Exemplo n.º 1
0
    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);
            });
        }
    }
Exemplo n.º 2
0
 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);
 }