using DefaultNamespace; using Events; using Markers; using Tween; using Unity.Entities; using UnityEngine; namespace UI { [UpdateInGroup(typeof(InitializationSystemGroup))] public class WindowManagementSystem : ComponentSystem { protected override void OnUpdate() { Entities.WithAllReadOnly() .ForEach( (RectTransform rectTransform) => { if (!rectTransform.gameObject.activeSelf) { rectTransform.gameObject.SetActive(true); } }); Entities.WithAllReadOnly() .WithNone() .ForEach( (RectTransform rectTransform) => { if (rectTransform.gameObject.activeSelf) { rectTransform.gameObject.SetActive(false); } }); Entities.WithAllReadOnly() .ForEach( (Entity entity, WindowButtonPropertiesData properties) => { if (Input.GetButtonDown(properties.Button)) { PostUpdateCommands.RemoveComponent(entity); PostUpdateCommands.AddComponent(entity, new WindowCloseEventData { Player = GetSingletonEntity() }); } }); Entities.WithNone() .ForEach( (Entity entity, WindowButtonPropertiesData properties) => { if (Input.GetButtonDown(properties.Button)) { PostUpdateCommands.AddComponent(entity, new EnabledComponentData()); PostUpdateCommands.AddComponent(entity, new WindowOpenEventData { Player = GetSingletonEntity() }); PostUpdateCommands.StartTween(entity, 0.3f, EaseType.easeInOutExpo, new TweenScaleFromToData(Vector2.zero, Vector2.one)); } }); Entities.WithAllReadOnly().ForEach(entity => { PostUpdateCommands.RemoveComponent(entity); }); Entities.WithAllReadOnly().ForEach(entity => { PostUpdateCommands.RemoveComponent(entity); }); } } }