public static void Create <TOrb>(this TOrb orb)
     where TOrb : Orb
 {
     if (NetworkServer.active)
     {
         OrbManager.instance.AddOrb(orb);
     }
     else
     {
         var index = OrbIndex <TOrb> .index;
         if (index == OrbSerializerCatalog.Index.Invalid)
         {
             throw new InvalidOperationException("Orb not registered in catalog");
         }
         if (!OrbSerializerCatalog.TryGetDef(index, out var def) || def is NoSerializer)
         {
             throw new InvalidOperationException("No valid serializer registered for orb");
         }
         new OrbMessage(orb, def).Send(NetworkDestination.Server);
     }
 }
 public void Deserialize(NetworkReader reader)
 {
     this.serializer = OrbSerializerCatalog.GetDef(reader.ReadBits <OrbSerializerCatalog.Index>()) !;
     this.orb        = this.serializer.CreateInstance();
     reader.Read(ref this.orb, this.serializer);
 }
Beispiel #3
0
 public static void AddAll()
 {
     OrbSerializerCatalog.Add(new LightningOrbSerializer());
 }