32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
![]() |
using UnityEngine;
|
||
|
using UnityEngine.Pool;
|
||
|
|
||
|
namespace BlueWater.Tycoons
|
||
|
{
|
||
|
public class Garnish : LiquidIngredient
|
||
|
{
|
||
|
private IObjectPool<Garnish> _managedPool;
|
||
|
|
||
|
public void Initialize(Vector3 spawnPosition, Quaternion rotation, Collider2D targetCollider, Vector3 pushForce, Sprite sprite)
|
||
|
{
|
||
|
transform.position = spawnPosition;
|
||
|
transform.rotation = rotation;
|
||
|
TargetCollider = targetCollider;
|
||
|
SpriteRenderer.sprite = sprite;
|
||
|
Rigidbody2D.linearVelocity = Vector2.zero;
|
||
|
|
||
|
CanInteraction = true;
|
||
|
gameObject.SetActive(true);
|
||
|
Rigidbody2D.AddForce(pushForce, ForceMode2D.Impulse);
|
||
|
}
|
||
|
|
||
|
public void SetManagedPool(IObjectPool<Garnish> pool) => _managedPool = pool;
|
||
|
public void Destroy() => _managedPool.Release(this);
|
||
|
|
||
|
public override void ReachedObject()
|
||
|
{
|
||
|
CanInteraction = false;
|
||
|
Destroy();
|
||
|
}
|
||
|
}
|
||
|
}
|