/// <inheritdoc /> public override void Initialize() { _pauseManager = IoCManager.Resolve <IPauseManager>(); EntityQuery = new TypeEntityQuery(typeof(PlayerInputMoverComponent)); var moveUpCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.North, true), session => HandleDirChange(session, Direction.North, false)); var moveLeftCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.West, true), session => HandleDirChange(session, Direction.West, false)); var moveRightCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.East, true), session => HandleDirChange(session, Direction.East, false)); var moveDownCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.South, true), session => HandleDirChange(session, Direction.South, false)); var runCmdHandler = InputCmdHandler.FromDelegate( session => HandleRunChange(session, true), session => HandleRunChange(session, false)); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); input.BindMap.BindFunction(EngineKeyFunctions.MoveUp, moveUpCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.MoveLeft, moveLeftCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.MoveRight, moveRightCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.MoveDown, moveDownCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.Run, runCmdHandler); }
/// <inheritdoc /> public override void FrameUpdate(float frameTime) { var renderTreeSystem = EntitySystemManager.GetEntitySystem <RenderingTreeSystem>(); // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var currentMap = _eyeManager.CurrentMap; if (currentMap == MapId.Nullspace) { return; } var mapTree = renderTreeSystem.GetSpriteTreeForMap(currentMap); var pvsEntities = mapTree.Query(pvsBounds, true); foreach (var sprite in pvsEntities) { if (sprite.IsInert) { continue; } sprite.FrameUpdate(frameTime); } }
/// <inheritdoc /> public override void FrameUpdate(float frameTime) { var renderTreeSystem = EntitySystemManager.GetEntitySystem <RenderingTreeSystem>(); // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var currentMap = _eyeManager.CurrentMap; if (currentMap == MapId.Nullspace) { return; } var mapTree = renderTreeSystem.GetSpriteTreeForMap(currentMap); mapTree.QueryAabb(ref frameTime, (ref float state, in SpriteComponent value) => { if (value.IsInert) { return(true); } value.FrameUpdate(state); return(true); }, pvsBounds, approx: true); }
private void DispatchGraph(SharedAiDebug.RequestPathfindingGraphMessage message) { var pathfindingSystem = EntitySystemManager.GetEntitySystem <PathfindingSystem>(); var mapManager = IoCManager.Resolve <IMapManager>(); var result = new Dictionary <int, List <Vector2> >(); var idx = 0; foreach (var(gridId, chunks) in pathfindingSystem.Graph) { var gridManager = mapManager.GetGrid(gridId); foreach (var chunk in chunks.Values) { var nodes = new List <Vector2>(); foreach (var node in chunk.Nodes) { var worldTile = gridManager.GridTileToWorldPos(node.TileRef.GridIndices); nodes.Add(worldTile); } result.Add(idx, nodes); idx++; } } var systemMessage = new SharedAiDebug.PathfindingGraphMessage(result); EntityManager.EntityNetManager.SendSystemNetworkMessage(systemMessage); }
/// <inheritdoc /> public override void Initialize() { EntityQuery = new TypeEntityQuery(typeof(IMoverComponent)); var moveUpCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.North, true), session => HandleDirChange(session, Direction.North, false)); var moveLeftCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.West, true), session => HandleDirChange(session, Direction.West, false)); var moveRightCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.East, true), session => HandleDirChange(session, Direction.East, false)); var moveDownCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.South, true), session => HandleDirChange(session, Direction.South, false)); var runCmdHandler = InputCmdHandler.FromDelegate( session => HandleRunChange(session, true), session => HandleRunChange(session, false)); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); input.BindMap.BindFunction(EngineKeyFunctions.MoveUp, moveUpCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.MoveLeft, moveLeftCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.MoveRight, moveRightCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.MoveDown, moveDownCmdHandler); input.BindMap.BindFunction(EngineKeyFunctions.Run, runCmdHandler); SubscribeEvent <PlayerAttachSystemMessage>(PlayerAttached); SubscribeEvent <PlayerDetachedSystemMessage>(PlayerDetached); _audioSystem = EntitySystemManager.GetEntitySystem <AudioSystem>(); }
public override void Initialize() { var inputSys = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSys.BindMap.BindFunction(ContentKeyFunctions.UseItemInHand, new PointerInputCmdHandler(HandleUseItemInHand)); inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld, new PointerInputCmdHandler((HandleUseItemInWorld))); }
public override void Initialize() { base.Initialize(); IoCManager.InjectDependencies(this); _inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); }
public override void Initialize() { IoCManager.InjectDependencies(this); var inputSys = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSys.BindMap.BindFunction(ContentKeyFunctions.ExamineEntity, new PointerInputCmdHandler(HandleExamine)); }
#pragma warning restore 649 public override void Initialize() { base.Initialize(); var inputSys = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSys.BindMap.BindFunction(ContentKeyFunctions.OpenInventoryMenu, InputCmdHandler.FromDelegate(s => HandleOpenInventoryMenu())); }
#pragma warning restore 649 public override void Initialize() { base.Initialize(); var inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSystem.BindMap.BindFunction(ContentKeyFunctions.ToggleCombatMode, InputCmdHandler.FromDelegate(CombatModeToggled)); }
public override void Initialize() { base.Initialize(); SubscribeLocalEvent <PlayerDetachedSystemMessage>(PlayerDetached); _audioSystem = EntitySystemManager.GetEntitySystem <AudioSystem>(); UpdatesBefore.Add(typeof(PhysicsSystem)); }
#pragma warning restore 649 public override void Initialize() { base.Initialize(); var inputSys = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSys.BindMap.BindFunction(ContentKeyFunctions.OpenCraftingMenu, new PointerInputCmdHandler(HandleOpenCraftingMenu)); }
public override void Shutdown() { //WARN: Tightly couples this system with InputSystem, and assumes InputSystem exists and is initialized var inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSystem.BindMap.UnbindFunction(EngineKeyFunctions.CameraRotateRight); inputSystem.BindMap.UnbindFunction(EngineKeyFunctions.CameraRotateLeft); base.Shutdown(); }
public override void Initialize() { base.Initialize(); _gameHud.OnCombatModeChanged = OnCombatModeChanged; _gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged; _inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); _inputSystem.BindMap.BindFunction(ContentKeyFunctions.ToggleCombatMode, InputCmdHandler.FromDelegate(CombatModeToggled)); }
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons /// <inheritdoc /> public override void Initialize() { base.Initialize(); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); input.BindMap.BindFunction(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands)); input.BindMap.BindFunction(ContentKeyFunctions.Drop, new PointerInputCmdHandler(HandleDrop)); input.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInHand, InputCmdHandler.FromDelegate(HandleActivateItem)); input.BindMap.BindFunction(ContentKeyFunctions.ThrowItemInHand, new PointerInputCmdHandler(HandleThrowItem)); }
public override void Initialize() { base.Initialize(); IoCManager.InjectDependencies(this); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); input.BindMap.BindFunction(ContentKeyFunctions.OpenContextMenu, new PointerInputCmdHandler(OnOpenContextMenu)); }
public override void Initialize() { base.Initialize(); EntityQuery = new TypeEntityQuery(typeof(EyeComponent)); //WARN: Tightly couples this system with InputSystem, and assumes InputSystem exists and is initialized var inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSystem.BindMap.BindFunction(EngineKeyFunctions.CameraRotateRight, new NullInputCmdHandler()); inputSystem.BindMap.BindFunction(EngineKeyFunctions.CameraRotateLeft, new NullInputCmdHandler()); }
public override void Initialize() { base.Initialize(); _gameHud.OnCombatModeChanged = OnCombatModeChanged; _gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged; _inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); _inputSystem.BindMap.BindFunction(ContentKeyFunctions.UseOrAttack, new InputHandler(this)); _overlayManager.AddOverlay(new CombatModeOverlay(this)); }
#pragma warning restore 649 public override void Initialize() { base.Initialize(); SubscribeNetworkEvent <SetTargetZoneMessage>(SetTargetZoneHandler); SubscribeNetworkEvent <SetCombatModeActiveMessage>(SetCombatModeActiveHandler); var inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); inputSystem.BindMap.BindFunction(ContentKeyFunctions.ToggleCombatMode, InputCmdHandler.FromDelegate(CombatModeToggled)); }
#pragma warning restore 649 public override void Initialize() { base.Initialize(); var inputSys = EntitySystemManager.GetEntitySystem <InputSystem>(); CommandBinds.Builder .Bind(ContentKeyFunctions.OpenCraftingMenu, new PointerInputCmdHandler(HandleOpenCraftingMenu)) .Bind(EngineKeyFunctions.Use, new PointerInputCmdHandler(HandleUse)) .Register <ConstructorSystem>(); }
public override void Initialize() { base.Initialize(); SubscribeNetworkEvent <VerbSystemMessages.VerbsResponseMessage>(FillEntityPopup); IoCManager.InjectDependencies(this); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); input.BindMap.BindFunction(ContentKeyFunctions.OpenContextMenu, new PointerInputCmdHandler(OnOpenContextMenu)); }
private const float ThrowForce = 1.5f; // Throwing force of mobs in Newtons /// <inheritdoc /> public override void Initialize() { base.Initialize(); SubscribeLocalEvent <EntRemovedFromContainerMessage>(HandleContainerModified); SubscribeLocalEvent <EntInsertedIntoContainerMessage>(HandleContainerModified); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); input.BindMap.BindFunction(ContentKeyFunctions.SwapHands, InputCmdHandler.FromDelegate(HandleSwapHands)); input.BindMap.BindFunction(ContentKeyFunctions.Drop, new PointerInputCmdHandler(HandleDrop)); input.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInHand, InputCmdHandler.FromDelegate(HandleActivateItem)); input.BindMap.BindFunction(ContentKeyFunctions.ThrowItemInHand, new PointerInputCmdHandler(HandleThrowItem)); }
/// <summary> /// Parse click to the relevant entity system /// </summary> /// <param name="message"></param> /// <param name="player"></param> private void ParseClickMessage(ClickEventMessage message, IEntity player) { switch (message.Click) { case ClickType.Left: EntitySystemManager.GetEntitySystem <InteractionSystem>().UserInteraction(message, player); break; case (ClickType.Left | ClickType.Shift): EntitySystemManager.GetEntitySystem <ExamineSystem>().Examine(message, player); break; case ClickType.Right: //Verb System break; } }
/// <inheritdoc /> public override void FrameUpdate(float frameTime) { var renderTreeSystem = EntitySystemManager.GetEntitySystem <RenderingTreeSystem>(); // So we could calculate the correct size of the entities based on the contents of their sprite... // Or we can just assume that no entity is larger than 10x10 and get a stupid easy check. var pvsBounds = _eyeManager.GetWorldViewport().Enlarged(5); var currentMap = _eyeManager.CurrentMap; if (currentMap == MapId.Nullspace) { return; } foreach (var gridId in _mapManager.FindGridIdsIntersecting(currentMap, pvsBounds, true)) { Box2 gridBounds; if (gridId == GridId.Invalid) { gridBounds = pvsBounds; } else { gridBounds = pvsBounds.Translated(-_mapManager.GetGrid(gridId).WorldPosition); } var mapTree = renderTreeSystem.GetSpriteTreeForMap(currentMap, gridId); mapTree.QueryAabb(ref frameTime, (ref float state, in SpriteComponent value) => { if (value.IsInert) { return(true); } value.FrameUpdate(state); return(true); }, gridBounds, approx: true); } }
public override void FrameUpdate(float frameTime) { var currentEye = _eyeManager.CurrentEye; var inputSystem = EntitySystemManager.GetEntitySystem <InputSystem>(); var direction = 0; if (inputSystem.CmdStates[EngineKeyFunctions.CameraRotateRight] == BoundKeyState.Down) { direction += 1; } if (inputSystem.CmdStates[EngineKeyFunctions.CameraRotateLeft] == BoundKeyState.Down) { direction -= 1; } // apply camera rotation if (direction != 0) { currentEye.Rotation += CameraRotateSpeed * frameTime * direction; currentEye.Rotation = currentEye.Rotation.Reduced(); } else { // snap to cardinal directions var closestDir = currentEye.Rotation.GetCardinalDir().ToVec(); var currentDir = currentEye.Rotation.ToVec(); var dot = Vector2.Dot(closestDir, currentDir); if (FloatMath.CloseTo(dot, 1, CameraSnapTolerance)) { currentEye.Rotation = closestDir.ToAngle(); } } foreach (var entity in RelevantEntities) { var eyeComp = entity.GetComponent <EyeComponent>(); eyeComp.UpdateEyePosition(); } }
public override void Update(float frameTime) { _lastUpdate += frameTime; if (_lastUpdate < UpdateDelay) { return; } var atmosSystem = EntitySystemManager.GetEntitySystem <AtmosphereSystem>(); // creadth: everything exposable by atmos should be updated as well foreach (var atmosExposedComponent in EntityManager.ComponentManager.EntityQuery <AtmosExposedComponent>()) { var tile = atmosExposedComponent.Owner.Transform.Coordinates.GetTileAtmosphere(_entityManager); if (tile == null) { continue; } atmosExposedComponent.Update(tile, _lastUpdate); } _lastUpdate = 0; }
/// <inheritdoc /> public override void Initialize() { EntityQuery = new TypeEntityQuery(typeof(IMoverComponent)); var moveUpCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.North, true), session => HandleDirChange(session, Direction.North, false)); var moveLeftCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.West, true), session => HandleDirChange(session, Direction.West, false)); var moveRightCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.East, true), session => HandleDirChange(session, Direction.East, false)); var moveDownCmdHandler = InputCmdHandler.FromDelegate( session => HandleDirChange(session, Direction.South, true), session => HandleDirChange(session, Direction.South, false)); var walkCmdHandler = InputCmdHandler.FromDelegate( session => HandleRunChange(session, true), session => HandleRunChange(session, false)); var input = EntitySystemManager.GetEntitySystem <InputSystem>(); CommandBinds.Builder .Bind(EngineKeyFunctions.MoveUp, moveUpCmdHandler) .Bind(EngineKeyFunctions.MoveLeft, moveLeftCmdHandler) .Bind(EngineKeyFunctions.MoveRight, moveRightCmdHandler) .Bind(EngineKeyFunctions.MoveDown, moveDownCmdHandler) .Bind(EngineKeyFunctions.Walk, walkCmdHandler) .Register <MoverSystem>(); SubscribeLocalEvent <PlayerAttachSystemMessage>(PlayerAttached); SubscribeLocalEvent <PlayerDetachedSystemMessage>(PlayerDetached); _audioSystem = EntitySystemManager.GetEntitySystem <AudioSystem>(); _configurationManager.RegisterCVar("game.diagonalmovement", true, CVar.ARCHIVE); }