protected override void OnCreate() { base.OnCreate(); _emitSignalSystem = World.GetOrCreateSystem <SetSignalSystem>(); _executeSys = World.GetOrCreateSystem <ExecutePawnControllerInputSystem>(); _physicsWorldSystem = World.GetOrCreateSystem <PhysicsWorldSystem>(); _executeGameActionSystem = World.GetOrCreateSystem <ExecuteGameActionSystem>(); }
private void ExecutePlayerInput(SimPlayerInput input, Entity playerEntity) { // fbessette: For now, we simply do a switch. // In the future, we'll probably want to implement something dynamic instead ExecutePawnControllerInputSystem pawnControllerInputSystem = World.GetOrCreateSystem <ExecutePawnControllerInputSystem>(); switch (input) { case SimPlayerInputSetPawnName setNameInput: pawnControllerInputSystem.Inputs.Add(new PawnControllerInputSetPawnName(playerEntity, setNameInput.Name)); break; case SimPlayerInputUseItem useItemInput: { pawnControllerInputSystem.Inputs.Add(new PawnControllerInputUseItem(playerEntity, useItemInput.ItemIndex, useItemInput.UseData)); break; } case SimPlayerInputReady readyInput: { EntityManager.SetOrAddComponentData(playerEntity, new ReadyToPlay() { Value = readyInput.IsReady }); break; } case SimPlayerInputSetPawnDoodle setPawnDoodleInput: { Entity pawn = GetPlayerPawn(playerEntity); if (pawn != Entity.Null) { EntityManager.SetOrAddComponentData(pawn, new DoodleId() { Guid = setPawnDoodleInput.DoodleId }); EntityManager.SetOrAddComponentData(pawn, new DoodleStartDirection() { IsLookingRight = setPawnDoodleInput.DoodleDirectionIsLookingRight }); } break; } case SimPlayerInputEquipItem equipItemInput: { pawnControllerInputSystem.Inputs.Add(new PawnControllerInputEquipItem(playerEntity, equipItemInput.ItemIndex, equipItemInput.ChestEntity)); break; } case SimPlayerInputDropItem dropItemInput: { pawnControllerInputSystem.Inputs.Add(new PawnControllerInputDropItem(playerEntity, dropItemInput.ItemIndex)); break; } case SimPlayerInputMove moveInput: { if (HasComponent <Team>(playerEntity)) { Entity pawn = GetPlayerPawn(playerEntity); if (HasComponent <MoveInput>(pawn)) { SetComponent <MoveInput>(pawn, moveInput.NewDirection); } } break; } } }