public CommandPostEntitySnapshot(INetEntity entity, NetCreatableInfo info, SnapshotSystem snapshotSystem) : base(entity, info, snapshotSystem) { x = AddPrimitiveField <float>(); y = AddPrimitiveField <float>(); z = AddPrimitiveField <float>(); }
public void OnCreatableInstantiated(NetCreatableInfo info, NetConnectionSnapshotState state) { ServerMPPlayer player = info.Creatable as ServerMPPlayer; if (player != null) { NetConnection owner = state.Connection; WriteDebug("[CSS] Created MPPlayer for {0}.", owner); // Create the worldsnapshot for the the player WorldSnapshot ws = state.WorldSnapshot; // Add the current players to the snapshot foreach (ServerMPPlayer plr in players.Values) { if (!ws.IsPlayerAdded(plr.StateInfo.Id)) { ws.AddPlayer(plr.StateInfo.Id, false, true); } } // Add the new player players.Add(info.Id, player); playersFromConnection.Add(player.StateInfo.Owner, player); // Add the new player to each players state (including the new player's state) foreach (NetConnectionSnapshotState otherState in snapshotComponent.ConnectionStates.Values) { otherState.WorldSnapshot.AddPlayer(info.Id, state == otherState, true); } } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo info) { if (info.Owner != null) { charSnapshotSystem.OnCreatableInstantiated(info, ConnectionStates[info.Owner]); } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo info) { if (info.Owner != null) { charSnapshotSystem.OnCreatableInstantiated(info, WorldSnapshot); } }
void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo creatable) { ClientPlayer player = creatable.Creatable as ClientPlayer; if (player != null) { // If a player was destroyed we need to remove // anything associated with them. players.Remove(creatable.Id); player.Dispose(); if (player == OurPlayer) { // Notify the player OurPlayer.OnKilled(); // Remove the player OurPlayer = null; } } else { GameObject gameObject = creatable.Creatable as GameObject; if (gameObject.HasComponent <PhysicsBodyComponent>()) { physEntities.Remove(creatable.Id); } gameObject.Dispose(); } }
public override void OnNetworkInstantiated(NetCreatableInfo stateInfo) { base.OnNetworkInstantiated(stateInfo); SnapshotNetComponent snc = AOSServer.Instance.GetComponent <SnapshotNetComponent>(); ClientSnapshot = new ClientPlayerSnapshot(snc.SnapshotSystem, stateInfo.Owner, true); }
public virtual void OnNetworkInstantiated(NetCreatableInfo stateInfo) { StateInfo = stateInfo; if (DashCMD.GetCVar <bool>("log_mpplayer")) { DashCMD.WriteStandard("[MPPlayer - {1}] Instantiated with id {0}", stateInfo.Id, stateInfo.IsAppOwner ? "Ours" : "Not Ours"); } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo e) { ClientPlayer player = e.Creatable as ClientPlayer; if (player != null) { // Add to our list Players.Add(e.Id, player); // Inform gamemode OnPlayerAdded(e.Id, player); } }
private void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo e) { ServerMPPlayer player = e.Creatable as ServerMPPlayer; if (player != null) { // Update network player NetworkPlayer netPlayer; if (NetPlayerComponent.TryGetPlayer(e.Owner, out netPlayer)) { netPlayer.CharacterId = null; } } }
private void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo e) { ClientPlayer player = e.Creatable as ClientPlayer; if (player != null && player.StateInfo.IsAppOwner) { // Unlock cursor on player destroyed Input.IsCursorLocked = false; Input.IsCursorVisible = true; Camera.Active.HoldM2ToLook = true; Camera.Active.FOV = Camera.Active.DefaultFOV; Camera.Active.ArcBallMouseSensitivity = Camera.Active.DefaultArcBallMouseSensitivity; Camera.Active.FPSMouseSensitivity = Camera.Active.DefaultFPSMouseSensitivity; } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo e) { ClientPlayer player = e.Creatable as ClientPlayer; if (player != null && player.StateInfo.IsAppOwner) { // Setup input based on menu state ToggleFPSUserInput(!menu.Visible, (ClientMPPlayer)player); // Setup camera with object Camera.Active.SetMode(CameraMode.FPS); Camera.Active.LockedToTransform = player.Transform; hud.Player = player; hud.ShowCharacterInformation = true; } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo e) { ServerMPPlayer player = e.Creatable as ServerMPPlayer; if (player != null) { // Update network player NetworkPlayer netPlayer = NetPlayerComponent.GetPlayer(e.Owner); netPlayer.CharacterId = player.StateInfo.Id; // Player is all set Players.Add(player.StateInfo.Owner, player); // Inform the rest of the gamemode OnPlayerAdded(player.StateInfo.Owner, player); } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo creatable) { ServerMPPlayer player = creatable.Creatable as ServerMPPlayer; if (player != null) { players.TryAdd(creatable.Owner, player); AddGameObject(player); } else { GameObject gameObject = creatable.Creatable as GameObject; AddGameObject(gameObject); if (gameObject.HasComponent <PhysicsBodyComponent>()) { physEntities.Add(creatable.Id, gameObject); } } }
public void OnCreatableInstantiated(NetCreatableInfo info, WorldSnapshot ws) { ClientPlayer player = info.Creatable as ClientPlayer; // Add the new player if (player != null) { players.Add(info.Id, player); if (info.IsAppOwner) { // Setup player as our own if (ourPlayer != null) { DashCMD.WriteError("[CSS] Received client player instantiation twice!"); } else { // Setup our gamestate // Copy each existing player to the worldsnapshot foreach (ClientPlayer plr in players.Values) { if (plr == player) { // The new player doesn't have stateinfo setup yet ws.AddPlayer(info.Id, true, false); } else if (!ws.PlayerFieldExists(plr.StateInfo.Id)) { ws.AddPlayer(plr.StateInfo.Id, false, false); } } // Set our player and our new world snapshot ourPlayer = (ClientMPPlayer)player; } } else { ws.AddPlayer(info.Id, false, false); } } }
public void OnCreatableDestroyed(NetCreatableInfo info, WorldSnapshot ws) { ClientPlayer player; if (players.TryGetValue(info.Id, out player)) { players.Remove(info.Id); if (ws != null) { ws.RemovePlayer(player); } if (ourPlayer != null && ourPlayer.StateInfo.Id == info.Id) { ourPlayer = null; } } }
void HandleInstantiationPacket(NetInboundPacket packet) { string eventName = packet.ReadString(); ushort id = packet.ReadUInt16(); bool isOwner = packet.ReadBool(); NetInstantiationCallback callback; if (instCallbacks.TryGetValue(eventName, out callback)) { if (netObjects.Creatables.ContainsKey(id)) { DashCMD.WriteError("[ObjectNC] Creatable with id {0} is already instantiated!", id); return; } //DashCMD.WriteLine("[ObjectNC] Instantiating creatable with id {0}...", id); INetCreatable creatable = callback(id, isOwner, packet); NetCreatableInfo info = new NetCreatableInfo(packet.Sender, creatable, id, isOwner); netObjects.Add(id, info); INetEntity entity = creatable as INetEntity; if (entity != null && snapshotComponent.WorldSnapshot != null) { NetEntityListSnapshot entList = snapshotComponent.WorldSnapshot.NetEntityListSnapshot; entList.AddNetEntity(info, entity); } creatable.OnNetworkInstantiated(info); if (OnCreatableInstantiated != null) { OnCreatableInstantiated(this, info); } } else { DashCMD.WriteError("[ObjectNC] Received instantiation for unknown type: {0}", eventName); } }
private void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo e) { ClientPlayer player = e.Creatable as ClientPlayer; if (player == null) { // We are only concerned with ClientPlayers here return; } // If a player was destroyed we need to remove // anything associated with them. Players.Remove(e.Id); if (player == OurPlayer) { // Notify our player OurPlayer.OnKilled(); OurPlayer = null; } }
void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo creatable) { ServerMPPlayer player = creatable.Creatable as ServerMPPlayer; if (player != null) { // If a player was destroyed we need to remove // anything associated with them. player.Dispose(); players.TryRemove(creatable.Owner, out player); } else { GameObject gameObject = creatable.Creatable as GameObject; if (gameObject.HasComponent <PhysicsBodyComponent>()) { physEntities.Remove(creatable.Id); } gameObject.Dispose(); } }
private void ObjectComponent_OnCreatableInstantiated(object sender, NetCreatableInfo creatable) { ClientPlayer player = creatable.Creatable as ClientPlayer; if (player != null) { players.Add(creatable.Id, player); if (creatable.IsAppOwner) { OurPlayer = (ClientMPPlayer)player; } AddGameObject(player); } else { GameObject gameObject = creatable.Creatable as GameObject; AddGameObject(gameObject); if (gameObject.HasComponent <PhysicsBodyComponent>()) { physEntities.Add(creatable.Id, gameObject); } } }
public NetEntitySnapshot CreateSnapshot(NetCreatableInfo info, SnapshotSystem snapshotSystem) { return(new CommandPostEntitySnapshot(this, info, snapshotSystem)); }
private void ObjectComponent_OnCreatableDestroyed(object sender, NetCreatableInfo info) { charSnapshotSystem.OnCreatableDestroyed(info.Id); }
public void NetworkInstantiate(INetCreatable creatable, string instEventName, NetConnection clientOwner, params object[] args) { ushort netId = lastNetEntId++; if (netId == 0) { netId++; } NetCreatableInfo info = new NetCreatableInfo(clientOwner, creatable, netId, true); INetEntity entity = creatable as INetEntity; if (entity != null) { foreach (NetConnectionSnapshotState state in snapshotComponent.ConnectionStates.Values) { state.WorldSnapshot.NetEntityListSnapshot.AddNetEntity(info, entity); } } creatable.OnNetworkInstantiated(info); if (OnCreatableInstantiated != null) { OnCreatableInstantiated(this, info); } netObjects.Add(netId, info); foreach (NetConnection conn in server.Connections.Values) { NetOutboundPacket packet = new NetOutboundPacket(NetDeliveryMethod.Reliable); packet.Write((byte)CustomPacketType.Instantiate); packet.Write(instEventName); packet.Write(netId); packet.Write(conn == clientOwner); for (int i = 0; i < args.Length; i++) { packet.WriteDynamic(args[i]); } conn.SendPacket(packet); } NetOutboundPacket epacket = new NetOutboundPacket(NetDeliveryMethod.Reliable); epacket.Write((byte)CustomPacketType.Instantiate); epacket.Write(instEventName); epacket.Write(netId); epacket.Write(false); for (int i = 0; i < args.Length; i++) { epacket.WriteDynamic(args[i]); } instPackets.Add(netId, epacket); }
public void OnNetworkInstantiated(NetCreatableInfo info) { CreatableInfo = info; }