File size: 1,465 Bytes
6e8f8e9
 
 
 
 
90a6dae
12bd634
90a6dae
 
12bd634
 
 
 
90a6dae
35113a1
 
 
 
 
 
90a6dae
 
12bd634
90a6dae
12bd634
35113a1
12bd634
35113a1
12bd634
35113a1
12bd634
 
90a6dae
 
 
 
 
12bd634
 
90a6dae
6e8f8e9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using UnityEngine;

public class ItemData : MonoBehaviour
{
    public string itemID;

    [Header("Grid Size (Width, Height, Depth)")]
    public Vector3Int baseFootprint = new Vector3Int(1, 1, 1);

    // Variables used by InventoryPlacer
    [HideInInspector] public Vector3Int gridPosition;
    [HideInInspector] public Vector3Int currentFootprint;
    [HideInInspector] public int swapState = 0;

    // Defines how the item rotates logically.
    // State0: (W, H, D)  - default, bulk consumes Y (vertical).
    // State1: (H, W, D)  - swap W<->H, bulk consumes X (horizontal).
    // State2: (W, D, H)  - swap H<->D, bulk consumes Z (depth).
    // Priority when placing: try State0 first, then State1, then State2 - i.e. prefer vertical,
    // then horizontal, then depth.
    public Vector3Int FootprintAtState(int state)
    {
        switch (state)
        {
            case 0:
                return baseFootprint; // Normal (W, H, D) - bulk on Y
            case 1:
                return new Vector3Int(baseFootprint.y, baseFootprint.x, baseFootprint.z); // Swap Width and Height - bulk on X
            case 2:
                return new Vector3Int(baseFootprint.x, baseFootprint.z, baseFootprint.y); // Swap Height and Depth - bulk on Z
            default:
                return baseFootprint;
        }
    }

    public void ApplySwapState(int state)
    {
        swapState = state;
        currentFootprint = FootprintAtState(state);
    }
}