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