コード例 #1
0
 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);
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 public static void AddAll()
 {
     OrbSerializerCatalog.Add(new LightningOrbSerializer());
 }