public void Tick() { switch (GetGameState()) { case State.Pregame: if (_main.gameInputActive && Input.IsActionJustPressed("attack_1") && _playerStarts.Any()) { PlayerStartNode node = _playerStarts[0]; EntPlayer plyr = _main.factory.SpawnPlayer(); _plyrId = plyr.actorId; plyr.GlobalTransform = node.GlobalTransform; SetGameState(State.Gamplay); } break; case State.GameOver: uint diff = OS.GetTicksMsec() - _stateTimestamp; if (diff < 1000) { break; } if (_main.gameInputActive && Input.IsActionJustPressed("attack_1")) { string cmd = $"map {_mapName}"; Console.WriteLine($"Restart map: {cmd}"); _main.console.Execute(cmd); } break; } if (_debugActorId != NullActorId) { IActor actor = GetActor(_debugActorId); if (actor == null) { _debugActorId = NullActorId; } else { _main.SetDebugText(actor.GetActorDebugText()); } } else { _main.SetDebugText(string.Empty); } }
public void RegisterPlayerStart(PlayerStartNode node) { Vector3 p = node.GlobalTransform.origin; Console.WriteLine($"Register player start at {p}"); _playerStarts.Add(node); if (_playerStarts.Count == 1) { SetGameState(State.Pregame); if (_main.cam.GetParentType() != GameCamera.ParentType.Player) { _main.cam.AttachToTarget(node, new Vector3(0, 1, 0), GameCamera.ParentType.Misc); } } }