public void AddExtension() { ScapeNet.AddPacketType(typeof(DamagePacket)); ScapeNet.AddPacketType(typeof(ServersideSpawnPacket)); Debug.Log("EXTENSION ADDED"); if (isServer) { server.serverNetworker.OnNewConnection(received => { PacketData <OnConnectPacket> data = new PacketData <OnConnectPacket>(received); SpawnPlayer(data); Debug.Log("ID " + data.playerId); return(false); }); server.serverNetworker.OnReceive("Damage", received => { PacketData <DamagePacket> data = new PacketData <DamagePacket>(received); server.FindSpawnedNetObject(data.packet.damaged_items_id).GetComponent <ScapeNet_Destructable>().health += data.packet.damageDone; return(false); }); } }
public void OnReceive(string packet_identifier, Type packet_type, Func <object[], bool> function) { ScapeNet.AddPacketType(packet_type); Packet_Register.Instance.clientPacketReceivedRegister.Add(packet_identifier, function); }