private FrameSyncManagedBehaviour NewManagedBehavior(IFrameSyncBehaviour FrameSyncBehavior) { FrameSyncManagedBehaviour result = new FrameSyncManagedBehaviour(FrameSyncBehavior); //mapBehaviorToManagedBehavior[FrameSyncBehavior] = result; return(result); }
private void CheckQueuedBehaviours() { foreach (var bhList in behaviorsByPlayer) { for (int i = 0; i < bhList.Value.Count; i++) { FrameSyncManagedBehaviour playerBehaviour = (bhList.Value)[i]; playerBehaviour.OnSyncedStart(); } } for (int j = 0; j < ListManagedBehaviors.Count; j++) { FrameSyncManagedBehaviour fsmb = ListManagedBehaviors[j].Value; fsmb.OnSyncedStart(); } }
/** * @brief Removes objets related to a provided player. * * @param playerId Target player's id. **/ public static void RemovePlayer(int playerId) { if (instance != null /*&& instance.lockstep != null*/) { List <FrameSyncManagedBehaviour> behaviorsList = instance.behaviorsByPlayer[playerId]; for (int index = 0, length = behaviorsList.Count; index < length; index++) { FrameSyncManagedBehaviour tsmb = behaviorsList[index]; tsmb.disabled = true; FPCollider[] tsColliders = ((FrameSyncBehaviour)tsmb.FrameSyncBehavior).gameObject.GetComponentsInChildren <FPCollider>(); if (tsColliders != null) { for (int index2 = 0, length2 = tsColliders.Length; index2 < length2; index2++) { FPCollider tsCollider = tsColliders[index2]; if (!tsCollider.Body.TSDisabled) { DestroyFPRigidBody(tsCollider.gameObject, tsCollider.Body); } } } FPCollider2D[] tsCollider2Ds = ((FrameSyncBehaviour)tsmb.FrameSyncBehavior).gameObject.GetComponentsInChildren <FPCollider2D>(); if (tsCollider2Ds != null) { for (int index2 = 0, length2 = tsCollider2Ds.Length; index2 < length2; index2++) { FPCollider2D tsCollider2D = tsCollider2Ds[index2]; if (!tsCollider2D.Body.TSDisabled) { DestroyFPRigidBody(tsCollider2D.gameObject, tsCollider2D.Body); } } } } instance.behaviorsByPlayer.Remove(playerId); } }
private void RemoveFromTSMBList(List <FrameSyncManagedBehaviour> fsmbList, List <FrameSyncBehaviour> behaviours) { List <FrameSyncManagedBehaviour> toRemove = new List <FrameSyncManagedBehaviour>(); for (int j = 0; j < fsmbList.Count; j++) { FrameSyncManagedBehaviour fsmb = fsmbList[j]; if ((fsmb.FrameSyncBehavior is FrameSyncBehaviour) && behaviours.Contains((FrameSyncBehaviour)fsmb.FrameSyncBehavior)) { toRemove.Add(fsmb); } } for (int i = 0; i < toRemove.Count; i++) { FrameSyncManagedBehaviour tsmb = toRemove[i]; fsmbList.Remove(tsmb); } }
void GetLocalData(InputDataBase playerInputData) { FrameSyncInput.CurrentInputData = (InputData)playerInputData; if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID)) { List <FrameSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID]; for (int index = 0, length = managedBehavioursByPlayer.Count; index < length; index++) { FrameSyncManagedBehaviour bh = managedBehavioursByPlayer[index]; if (bh != null && !bh.disabled) { bh.OnSyncedInput(); } } } FrameSyncInput.CurrentInputData = null; }
void OnStepUpdate(List <InputDataBase> allInputData) { FrameSyncInput.SetAllInputs(allInputData); FrameSyncInput.CurrentSimulationData = null; for (int index = 0; index < mapManagedBehaviors.Count; index++) { FrameSyncManagedBehaviour bh = mapManagedBehaviors[index].Value; if (bh != null && !bh.disabled) { bh.OnSyncedUpdate(); } } for (int index = 0, length = allInputData.Count; index < length; index++) { InputDataBase playerInputData = allInputData[index]; if (behaviorsByPlayer.ContainsKey(playerInputData.ownerID)) { FrameSyncInput.CurrentSimulationData = (InputData)playerInputData; List <FrameSyncManagedBehaviour> managedBehavioursByPlayer = behaviorsByPlayer[playerInputData.ownerID]; for (int index2 = 0, length2 = managedBehavioursByPlayer.Count; index2 < length2; index2++) { FrameSyncManagedBehaviour bh = managedBehavioursByPlayer[index2]; if (bh != null && !bh.disabled) { bh.OnSyncedUpdate(); } } } FrameSyncInput.CurrentSimulationData = null; } }
private FrameSyncManagedBehaviour NewManagedBehavior(IFrameSyncBehaviour FrameSyncBehavior) { FrameSyncManagedBehaviour result = new FrameSyncManagedBehaviour(FrameSyncBehavior); return(result); }