private void UpdateCursorState(CursorState cursorState) { var ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit, 200)) { var objectHit = hit.collider.gameObject; if (objectHit.GetEntityId() != EntityIdComponent.InvalidEntityId) { var nowSelectedEntity = entitySystem.GetEntity(objectHit.GetEntityId()); cursorState.DebugEntity = nowSelectedEntity; if (!nowSelectedEntity.HasState <InteractiveState>() || nowSelectedEntity.GetState <InteractiveState>().CurrentlyInteractive) { cursorState.SelectedEntity = GetEntitiesInRange().Contains(nowSelectedEntity) ? nowSelectedEntity : null; } else { cursorState.SelectedEntity = null; } } else { cursorState.SelectedEntity = null; } cursorState.MousedOverPosition = hit.point; } }
public void OnEntityAdded(Entity entity) { var gameObject = entity.GetState <BlueprintGameObjectState>().BlueprintGameObject; var waypointSpawner = gameObject.GetComponent <WaypointSpawner>(); Entity nextWaypoint = null; if (waypointSpawner != null) { var nextWaypointObject = waypointSpawner.NextWaypoint; if (nextWaypointObject != null) { var entityIdOfNextWaypoint = nextWaypointObject.GetComponent <EntityIdComponent>().EntityId; nextWaypoint = entitySystem.GetEntity(entityIdOfNextWaypoint); } } entity.GetState <WaypointState>().NextWaypoint = nextWaypoint; }
public void OnEntityAdded(Entity entity) { var goalSatisfierState = entity.GetState <GoalSatisfierState>(); var childWaypointsState = entity.GetState <ChildWaypointsState>(); var childWaypoints = entity.GameObject.GetComponentsInChildren <WaypointVisualizer>(); for (var i = 0; i < childWaypoints.Length; i++) { var waypointChildId = childWaypoints[i].GetComponent <EntityIdComponent>().EntityId; var waypointChild = entitySystem.GetEntity(waypointChildId); childWaypointsState.AddChild(waypointChild); var childSatisfierState = waypointChild.GetState <GoalSatisfierState>(); var childGoals = childSatisfierState.SatisfiedGoals; goalSatisfierState.SatisfiedGoals.AddRange(childGoals); } }