public void TriggerSpawn(SpawnOnEvent spawnEvent, ActionEvent arg) { if (arg.State == spawnEvent.End && spawnEvent.ActiveGameObject != null) { ItemPool.Despawn(spawnEvent.ActiveGameObject); } else if (arg.State == spawnEvent.Start && spawnEvent.Prefab != null) { arg.GetSpawnPositionRotation(out var spawnPos, out var spawnRot); spawnEvent.ActiveGameObject = ItemPool.Spawn(spawnEvent.Prefab, spawnPos, spawnRot); if (spawnEvent.End == ActionState.None) { spawnEvent.ActiveGameObject = null; } } }
public void TriggerSpawn(SpawnOnEvent spawnEvent, ActionStateEvent arg) { if (arg.State == spawnEvent.EndEvent && spawnEvent.ActiveGameObject != null) { ItemPool.Despawn(spawnEvent.ActiveGameObject); } else if (arg.State == spawnEvent.StartEvent && spawnEvent.Prefab != null) { var animData = arg.Origin.Entity.Find <AnimatorComponent>(); var spawnPos = animData?.Value?.GetEventPosition ?? (arg.Origin.Tr != null ? arg.Origin.Tr.position : Vector3.zero); var spawnRot = animData?.Value?.GetEventRotation ?? (arg.Origin.Tr != null ? arg.Origin.Tr.rotation : Quaternion.identity); spawnEvent.ActiveGameObject = ItemPool.Spawn(spawnEvent.Prefab, spawnPos, spawnRot); if (spawnEvent.EndEvent == ActionStateEvents.None) { spawnEvent.ActiveGameObject = null; } } }