Made fans move objects

This commit is contained in:
2026-04-11 15:26:19 +01:00
parent 75565f040e
commit 2222294a79
6 changed files with 249 additions and 12 deletions

View File

@@ -1,7 +1,45 @@
namespace Fruitomation.Game
using Fruitomation.Global;
using UnityEngine;
namespace Fruitomation.Game
{
public class FanBuilding : BuildingBase
{
[Header("Fan Specific Items")]
[SerializeField] private TriggerDetector TriggerDetector;
[SerializeField] private Animator FanAnimator;
private void Start()
{
TriggerDetector.SetAction((other) =>
{
if (other.transform.parent.TryGetComponent(out Rigidbody2D body))
{
body?.AddForce(-transform.right * Mathf.PI, ForceMode2D.Impulse);
}
});
}
private void Update()
{
if (GameStateController.Is(GameState.Simulation))
{
if (FanAnimator.speed == 0)
{
FanAnimator.Play(0, 0, 0f); // Play from beginning
FanAnimator.speed = 1; // Playing
}
}
else
{
if (FanAnimator.speed != 0)
{
FanAnimator.Play(0, 0, 0f); // Jump back to default frame
FanAnimator.speed = 0; // Paused
}
}
}
}
}
}