public static void ListCharacters() { var characterNodes = EntityController.GetNodeList <CharacterNode>(); Console.Log("Character Count " + characterNodes.UsedCount); characterNodes.Run( (ref CharacterNode node) => { Console.Log("Character " + node.Entity.DebugId); }); }
public void OnSystemUpdate(float dt, float unscaledDt) { if (_flyingList == null) { _flyingList = EntityController.GetNodeList <FlyingNode>(); } if (_flyingList != null) { _flyingList.Run(UpdateNode); } }
public SensorSystem() { NodeFilter <SensorDetectingNode> .Setup(SensorDetectingNode.GetTypes()); _sensorNodes = EntityController.GetNodeList <SensorDetectingNode>(); NodeFilter <UnitySensorNode> .Setup(UnitySensorNode.GetTypes()); _unitySensorNodes = EntityController.GetNodeList <UnitySensorNode>(); EntityController.RegisterReceiver(new EventReceiverFilter(this, new[] { typeof(SensorTargetsComponent) })); }
public void OnPeriodicUpdate() { if (_occupyNodes == null) { _occupyNodes = EntityController.GetNodeList <UnitOccupyingCellNode>(); } if (Game.GameActive && !Game.Paused) { _sensorNodes.Run(RunUpdate); _unitySensorNodes.Run(RunUpdate); } }
public MoverSystem() { NodeFilter <ForwardMoverNode> .Setup(ForwardMoverNode.GetTypes()); _forwardMovers = EntityController.GetNodeList <ForwardMoverNode>(); NodeFilter <RotateToNode> .Setup(RotateToNode.GetTypes()); _rotators = EntityController.GetNodeList <RotateToNode>(); NodeFilter <SimpleMoverNode> .Setup(SimpleMoverNode.GetTypes()); _simpleMovers = EntityController.GetNodeList <SimpleMoverNode>(); NodeFilter <ArcMoverNode> .Setup(ArcMoverNode.GetTypes()); _arcMovers = EntityController.GetNodeList <ArcMoverNode>(); }
public void OnFixedSystemUpdate(float dt) { if (_moverList == null) { _moverList = EntityController.GetNodeList <RigidbodyMoverNode>(); } if (_moverList != null) { _moverList.Run(HandleVelocityMover); } if (_frozen) { CheckRigidbodies(); } }
public void OnFixedSystemUpdate(float dt) { if (_moverList == null) { _moverList = EntityController.GetNodeList <RigidbodyMoverNode>(); } if (_moverList != null) { for (int i = 0; i < _moverList.Count; i++) { HandleVelocityMover(_moverList[i]); } } if (_frozen) { CheckRigidbodies(); } }
public void OnSystemUpdate(float dt) { if (_nodeList == null) { _nodeList = EntityController.GetNodeList <PathfindMoverNode>(); } if (_nodeList == null || Game.Paused) { return; } for (int i = 0; i < _nodeList.Count; i++) { var node = _nodeList[i]; var pathfinder = node.Pathfinder.c; if (node.Debugging.c != null) { node.Debugging.c.UpdateStatus(pathfinder); } if (!node.Target.c.IsValid) { node.Pathfinder.c.ReachedDestination(); continue; } var currentMoveTarget = node.Target.c.GetTargetPosition.toPoint3(); if (pathfinder.End != currentMoveTarget) { pathfinder.SetEnd(currentMoveTarget); continue; } switch (pathfinder.CurrentStatus) { case SimplePathfindingAgent.Status.NoPath: if (pathfinder.Redirected && pathfinder.CanRepath) { pathfinder.SearchPath(); } continue; case SimplePathfindingAgent.Status.InvalidPath: case SimplePathfindingAgent.Status.Created: case SimplePathfindingAgent.Status.WaitingOnPath: continue; case SimplePathfindingAgent.Status.PathReceived: case SimplePathfindingAgent.Status.WaitingOnNode: if (pathfinder.CurrentStatus == SimplePathfindingAgent.Status.PathReceived) { if (node.Debugging.c != null) { node.Debugging.c.SetPath(pathfinder.CurrentNodePath); } _grid.SetStationaryAgent(pathfinder.CurrentPos, pathfinder.Entity, false); } if (!node.Pathfinder.c.TryEnterNextNode()) { continue; } break; } var moveSpeed = node.GetMoveSpeed; if (pathfinder.IsLastIndex) { moveSpeed *= 0.5f; } pathfinder.MovementLerp += dt * moveSpeed; float dst = pathfinder.GetCurrentDistance(); float progress = Mathf.Clamp01(pathfinder.MovementLerp / dst); node.Entity.Tr.position = Vector3.Lerp(pathfinder.PreviousTarget, pathfinder.CurrentTarget, progress); var dir = pathfinder.CurrentTarget - pathfinder.PreviousTarget; var nextRotation = dir != Vector3.zero ? Quaternion.LookRotation(dir, Vector3.up) : pathfinder.Entity.Tr.rotation; pathfinder.Entity.Tr.rotation = Quaternion.RotateTowards(pathfinder.Entity.Tr.rotation, nextRotation, _pathfinderRotationSpeed * dt); if (progress < 1) { continue; } _grid.Exit(node.Entity, pathfinder.GridTarget); pathfinder.CurrentPos = pathfinder.GridTarget; if (pathfinder.CurrentIndex >= pathfinder.CurrentNodePath.Count - 1) { node.Pathfinder.c.ReachedDestination(); node.Target.c.Clear(); if (node.Debugging.c != null) { node.Debugging.c.ClearPath(); } continue; } pathfinder.AdvancePath(); if (pathfinder.CanRepath) { pathfinder.SearchPath(); continue; } pathfinder.TryEnterNextNode(); } }
public FlightNpcSystem() { NodeFilter <NpcFlyingNode> .Setup(NpcFlyingNode.GetTypes()); _flyingList = EntityController.GetNodeList <NpcFlyingNode>(); }
public DirectionalSpriteSystem() { NodeFilter <DirectionalSpriteNode> .Setup(DirectionalSpriteNode.GetTypes()); _directionalComponents = EntityController.GetNodeList <DirectionalSpriteNode>(); }
public FlightPhysicsSystem() { NodeFilter <FlyingNode> .Setup(FlyingNode.GetTypes()); _flyingList = EntityController.GetNodeList <FlyingNode>(); }
public CollisionCheckSystem() { NodeFilter <CollisionCheckForwardNode> .Setup(CollisionCheckForwardNode.GetTypes()); _list = EntityController.GetNodeList <CollisionCheckForwardNode>(); }
public void OnPeriodicUpdate() { if (_visibleNodes == null) { _visibleNodes = EntityController.GetNodeList <UnitOccupyingCellNode>(); } if (_sensorList == null) { _sensorList = EntityController.GetNodeList <SensorDetectingNode>(); } if (_visibleNodes == null || _sensorList == null || !Game.GameActive || Game.Paused) { return; } var ls = World.Get <LineOfSightSystem>(); for (int n = 0; n < _sensorList.Count; n++) { var node = _sensorList[n]; var sensor = node.Sensor.c; sensor.DetectedCells.Clear(); var start = node.Position.c.Position; sensor.LastDetectedCenter = start; var fwd = node.Entity.Tr.ForwardDirection2D(); for (int i = 0; i < DirectionsExtensions.Length2D; i++) { var dir = (Directions)i; var maxRowDistance = dir == fwd ? sensor.MaxVisionDistance : sensor.MaxHearDistance; var adjacent = dir.Adjacent(); ShadowFloodFill.CheckRow(ref sensor.DetectedCells, start, start, maxRowDistance, new[] { adjacent[0].ToPoint3(), adjacent[1].ToPoint3() }, dir.ToPoint3()); } for (int i = 0; i < _visibleNodes.Count; i++) { var visible = _visibleNodes[i]; if (visible.Entity == node.Entity) { continue; } if (!sensor.DetectedCells.Contains(visible.Position.c)) { continue; } var isVision = true; if (CheckVision) { ls.CanSeeOrHear(node.Entity, visible.Entity, out isVision); } sensor.AddWatch(visible.Entity, isVision); } for (int w = sensor.WatchTargets.Count - 1; w >= 0; w--) { if (sensor.WatchTargets[w].Target == null) { sensor.RemoveWatch(sensor.WatchTargets[w]); continue; } sensor.WatchTargets[w].LastSensedTurnCount++; if (sensor.WatchTargets[w].LastSensedTurnCount > MaxTurnsNpcVisible) { sensor.RemoveWatch(sensor.WatchTargets[w]); } } } }
public MapSystem() { NodeFilter <UnitOccupyingCellNode> .Setup(UnitOccupyingCellNode.GetTypes()); _nodeList = EntityController.GetNodeList <UnitOccupyingCellNode>(); }