using Unity.Entities; using Unity.Tiny.Input; namespace Unity.TinyGems { public class RestartSystem : SystemBase { private EntityQuery m_CellsQuery; protected override void OnCreate() { base.OnCreate(); RequireSingletonForUpdate(); RequireSingletonForUpdate(); m_CellsQuery = GetEntityQuery(ComponentType.ReadWrite()); } protected override void OnUpdate() { var activeScene = GetSingleton(); var gameState = GetSingleton(); var input = World.GetExistingSystem(); if (activeScene.Value == Scenes.Title && InputUtil.GetInputDown(input)) { EntityManager.DestroyEntity(m_CellsQuery); AudioUtils.PlaySound(EntityManager, AudioTypes.StartGame); activeScene.Value = Scenes.Game; SetSingleton(activeScene); gameState.State = GameState.Spawn; gameState.Hearts = 3; SetSingleton(gameState); } } } }