protected override void OnUpdate() { //////////////////////////////////////////////////////////////////////////////////////// // Camera //////////////////////////////////////////////////////////////////////////////////////// if (CameraController.Instance != null) { Cache.CameraPosition = CameraController.Instance.CamPosition; Cache.CameraSize = CameraController.Instance.CamSize; } //////////////////////////////////////////////////////////////////////////////////////// // Player & Pawn //////////////////////////////////////////////////////////////////////////////////////// Cache.LocalPawn = PlayerHelpers.GetLocalSimPawnEntity(Cache.SimWorld); if (Cache.LocalPawn != Entity.Null) { Cache.LocalController = CommonReads.TryGetPawnController(Cache.SimWorld, Cache.LocalPawn); Cache.LocalPawnPosition = Cache.SimWorld.GetComponent <FixTranslation>(Cache.LocalPawn).Value; Cache.LocalPawnPositionFloat = Cache.LocalPawnPosition.ToUnityVec(); Cache.PlayerAP = Cache.SimWorld.GetComponent <ActionPoints>(Cache.LocalPawn).Value; Cache.PlayerMaxAP = Cache.SimWorld.GetComponent <MaximumFix <ActionPoints> >(Cache.LocalPawn).Value; } else { Cache.LocalController = Entity.Null; } //////////////////////////////////////////////////////////////////////////////////////// // Player Group //////////////////////////////////////////////////////////////////////////////////////// if (Cache.SimWorld.HasSingleton <PlayerGroupDataTag>()) { Cache.PlayerGroupEntity = Cache.SimWorld.GetSingletonEntity <PlayerGroupDataTag>(); Cache.GroupLifePoints = Cache.SimWorld.GetComponent <LifePoints>(Cache.PlayerGroupEntity); Cache.GroupHealth = Cache.SimWorld.GetComponent <Health>(Cache.PlayerGroupEntity); Cache.GroupMaxHealth = Cache.SimWorld.GetComponent <MaximumFix <Health> >(Cache.PlayerGroupEntity).Value; Cache.GroupShield = Cache.SimWorld.GetComponent <Shield>(Cache.PlayerGroupEntity); Cache.GroupMaxShield = Cache.SimWorld.GetComponent <MaximumFix <Shield> >(Cache.PlayerGroupEntity).Value; Cache.GroupPosition = Cache.SimWorld.GetComponent <FixTranslation>(Cache.PlayerGroupEntity).Value; } //////////////////////////////////////////////////////////////////////////////////////// // Pointer //////////////////////////////////////////////////////////////////////////////////////// { Cache.PointerWorldPosition = CameraService.Instance.ActiveCamera.ScreenToWorldPoint(Input.mousePosition); if (WorldUIEventSystem.Instance != null) { Cache.PointerInWorld = WorldUIEventSystem.Instance.MouseInWorld; } Cache.PointedTile = Helpers.GetTile(Cache.PointerWorldPosition); int hitCount = Physics2D.OverlapPointNonAlloc(Cache.PointerWorldPosition, _overlapResults, layerMask: ~0); Cache.PointedViewEntities.Clear(); Cache.PointedColliders.Clear(); Cache.PointedGameObjects.Clear(); for (int i = 0; i < hitCount; i++) { Cache.PointedColliders.Add(_overlapResults[i]); Cache.PointedGameObjects.AddUnique(_overlapResults[i].gameObject); if (_overlapResults[i].gameObject.TryGetComponent(out BindedSimEntityManaged bindedSimEntity)) { Cache.PointedViewEntities.Add(bindedSimEntity); } } Cache.PointedBodies.Clear(); var physicsWorldSys = Cache.SimWorld.GetExistingSystem <PhysicsWorldSystem>(); if (physicsWorldSys.PhysicsWorldFullyUpdated) { NativeList <OverlapPointHit> hits = new NativeList <OverlapPointHit>(Allocator.Temp); OverlapPointInput input = OverlapPointInput.Default; input.Position = Cache.PointerWorldPosition; physicsWorldSys.PhysicsWorld.OverlapPoint(input, ref hits); foreach (var hit in hits) { Cache.PointedBodies.Add(hit.Entity); } } } }