protected override void OnLoad(object[] args) { // Create the world and hook into it's events World = new ServerWorld(); World.OnPlayerKilled += World_OnPlayerKilled; // Hook into the component events snapshotComponent.OnWorldSnapshotOutbound += SnapshotComponent_OnWorldSnapshotOutbound; netPlayerComponent.OnClientInfoReceived += NetPlayerComponent_OnClientInfoReceived; netPlayerComponent.OnClientLeave += NetPlayerComponent_OnClientLeave; // Create the handshake component so we can send players world data handshakeComponent = new HandshakeComponent(this, World, server); // Add remotes channel.AddRemoteEvent("Server_ChatItem", R_ChatItem); // If the world loaded a default map // hook into it's events and let clients download it if (World.Terrain != null) { World.Terrain.OnModified += Terrain_OnModified; processNewConnections = true; } // Hook into the custom packet handler server.AddPacketHook(OnCustomPacket); // Hook into the user connection events server.OnUserConnected += Server_OnUserConnected; server.OnUserDisconnected += Server_OnUserDisconnected; SwitchGamemode(GamemodeType.CTF); }
public Handshake(HandshakeComponent component, NetConnection with) { this.component = component; With = with; server = component.GetServer(); world = component.GetWorld(); TerrainChanges = new HashSet <BlockChange>(); Start(); }