public UpdatePlayerStateMessage(Player player) { Id = player.Id; Position = player.SimulationState.Position; Velocity = player.SimulationState.Velocity; Rotation = player.SimulationState.Rotation; MessageTime = NetTime.Now; }
public Session(NetConnection connection, GameServer server, string username) { this.connection = connection; this.server = server; this.username = username; handler.OnUpdatePlayerState += HandleUpdatePlayerStateMessage; handler.OnChatTalk += HandleChatTalkMessage; player = server.World.AddPlayer(); SendMessageOrdered(new ChatTalkMessage("Welcome to the servers, press right ctrl to chat !")); SendMessageOrdered(new ChatTalkMessage("Type /help to see a list of available commands.")); }
public Player AddPlayer(long id, Vector3 position, Vector3 velocity, float rotation, bool isLocal) { if (players.ContainsKey(id)) { return players[id]; } var player = new Player( id, new EntityState {Position = position, Rotation = rotation, Velocity = velocity}); players.Add(player.Id, player); if (isLocal) { localPlayer = player; } return player; }
public PlayerStateChangedArgs(Player player) { Player = player; }
public bool PlayerIsLocal(Player player) { return localPlayer != null && localPlayer.Id == player.Id; }
protected void OnPlayerStateChanged(Player player) { EventHandler<PlayerStateChangedArgs> playerStateChanged = PlayerStateChanged; if (playerStateChanged != null) { playerStateChanged(this, new PlayerStateChangedArgs(player)); } }