public int this[NetworkProperty property] { get { #if DEBUG NetAssert.NotNull(property); NetAssert.True(OffsetObjects >= 0); NetAssert.True(OffsetObjects < Root.Meta.CountObjects); NetAssert.Same(Root.Objects[OffsetObjects], this); NetAssert.Same(Root.Objects[OffsetObjects].Meta, property.PropertyMeta); NetAssert.Same(Root.Meta.Properties[Root.Objects[OffsetObjects].OffsetProperties + property.OffsetProperties].Property, property); #endif return(this.OffsetStorage + property.OffsetStorage); } }
void AddPropertyToArray(int offsetProperties, int offsetObjects, NetworkProperty property) { NetAssert.Null(Properties[offsetProperties].Property); if (offsetProperties > 0) { NetAssert.NotNull(Properties[offsetProperties - 1].Property); } Properties[offsetProperties].Property = property; Properties[offsetProperties].OffsetObjects = offsetObjects; for (int i = 0; i < 32; ++i) { int f = 1 << i; // this can't be set if (Filters[i] != null) { NetAssert.False(Filters[i].IsSet(offsetProperties)); } // if property is included in this filter, flag it if ((property.PropertyFilters & f) == f) { if (Filters[i] == null) { Filters[i] = new BitSet(); } Filters[i].Set(offsetProperties); // now it must be set NetAssert.True(Filters[i].IsSet(offsetProperties)); } } }
public UniqueId(byte[] bytes) { NetAssert.NotNull(bytes); NetAssert.True(bytes.Length == 16); this = default(UniqueId); this.byte0 = bytes[0]; this.byte1 = bytes[1]; this.byte2 = bytes[2]; this.byte3 = bytes[3]; this.byte4 = bytes[4]; this.byte5 = bytes[5]; this.byte6 = bytes[6]; this.byte7 = bytes[7]; this.byte8 = bytes[8]; this.byte9 = bytes[9]; this.byte10 = bytes[10]; this.byte11 = bytes[11]; this.byte12 = bytes[12]; this.byte13 = bytes[13]; this.byte14 = bytes[14]; this.byte15 = bytes[15]; }
public UniqueId(string guid) { NetAssert.NotNull(guid); this = default(UniqueId); this.guid = new Guid(guid); }
public void SetExtrapolationClamper(System.Func <AscensionEntity, Vector3, Vector3> clamper) { NetAssert.NotNull(clamper); Clamper = clamper; }
public void Detach() { NetAssert.NotNull(UnityObject); NetAssert.True(IsAttached); NetAssert.True(NetworkId.Packed != 0UL); if (AutoRemoveChildEntities) { foreach (AscensionEntity child in UnityObject.GetComponentsInChildren(typeof(AscensionEntity), true)) { if (child.IsAttached && (ReferenceEquals(child.entity, this) == false)) { child.transform.parent = null; } } } if (Controller) { RevokeControl(null); } // destroy on all connections var it = Core.connections.GetIterator(); while (it.Next()) { it.val.entityChannel.DestroyOnRemote(this); } // call out to behaviours foreach (IEntityBehaviour eb in Behaviours) { try { if (eb.Invoke && ReferenceEquals(eb.entity, this.UnityObject)) { eb.Detached(); eb.entity = null; } } catch (Exception exn) { NetLog.Error("User code threw exception inside Detach callback"); NetLog.Exception(exn); } } // call out to user try { GlobalEventListenerBase.EntityDetachedInvoke(this.UnityObject); } catch (Exception exn) { NetLog.Error("User code threw exception inside Detach callback"); NetLog.Exception(exn); } // clear out attached flag Flags &= ~EntityFlags.ATTACHED; // remove from entities list if (Core.entitiesFrozen.Contains(this)) { Core.entitiesFrozen.Remove(this); } if (Core.entitiesThawed.Contains(this)) { Core.entitiesThawed.Remove(this); } // clear from unity object UnityObject.entity = null; // log NetLog.Debug("Detached {0}", this); }
public void Attach() { NetAssert.NotNull(UnityObject); NetAssert.False(IsAttached); NetAssert.True((NetworkId.Packed == 0UL) || (Source != null)); try { AttachIsRunning = true; // mark as don't destroy on load GameObject.DontDestroyOnLoad(UnityObject.gameObject); // assign network id if (Source == null) { NetworkId = NetworkIdAllocator.Allocate(); } // add to entities list Core.entitiesThawed.AddLast(this); // mark as attached Flags |= EntityFlags.ATTACHED; // call out to behaviours foreach (IEntityBehaviour eb in Behaviours) { try { if (eb.Invoke && ReferenceEquals(eb.entity, this.UnityObject)) { eb.Attached(); } } catch (Exception exn) { NetLog.Error("User code threw exception inside Attached callback"); NetLog.Exception(exn); } } // call out to user try { GlobalEventListenerBase.EntityAttachedInvoke(this.UnityObject); } catch (Exception exn) { NetLog.Error("User code threw exception inside Attached callback"); NetLog.Exception(exn); } // log NetLog.Debug("Attached {0} (Token: {1})", this, AttachToken); } finally { AttachIsRunning = false; } }