This commit is contained in:
SoulliesOfficial
2025-12-17 04:19:38 -05:00
parent 7c1cb7e8e1
commit d15957c719
4315 changed files with 8260710 additions and 2940 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Lean.Pool;
@@ -13,12 +14,14 @@ namespace SLSFramework.LeanPoolAssistance
[ShowIf("isAutoDespawn")][Tooltip("自动回收时间")]
public float autoDespawnTime = 1;
[ShowIf("isAutoDespawn")][Tooltip("自动回收计时器")][ReadOnly][HideInEditorMode]
public float despawnTimer;
private List<IPoolable> children;
private bool spawnExecuted = false;
protected bool spawnExecuted = false;
public void OnSpawn()
public virtual void OnSpawn()
{
if (spawnExecuted)
{
@@ -26,14 +29,30 @@ namespace SLSFramework.LeanPoolAssistance
}
spawnExecuted = true;
despawnTimer = 0;
children = GetComponentsInChildren<IPoolable>().ToList();
children.Remove(this);
children.ForEach(child => child.OnSpawn());
if (isAutoDespawn)
}
protected virtual void Update()
{
UpdateTimer(Time.deltaTime);
}
protected virtual void UpdateTimer(float deltaTime)
{
if (!isAutoDespawn)
{
LeanPool.Despawn(gameObject, autoDespawnTime);
return;
}
despawnTimer += deltaTime;
if (despawnTimer >= autoDespawnTime)
{
LeanPool.Despawn(gameObject);
}
}