Hold Tilt
This commit is contained in:
56
Assets/Scripts/EditorGame/Base/Pool/PooledObject.cs
Normal file
56
Assets/Scripts/EditorGame/Base/Pool/PooledObject.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Ichni
|
||||
{
|
||||
public class PooledObject : MonoBehaviour, IPoolable
|
||||
{
|
||||
public UnityAction onSpawn;
|
||||
public UnityAction onDespawn;
|
||||
|
||||
public void OnSpawn()
|
||||
{
|
||||
onSpawn?.Invoke();
|
||||
}
|
||||
|
||||
public void OnDespawn()
|
||||
{
|
||||
onDespawn?.Invoke();
|
||||
}
|
||||
|
||||
public void SetOnSpawn(UnityAction action, bool isOverride = false, bool isAdditive = false)
|
||||
{
|
||||
if (isOverride)
|
||||
{
|
||||
onSpawn = action;
|
||||
}
|
||||
else if (isAdditive)
|
||||
{
|
||||
onSpawn += action;
|
||||
}
|
||||
else
|
||||
{
|
||||
onSpawn ??= action;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetOnDespawn(UnityAction action, bool isOverride = false, bool isAdditive = false)
|
||||
{
|
||||
if (isOverride)
|
||||
{
|
||||
onDespawn = action;
|
||||
}
|
||||
else if (isAdditive)
|
||||
{
|
||||
onDespawn += action;
|
||||
}
|
||||
else
|
||||
{
|
||||
onDespawn ??= action;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/EditorGame/Base/Pool/PooledObject.cs.meta
Normal file
11
Assets/Scripts/EditorGame/Base/Pool/PooledObject.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6ba0e915cddec743a29f85a93f12594
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user