public static void ReplBlockChangeOwnership(this IReplicatedBehaviour repl_behaviour, bool block) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); if (replicationComponent == null) { return; } replicationComponent.ReplBlockChangeOwnership(block); }
public static void ReplGiveOwnership(this IReplicatedBehaviour repl_behaviour, P2PPeer peer) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); if (replicationComponent == null) { return; } replicationComponent.ReplGiveOwnership(peer); }
public static ReplicationComponent GetReplicationComponent(this IReplicatedBehaviour repl_behaviour) { ReplicatedBehaviour replicatedBehaviour = repl_behaviour as ReplicatedBehaviour; if (replicatedBehaviour == null) { return(Replicator.Singleton.GetReplComponentForGameObject(((MonoBehaviour)repl_behaviour).gameObject, true)); } return(replicatedBehaviour.GetReplicationComponent()); }
public static float ReplGetReplicationInterval(this IReplicatedBehaviour repl_behaviour) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); if (replicationComponent == null) { return(0f); } return(replicationComponent.ReplGetReplicationInterval(ReplTools.GetLocalPeer())); }
public static void ReplClearDirty(this IReplicatedBehaviour repl_behaviour) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); if (replicationComponent == null) { return; } replicationComponent.ReplSetDirty(repl_behaviour, false); }
public static P2PPeer ReplGetOwner(this IReplicatedBehaviour repl_behaviour) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); if (replicationComponent == null) { return(null); } return(replicationComponent.ReplGetOwner()); }
public static TDelegate GetReflectedMethod <TDelegate>(this IReplicatedBehaviour obj, ReplicationComponentReflection.ReflectedMethodType method_type) where TDelegate : class { MethodInfo methodInfo = ReplicationComponentReflection.GetMethodInfo(obj.GetType(), method_type); if (methodInfo != null) { return(Delegate.CreateDelegate(typeof(TDelegate), obj, methodInfo) as TDelegate); } return(default(TDelegate)); }
public static int GetUniqueIdForType(this IReplicatedBehaviour repl_behaviour) { int hashCode; if (!IReplicatedBehaviourExtension.s_ReplBehaviourUniqueIds.TryGetValue(repl_behaviour.GetType(), out hashCode)) { hashCode = repl_behaviour.GetType().FullName.GetHashCode(); IReplicatedBehaviourExtension.s_ReplBehaviourUniqueIds[repl_behaviour.GetType()] = hashCode; } return(hashCode); }
public int GetComponentIndex(IReplicatedBehaviour repl_behaviour) { for (int i = 0; i < this.GetReplBehaviours.Length; i++) { if (this.GetReplBehaviours[i] == repl_behaviour) { return(i); } } DebugUtils.Assert(false, true); return(-1); }
public bool ReplIsDirty(IReplicatedBehaviour repl_behaviour) { if (this.GetReplBehaviours == null) { return(false); } for (int i = 0; i < this.GetReplBehaviours.Length; i++) { if (this.GetReplBehaviours[i] == repl_behaviour) { return(this.m_DirtyBit[i]); } } return(false); }
public void ReplSetDirty(IReplicatedBehaviour repl_behaviour, bool dirty) { if (this.m_ReplBehavioursInternal == null || this.m_ReplBehavioursInternal.Length == 0) { return; } for (int i = 0; i < this.GetReplBehaviours.Length; i++) { if (this.GetReplBehaviours[i] == repl_behaviour) { this.m_DirtyBit[i] = dirty; return; } } }
private void CallReplicationDeserialize_Gen(IReplicatedBehaviour repl_behaviour, P2PNetworkReader reader, bool initial_state) { if (this.m_ReplicationDeserializeDel == null) { foreach (IReplicatedBehaviour replicatedBehaviour in this.GetReplBehaviours) { Action <P2PNetworkReader, bool> reflectedMethod = replicatedBehaviour.GetReflectedMethod(ReplicationComponentReflection.ReflectedMethodType.OnReplicationDeserialize_CJGenerated); if (reflectedMethod != null) { if (this.m_ReplicationDeserializeDel == null) { this.m_ReplicationDeserializeDel = new Dictionary <IReplicatedBehaviour, Action <P2PNetworkReader, bool> >(); } this.m_ReplicationDeserializeDel[replicatedBehaviour] = reflectedMethod; } } } Action <P2PNetworkReader, bool> action; if (this.m_ReplicationDeserializeDel != null && this.m_ReplicationDeserializeDel.TryGetValue(repl_behaviour, out action)) { action(reader, initial_state); } }
private void CallReplicationResolve_Gen(IReplicatedBehaviour repl_behaviour) { if (this.m_ReplicationResolveDel == null) { foreach (IReplicatedBehaviour replicatedBehaviour in this.GetReplBehaviours) { Action reflectedMethod = replicatedBehaviour.GetReflectedMethod(ReplicationComponentReflection.ReflectedMethodType.OnReplicationResolve_CJGenerated); if (reflectedMethod != null) { if (this.m_ReplicationResolveDel == null) { this.m_ReplicationResolveDel = new Dictionary <IReplicatedBehaviour, Action>(); } this.m_ReplicationResolveDel[replicatedBehaviour] = reflectedMethod; } } } Action action; if (this.m_ReplicationResolveDel != null && this.m_ReplicationResolveDel.TryGetValue(repl_behaviour, out action)) { action(); } }
public static bool ReplCanChangeOwnership(this IReplicatedBehaviour repl_behaviour) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); return(replicationComponent != null && replicationComponent.ReplCanChangeOwnership()); }
public void ReplicationReceive(P2PNetworkReader reader, bool initial_state) { if (P2PLogFilter.logPedantic) { Debug.Log(string.Format("ReplicationReceive called for {0} with guid {1}", base.name, this.GetGuidComponent.GetGuid()), this); } int num = reader.ReadInt32(); if (num <= this.m_Revision && !initial_state) { return; } ReplicationComponent.s_DeserializedComponent = this; this.m_Revision = num; this.m_LastReplicationTime = Time.time; this.m_LastReplicationTimeReal = Time.realtimeSinceStartup; short num2 = reader.ReadInt16(); if (this.m_OwnerPeer.GetHostId() != num2) { this.ReplOnChangedOwner(ReplTools.GetPeerById(num2)); if (this.m_OwnerPeer == ReplTools.GetLocalPeer()) { this.ReplRequestOwnership(); } } this.ReplBlockChangeOwnership(!reader.ReadBoolean()); for (int i = 0; i < this.GetReplBehaviours.Length; i++) { IReplicatedBehaviour replicatedBehaviour = this.GetReplBehaviours[i]; if (replicatedBehaviour as UnityEngine.Object == null) { if (reader.ReadBoolean()) { ReplicationComponent.s_DeserializedComponent = null; return; } this.m_ReplBehavioursFlag[i] = false; } else if (reader.ReadBoolean()) { int uniqueIdForType = replicatedBehaviour.GetUniqueIdForType(); int num3 = reader.ReadInt32(); if (uniqueIdForType != num3) { ReplicationComponent.s_DeserializedComponent = null; return; } replicatedBehaviour.OnReplicationDeserialize(reader, initial_state); this.CallReplicationDeserialize_Gen(replicatedBehaviour, reader, initial_state); this.m_ReplBehavioursFlag[i] = true; } else { this.m_ReplBehavioursFlag[i] = false; } } for (int j = 0; j < this.GetReplBehaviours.Length; j++) { if (this.m_ReplBehavioursFlag[j]) { IReplicatedBehaviour replicatedBehaviour2 = this.GetReplBehaviours[j]; replicatedBehaviour2.OnReplicationResolve(); this.CallReplicationResolve_Gen(replicatedBehaviour2); } } if (P2PConnection.s_Size > reader.Position && !initial_state) { Debug.LogError(string.Format("Didn't read whole buffer! (number of bytes unread: {0})", P2PConnection.s_Size - reader.Position), this); } ReplicationComponent.s_DeserializedComponent = null; }
public static bool ReplIsDirty(this IReplicatedBehaviour repl_behaviour) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); return(replicationComponent != null && replicationComponent.ReplIsDirty(repl_behaviour)); }
public static bool ReplIsTransferringOwnership(this IReplicatedBehaviour repl_behaviour) { ReplicationComponent replicationComponent = repl_behaviour.GetReplicationComponent(); return(replicationComponent != null && replicationComponent.IsTransferringOwnership()); }