mirror of
https://github.com/DerTyp7/industrialize-unity.git
synced 2025-10-29 12:32:12 +01:00
Update ItemObject.cs
This commit is contained in:
@@ -15,6 +15,8 @@ public abstract class ItemObject : MonoBehaviour
|
|||||||
[SerializeField] private Vector2 conveyorDirection = Vector2.zero;
|
[SerializeField] private Vector2 conveyorDirection = Vector2.zero;
|
||||||
[SerializeField] private ConveyorPO currentConveyor;
|
[SerializeField] private ConveyorPO currentConveyor;
|
||||||
|
|
||||||
|
[SerializeField] private IOPort ioPort = null;
|
||||||
|
|
||||||
public abstract void OnSpawn();
|
public abstract void OnSpawn();
|
||||||
|
|
||||||
|
|
||||||
@@ -33,6 +35,7 @@ public abstract class ItemObject : MonoBehaviour
|
|||||||
|
|
||||||
private void OnCollisionEnter2D(Collision2D collision)
|
private void OnCollisionEnter2D(Collision2D collision)
|
||||||
{
|
{
|
||||||
|
// Stack Item
|
||||||
if (collision.gameObject.GetComponent<ItemObject>() != null)
|
if (collision.gameObject.GetComponent<ItemObject>() != null)
|
||||||
{
|
{
|
||||||
ItemObject collisionItemObject = collision.gameObject.GetComponent<ItemObject>();
|
ItemObject collisionItemObject = collision.gameObject.GetComponent<ItemObject>();
|
||||||
@@ -52,6 +55,12 @@ public abstract class ItemObject : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IOPort
|
||||||
|
if (collision.gameObject.GetComponent<IOPort>() != null)
|
||||||
|
{
|
||||||
|
ioPort = collision.gameObject.GetComponent<IOPort>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets the temporary pivot point based on the conveyor direction
|
// Gets the temporary pivot point based on the conveyor direction
|
||||||
@@ -132,6 +141,20 @@ public abstract class ItemObject : MonoBehaviour
|
|||||||
UpdateWithoutConveyor();
|
UpdateWithoutConveyor();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
#region IOPort
|
||||||
|
if (ioPort != null)
|
||||||
|
{
|
||||||
|
if (ioPort.item == itemSO)
|
||||||
|
{
|
||||||
|
stackSize = ioPort.IncreaseItemCount(stackSize);
|
||||||
|
if (stackSize == 0)
|
||||||
|
{
|
||||||
|
Despawn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateWithoutConveyor() // Handles the item when it is not on a conveyor
|
private void UpdateWithoutConveyor() // Handles the item when it is not on a conveyor
|
||||||
|
|||||||
Reference in New Issue
Block a user