Refator
Browse files
Assets/Prefabs/objTstOrient1.fbx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:959a865e2418cffdf1faef58350bcb513b950811e1a7fa83a194e5f38d5dfe77
|
| 3 |
+
size 12684
|
Assets/Prefabs/objTstOrient1.fbx.meta
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fileFormatVersion: 2
|
| 2 |
+
guid: 4f1c004b5acbc994ab56e557d1e7a39c
|
| 3 |
+
ModelImporter:
|
| 4 |
+
serializedVersion: 22200
|
| 5 |
+
internalIDToNameTable: []
|
| 6 |
+
externalObjects: {}
|
| 7 |
+
materials:
|
| 8 |
+
materialImportMode: 2
|
| 9 |
+
materialName: 0
|
| 10 |
+
materialSearch: 1
|
| 11 |
+
materialLocation: 1
|
| 12 |
+
animations:
|
| 13 |
+
legacyGenerateAnimations: 4
|
| 14 |
+
bakeSimulation: 0
|
| 15 |
+
resampleCurves: 1
|
| 16 |
+
optimizeGameObjects: 0
|
| 17 |
+
removeConstantScaleCurves: 0
|
| 18 |
+
motionNodeName:
|
| 19 |
+
rigImportErrors:
|
| 20 |
+
rigImportWarnings:
|
| 21 |
+
animationImportErrors:
|
| 22 |
+
animationImportWarnings:
|
| 23 |
+
animationRetargetingWarnings:
|
| 24 |
+
animationDoRetargetingWarnings: 0
|
| 25 |
+
importAnimatedCustomProperties: 0
|
| 26 |
+
importConstraints: 0
|
| 27 |
+
animationCompression: 1
|
| 28 |
+
animationRotationError: 0.5
|
| 29 |
+
animationPositionError: 0.5
|
| 30 |
+
animationScaleError: 0.5
|
| 31 |
+
animationWrapMode: 0
|
| 32 |
+
extraExposedTransformPaths: []
|
| 33 |
+
extraUserProperties: []
|
| 34 |
+
clipAnimations: []
|
| 35 |
+
isReadable: 0
|
| 36 |
+
meshes:
|
| 37 |
+
lODScreenPercentages: []
|
| 38 |
+
globalScale: 1
|
| 39 |
+
meshCompression: 0
|
| 40 |
+
addColliders: 0
|
| 41 |
+
useSRGBMaterialColor: 1
|
| 42 |
+
sortHierarchyByName: 1
|
| 43 |
+
importPhysicalCameras: 1
|
| 44 |
+
importVisibility: 1
|
| 45 |
+
importBlendShapes: 1
|
| 46 |
+
importCameras: 1
|
| 47 |
+
importLights: 1
|
| 48 |
+
nodeNameCollisionStrategy: 1
|
| 49 |
+
fileIdsGeneration: 2
|
| 50 |
+
swapUVChannels: 0
|
| 51 |
+
generateSecondaryUV: 0
|
| 52 |
+
useFileUnits: 1
|
| 53 |
+
keepQuads: 0
|
| 54 |
+
weldVertices: 1
|
| 55 |
+
bakeAxisConversion: 0
|
| 56 |
+
preserveHierarchy: 0
|
| 57 |
+
skinWeightsMode: 0
|
| 58 |
+
maxBonesPerVertex: 4
|
| 59 |
+
minBoneWeight: 0.001
|
| 60 |
+
optimizeBones: 1
|
| 61 |
+
meshOptimizationFlags: -1
|
| 62 |
+
indexFormat: 0
|
| 63 |
+
secondaryUVAngleDistortion: 8
|
| 64 |
+
secondaryUVAreaDistortion: 15.000001
|
| 65 |
+
secondaryUVHardAngle: 88
|
| 66 |
+
secondaryUVMarginMethod: 1
|
| 67 |
+
secondaryUVMinLightmapResolution: 40
|
| 68 |
+
secondaryUVMinObjectScale: 1
|
| 69 |
+
secondaryUVPackMargin: 4
|
| 70 |
+
useFileScale: 1
|
| 71 |
+
strictVertexDataChecks: 0
|
| 72 |
+
tangentSpace:
|
| 73 |
+
normalSmoothAngle: 60
|
| 74 |
+
normalImportMode: 0
|
| 75 |
+
tangentImportMode: 3
|
| 76 |
+
normalCalculationMode: 4
|
| 77 |
+
legacyComputeAllNormalsFromSmoothingGroupsWhenMeshHasBlendShapes: 0
|
| 78 |
+
blendShapeNormalImportMode: 1
|
| 79 |
+
normalSmoothingSource: 0
|
| 80 |
+
referencedClips: []
|
| 81 |
+
importAnimation: 1
|
| 82 |
+
humanDescription:
|
| 83 |
+
serializedVersion: 3
|
| 84 |
+
human: []
|
| 85 |
+
skeleton: []
|
| 86 |
+
armTwist: 0.5
|
| 87 |
+
foreArmTwist: 0.5
|
| 88 |
+
upperLegTwist: 0.5
|
| 89 |
+
legTwist: 0.5
|
| 90 |
+
armStretch: 0.05
|
| 91 |
+
legStretch: 0.05
|
| 92 |
+
feetSpacing: 0
|
| 93 |
+
globalScale: 1
|
| 94 |
+
rootMotionBoneName:
|
| 95 |
+
hasTranslationDoF: 0
|
| 96 |
+
hasExtraRoot: 0
|
| 97 |
+
skeletonHasParents: 1
|
| 98 |
+
lastHumanDescriptionAvatarSource: {instanceID: 0}
|
| 99 |
+
autoGenerateAvatarMappingIfUnspecified: 1
|
| 100 |
+
animationType: 2
|
| 101 |
+
humanoidOversampling: 1
|
| 102 |
+
avatarSetup: 0
|
| 103 |
+
addHumanoidExtraRootOnlyWhenUsingAvatar: 1
|
| 104 |
+
importBlendShapeDeformPercent: 1
|
| 105 |
+
remapMaterialsIfMaterialImportModeIsNone: 0
|
| 106 |
+
additionalBone: 0
|
| 107 |
+
userData:
|
| 108 |
+
assetBundleName:
|
| 109 |
+
assetBundleVariant:
|
Assets/Scenes/SampleScene.unity
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Assets/Scripts/Inventory/InventoryManager.cs
CHANGED
|
@@ -12,7 +12,7 @@ public class InventoryManager : MonoBehaviour
|
|
| 12 |
public int depthCount = 3; // Depth into the bag
|
| 13 |
|
| 14 |
[Header("Grid Settings (Visual)")]
|
| 15 |
-
public Vector3 gridOffset = new Vector3(0f, 0.
|
| 16 |
public Vector3 gridScale = new Vector3(1.75f, 1.75f, 1f);
|
| 17 |
public float cellSize = 0.15f;
|
| 18 |
public float gridSpacing = 0.05f;
|
|
@@ -140,7 +140,7 @@ public class InventoryManager : MonoBehaviour
|
|
| 140 |
foreach (var col in colliders) col.enabled = false;
|
| 141 |
|
| 142 |
// 4. Scale: intentionally left at Vector3.one (set in step 2). Items keep their true
|
| 143 |
-
// authored world size a footprint of N slots should measure exactly N * cellSize,
|
| 144 |
// never be scaled up/down to visually "fit". Only rotation (swap state) and position
|
| 145 |
// (grid slot) change.
|
| 146 |
|
|
@@ -156,17 +156,20 @@ public class InventoryManager : MonoBehaviour
|
|
| 156 |
|
| 157 |
itemObj.transform.localPosition = new Vector3(xPos, yPos, zPos);
|
| 158 |
|
| 159 |
-
// 6. Rotation based on swapState
|
|
|
|
|
|
|
|
|
|
| 160 |
switch (itemData.swapState)
|
| 161 |
{
|
| 162 |
case 0:
|
| 163 |
itemObj.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
| 164 |
break;
|
| 165 |
case 1:
|
| 166 |
-
itemObj.transform.localRotation = Quaternion.Euler(0, 0, 90f);
|
| 167 |
break;
|
| 168 |
case 2:
|
| 169 |
-
itemObj.transform.localRotation = Quaternion.Euler(
|
| 170 |
break;
|
| 171 |
}
|
| 172 |
}
|
|
|
|
| 12 |
public int depthCount = 3; // Depth into the bag
|
| 13 |
|
| 14 |
[Header("Grid Settings (Visual)")]
|
| 15 |
+
public Vector3 gridOffset = new Vector3(0f, 0.25f, 0.35f);
|
| 16 |
public Vector3 gridScale = new Vector3(1.75f, 1.75f, 1f);
|
| 17 |
public float cellSize = 0.15f;
|
| 18 |
public float gridSpacing = 0.05f;
|
|
|
|
| 140 |
foreach (var col in colliders) col.enabled = false;
|
| 141 |
|
| 142 |
// 4. Scale: intentionally left at Vector3.one (set in step 2). Items keep their true
|
| 143 |
+
// authored world size - a footprint of N slots should measure exactly N * cellSize,
|
| 144 |
// never be scaled up/down to visually "fit". Only rotation (swap state) and position
|
| 145 |
// (grid slot) change.
|
| 146 |
|
|
|
|
| 156 |
|
| 157 |
itemObj.transform.localPosition = new Vector3(xPos, yPos, zPos);
|
| 158 |
|
| 159 |
+
// 6. Rotation based on swapState.
|
| 160 |
+
// Model convention: Z = face axis, Y = up axis, X = side axis.
|
| 161 |
+
// State1 (bulk moves onto X / horizontal): roll -90 deg around Z.
|
| 162 |
+
// State2 (bulk moves onto Z / depth): pitch -90 deg around X.
|
| 163 |
switch (itemData.swapState)
|
| 164 |
{
|
| 165 |
case 0:
|
| 166 |
itemObj.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
| 167 |
break;
|
| 168 |
case 1:
|
| 169 |
+
itemObj.transform.localRotation = Quaternion.Euler(0, 0, -90f);
|
| 170 |
break;
|
| 171 |
case 2:
|
| 172 |
+
itemObj.transform.localRotation = Quaternion.Euler(-90f, 0, 0);
|
| 173 |
break;
|
| 174 |
}
|
| 175 |
}
|
Assets/Scripts/Inventory/Inventoryplacer.cs
CHANGED
|
@@ -54,30 +54,25 @@ public class InventoryPlacer
|
|
| 54 |
if (hasExisting)
|
| 55 |
{
|
| 56 |
ItemData lastCopy = existingStack[existingStack.Count - 1];
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
//
|
| 60 |
-
//
|
| 61 |
-
//
|
| 62 |
-
//
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
{
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
if (LockLastCopyAtStateTwo(lastCopy))
|
| 68 |
-
{
|
| 69 |
-
if (!wasAlreadyLocked) reflowed?.Add(lastCopy);
|
| 70 |
-
|
| 71 |
-
if (TryPlaceBeneathLockedCopy(lastCopy, item) || TryPlaceBehindStack(lastCopy, item))
|
| 72 |
-
{
|
| 73 |
-
RegisterPlacement(item);
|
| 74 |
-
return true;
|
| 75 |
-
}
|
| 76 |
-
}
|
| 77 |
-
|
| 78 |
-
// Either lastCopy couldn't lock at state 2 here, or there's no room beneath/behind it -
|
| 79 |
-
// this duplicate can't stack against lastCopy. Fall back to a fully fresh search below.
|
| 80 |
}
|
|
|
|
|
|
|
|
|
|
| 81 |
}
|
| 82 |
|
| 83 |
if (TryPlaceFresh(item))
|
|
@@ -89,53 +84,6 @@ public class InventoryPlacer
|
|
| 89 |
return false;
|
| 90 |
}
|
| 91 |
|
| 92 |
-
/// <summary>
|
| 93 |
-
/// Lookahead check: would locking lastCopy to State2 (or leaving it, if already locked) actually
|
| 94 |
-
/// open up room for newItem, either beneath it in the same column or behind it in another Z lane?
|
| 95 |
-
/// Does NOT mutate the grid - simulates the post-lock footprint/position mathematically.
|
| 96 |
-
/// Prevents needlessly rotating lastCopy into State2 when there's no depth left to exploit it.
|
| 97 |
-
/// </summary>
|
| 98 |
-
private bool WouldLockingCreateUsableRoom(ItemData lastCopy, ItemData newItem)
|
| 99 |
-
{
|
| 100 |
-
Vector3Int lockedOrigin = lastCopy.gridPosition;
|
| 101 |
-
Vector3Int lockedFootprint = lastCopy.swapState == 2 ? lastCopy.currentFootprint : lastCopy.FootprintAtState(2);
|
| 102 |
-
|
| 103 |
-
int lineIndex = lockedOrigin.x;
|
| 104 |
-
int depthLane = lockedOrigin.z;
|
| 105 |
-
int startY = lockedOrigin.y + lockedFootprint.y;
|
| 106 |
-
|
| 107 |
-
// Room beneath, in the same column/lane?
|
| 108 |
-
if (CanFitAnyStateAtColumn(newItem, lineIndex, depthLane, startY, grid.rowCount))
|
| 109 |
-
return true;
|
| 110 |
-
|
| 111 |
-
// Room behind, in any other Z lane available to this itemID?
|
| 112 |
-
for (int z = 1; z < grid.depthCount; z++)
|
| 113 |
-
{
|
| 114 |
-
if (!grid.DepthLaneAvailableFor(lineIndex, z, newItem.itemID)) continue;
|
| 115 |
-
if (CanFitAnyStateAtColumn(newItem, lineIndex, z, 0, grid.rowCount))
|
| 116 |
-
return true;
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
return false;
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
/// <summary>Read-only version of TryStatesAtColumn's search - checks fit without occupying.</summary>
|
| 123 |
-
private bool CanFitAnyStateAtColumn(ItemData item, int x, int z, int startY, int rowLimit)
|
| 124 |
-
{
|
| 125 |
-
bool cube = IsCube(item);
|
| 126 |
-
for (int y = startY; y < rowLimit; y++)
|
| 127 |
-
{
|
| 128 |
-
int maxState = cube ? 0 : 2;
|
| 129 |
-
for (int state = 0; state <= maxState; state++)
|
| 130 |
-
{
|
| 131 |
-
Vector3Int footprint = item.FootprintAtState(state);
|
| 132 |
-
if (grid.IsRegionFreeForItem(new Vector3Int(x, y, z), footprint, item.itemID))
|
| 133 |
-
return true;
|
| 134 |
-
}
|
| 135 |
-
}
|
| 136 |
-
return false;
|
| 137 |
-
}
|
| 138 |
-
|
| 139 |
/// <summary>Removes an item from the grid and placement bookkeeping (e.g. item dropped/consumed).</summary>
|
| 140 |
public void Remove(ItemData item)
|
| 141 |
{
|
|
|
|
| 54 |
if (hasExisting)
|
| 55 |
{
|
| 56 |
ItemData lastCopy = existingStack[existingStack.Count - 1];
|
| 57 |
+
bool wasAlreadyLocked = lastCopy.swapState == 2;
|
| 58 |
+
|
| 59 |
+
// Try to lock lastCopy to State2 - this is what USUALLY frees the most room (shrinks its
|
| 60 |
+
// Y footprint, banking the freed space into depth). But locking can legitimately fail
|
| 61 |
+
// (e.g. its State2 footprint would run out of depth bounds) - in that case lastCopy simply
|
| 62 |
+
// stays exactly as it already sits, and we still try to slot the duplicate in beneath/behind
|
| 63 |
+
// it using whatever footprint it currently has. Locking is an optimization, not a
|
| 64 |
+
// precondition - the duplicate can still find room next to an unlocked lastCopy.
|
| 65 |
+
bool locked = LockLastCopyAtStateTwo(lastCopy);
|
| 66 |
+
if (locked && !wasAlreadyLocked) reflowed?.Add(lastCopy);
|
| 67 |
+
|
| 68 |
+
if (TryPlaceBeneathLockedCopy(lastCopy, item) || TryPlaceBehindStack(lastCopy, item))
|
| 69 |
{
|
| 70 |
+
RegisterPlacement(item);
|
| 71 |
+
return true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
}
|
| 73 |
+
|
| 74 |
+
// No room beneath or behind lastCopy in whatever state it ended up in - this duplicate
|
| 75 |
+
// can't stack against lastCopy. Fall back to a fully fresh search below.
|
| 76 |
}
|
| 77 |
|
| 78 |
if (TryPlaceFresh(item))
|
|
|
|
| 84 |
return false;
|
| 85 |
}
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
/// <summary>Removes an item from the grid and placement bookkeeping (e.g. item dropped/consumed).</summary>
|
| 88 |
public void Remove(ItemData item)
|
| 89 |
{
|