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 void Simulate() { Serializer.OnSimulateBefore(); Iterator <Command> it; if (IsOwner) { foreach (IEntityBehaviour eb in Behaviours) { try { if (eb != null && ((MonoBehaviour)(object)eb) && eb.Invoke && ReferenceEquals(eb.entity, this.UnityObject)) { eb.SimulateOwner(); } } catch (Exception exn) { Debug.LogException(exn); } } } else { //FIXED: Entities getting frozen on clients after 10 seconds. //if (AscensionNetwork.IsClient) //{ // var diff = AscensionNetwork.ServerFrame - (Serializer as NetworkState).Frames.Last.Frame; // if (diff > 600) // { // Freeze(true); // } //} } if (HasControl) { NetAssert.Null(Controller); // execute all old commands (in order) it = CommandQueue.GetIterator(); while (it.Next()) { NetAssert.True(it.val.Flags & CommandFlags.HAS_EXECUTED); var resetState = ReferenceEquals(it.val, CommandQueue.First); if (resetState) { it.val.SmoothCorrection(); } // exec old command ExecuteCommand(it.val, resetState); } try { canQueueCommands = true; foreach (IEntityBehaviour eb in Behaviours) { if (eb.Invoke && ReferenceEquals(eb.entity, this.UnityObject)) { eb.SimulateController(); } } } finally { canQueueCommands = false; } // execute all new commands (in order) it = CommandQueue.GetIterator(); while (it.Next()) { if (it.val.Flags & CommandFlags.HAS_EXECUTED) { continue; } ExecuteCommand(it.val, false); } // if this is a local entity we are controlling // we should dispose all commands (there is no need to store them) if (IsOwner) { while (CommandQueue.Count > 0) { CommandQueue.RemoveFirst(); } //RemoveOldCommandCallbacks(CommandSequence); } else { //if (CommandQueue.count > 0) { // RemoveOldCommandCallbacks(CommandQueue.First.Sequence); //} } } else { if (Controller != null) { //if (CommandQueue.count > 0) { // RemoveOldCommandCallbacks(CommandQueue.First.Sequence); //} if (ExecuteCommandsFromRemote() == 0) { Command cmd = CommandQueue.LastOrDefault; for (int i = 0; i < Behaviours.Length; ++i) { if (ReferenceEquals(Behaviours[i].entity, this.UnityObject)) { Behaviours[i].MissingCommand(cmd); } } } } } Serializer.OnSimulateAfter(); }