void Notify(SyncBase sync) { if (Sync.IsServer) { foreach (var data in m_clientData) { data.Value.DirtyProperties[sync.Id] = true; } } else { m_dirtyProperties[sync.Id] = true; } }
void m_changeInterval_ValueChanged(SyncBase obj) { RaisePropertiesChanged(); }
void m_backgroundColor_ValueChanged(SyncBase obj) { m_backgroundColorChanged = true; RaisePropertiesChanged(); }
void SyncType_PropertyChanged(SyncBase obj) { if (obj == m_dummyDisplacement && MyPhysicsBody.IsConstraintValid(m_constraint)) { SetConstraintPosition(TopBlock, (HkLimitedHingeConstraintData)m_constraint.ConstraintData); } }
private void HandlePacket(NetworkMessage msg) { switch (msg.msgType) { case (PktType.TextMessage): TextMessagePkt TextMsg = new TextMessagePkt(); TextMsg.Deserialize(msg.reader); Term.Println(TextMsg.Message); break; case (PktType.Identity): IdentityPkt Identity = new IdentityPkt(); Identity.Deserialize(msg.reader); var Conn = new CConnectedPlayer(Identity.ConnectionID); if (Identity.Owned) { Player = Conn; } else { Debug.Log(Conn.ConnectionID + " connected!"); Term.Println(Conn.ConnectionID + " connected!"); } Players.Add(Conn.ConnectionID, Conn); break; case (PktType.MassIdentity): IntListPkt Identities = new IntListPkt(); Identities.Deserialize(msg.reader); foreach (int currId in Identities.IntList) { Players.Add(currId, new CConnectedPlayer(currId)); } break; case (PktType.SpawnEntity): SpawnEntityPkt SpawnPkt = new SpawnEntityPkt(); SpawnPkt.Deserialize(msg.reader); EntityType EntityType = SpawnPkt.EntityType; // Check if you are the owner and if they are spawning an NPC if (SpawnPkt.OwnerID == Player.ConnectionID && EntityType == EntityType.NPC) { // Change it into a PC instead. EntityType = EntityType.PC; } GameObject Obj = Spawner.Spawn(EntityType, SpawnPkt.Position, SpawnPkt.SyncBaseIDList); if (SpawnPkt.OwnerID > -1) { Players[SpawnPkt.OwnerID].Character = Obj.GetComponent <Character>(); } if (SpawnPkt.OwnerID == Player.ConnectionID) { gameObject.AddComponent <ClientSyncer>(); } break; case (PktType.MoveCreature): MoveCreaturePkt MoveCreature = new MoveCreaturePkt(); MoveCreature.Deserialize(msg.reader); SyncBase SyncBase = Spawner.SyncDB.Get(MoveCreature.SyncBaseID); if (SyncBase != null || SyncBase is Character) { Character Character = (Character)SyncBase; Character.Move(MoveCreature.Direction); } else { Debug.LogError("SyncBase " + MoveCreature.SyncBaseID + " is not a Creature"); Term.Println("SyncBase " + MoveCreature.SyncBaseID + " is not a Creature"); } break; case (PktType.Interact): InteractionPkt Interaction = new InteractionPkt(); Interaction.Deserialize(msg.reader); if (Interaction.OwnerSyncBaseID == Player.Character.ID) { break; } SyncBase Target = Spawner.SyncDB.Get(Interaction.InteractSyncBaseID); if (Target != null && Target is Interactable) { ((Interactable)Target).Interact( Spawner.SyncDB.Get(Interaction.OwnerSyncBaseID), Interaction.InteractionType); } else { Term.Println("Server has sent an erroneus SyncBase ID!"); } break; case (PktType.Sync): SyncHandler.HandleSyncPkt(msg); break; case (PktType.StaticObjectIds): IntListPkt StaticIds = new IntListPkt(); StaticIds.Deserialize(msg.reader); Spawner.SyncDB.SetStaticObjectsIDs(StaticIds.IntList); break; case (PktType.Disconnect): DisconnectPkt Disconnect = new DisconnectPkt(); Disconnect.Deserialize(msg.reader); Term.Println(Disconnect.ConnectionID + " disconnected!"); Spawner.Remove(Players[Disconnect.ConnectionID].Character.gameObject); Players.Remove(Disconnect.ConnectionID); break; case (PktType.InventoryAction): InventoryActionPkt InventoryActionPkt = new InventoryActionPkt(); InventoryActionPkt.Deserialize(msg.reader); SyncBase CurrSyncBase = Spawner.SyncDB.Get(InventoryActionPkt.SyncBaseID); Inventory Inventory; if (CurrSyncBase is Inventory) { Inventory = (Inventory)CurrSyncBase; } else { break; } Inventory.ActionHandler.HandleAction(InventoryActionPkt.Action, InventoryActionPkt.IntList); break; default: Debug.LogError("Received an unknown packet, id: " + msg.msgType); Term.Println("Received an unknown packet, id: " + msg.msgType); break; } }
void m_maxNumberOfBlocksPerProjection_ValueChanged(SyncBase obj) { RaisePropertiesChanged(); }
void m_instantBuildingEnabled_ValueChanged(SyncBase obj) { m_shouldUpdateProjection = true; if (m_instantBuildingEnabled) m_projectionsRemaining = m_maxNumberOfProjections; RaisePropertiesChanged(); }
void m_showFlag_ValueChanged(SyncBase obj) { if (m_showFlag != ShowTextOnScreenFlag.NONE) { m_forceUpdateText = true; } else { ReleaseRenderTexture(); m_forceUpdateText = false; m_previousTextureID = null; } }
void m_getOwnershipFromProjector_ValueChanged(SyncBase obj) { RaisePropertiesChanged(); }
void m_maxNumberOfProjections_ValueChanged(SyncBase obj) { m_projectionsRemaining = m_maxNumberOfProjections; RaisePropertiesChanged(); }
void WeldSpeed_ValueChanged(SyncBase obj) { m_weldSpeedSq = m_weldSpeed * m_weldSpeed; const float safeUnweldSpeedDif = 2; m_unweldSpeedSq = Math.Max(m_weldSpeed - safeUnweldSpeedDif, 0); m_unweldSpeedSq *= m_unweldSpeedSq; }
void m_fontColor_ValueChanged(SyncBase obj) { m_fontColorChanged = true; RaisePropertiesChanged(); }
public bool ComparePK(SyncBase other) => Model.ComparePK(other);
//###################################################################### void waitLoop() { addLog("waitLoop starting..."); SystemEvent[] _events = new SystemEvent[3]; addLog("waitLoop setting up event array..."); _events[0] = new SystemEvent("StateLeftScan1", false, false); _events[1] = new SystemEvent("DeltaLeftScan1", false, false); _events[2] = new SystemEvent("EndWaitLoop52", false, false); try { do { //Sleep as long as a snapshot is pending while (_bTakingSnapShot && _continueWait) { Thread.Sleep(50); } if (!_continueWait) { Thread.CurrentThread.Abort(); } addLog2("waitLoop WaitForMultipleObjects..."); SystemEvent signaledEvent = SyncBase.WaitForMultipleObjects( -1, // wait for ever _events ) as SystemEvent; addLog2("waitLoop WaitForMultipleObjects released: "); if (_continueWait) { if (signaledEvent == _events[0]) { addLog2("######### Caught StateLeftScan ########"); if (!_bLastState) { _bLastState = true; onStateScan(); } } if (signaledEvent == _events[1]) { addLog2("######### Caught DeltaLeftScan ########"); onDeltaScan(); } if (signaledEvent == _events[2]) { addLog2("######### Caught EndWaitLoop52 ########"); _continueWait = false; } } addLog2("waitLoop sleep(5)"); System.Threading.Thread.Sleep(5); } while (_continueWait); addLog("waitLoop while ended by _continueWait"); } catch (ThreadAbortException ex) { System.Diagnostics.Debug.WriteLine("waitLoop: ThreadAbortException: " + ex.Message); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("waitLoop: Exception: " + ex.Message); } finally { _events[0].Dispose(); _events[1].Dispose(); _events[2].Dispose(); } addLog("...waitLoop EXIT"); }
void m_fontSize_ValueChanged(SyncBase obj) { m_fontSizeChanged = true; RaisePropertiesChanged(); }
void SyncType_PropertyChanged(SyncBase obj) { if (obj == m_dummyDisplacement && m_constraint != null) Reattach(); }
private void HandlePacket(NetworkMessage msg) { switch (msg.msgType) { case PktType.TextMessage: TextMessagePkt TextMsg = new TextMessagePkt(); TextMsg.Deserialize(msg.reader); Term.Println(TextMsg.Message); break; case PktType.MoveCreature: MoveCreaturePkt MoveCreature = new MoveCreaturePkt(); MoveCreature.Deserialize(msg.reader); // Check if the player is allowed to move this character Character Controlled = Players[msg.conn.connectionId].Character.GetComponent <Character>(); if (Controlled.ID != MoveCreature.SyncBaseID) { break; } Controlled.Move(MoveCreature.Direction); foreach (var Player in Players) { if (Player.Value.Connection.connectionId == msg.conn.connectionId) { continue; } NetworkServer.SendToClient(Player.Value.Connection.connectionId, PktType.MoveCreature, MoveCreature); } break; case PktType.Interact: InteractionPkt Interaction = new InteractionPkt(); Interaction.Deserialize(msg.reader); Character Sender = Players[msg.conn.connectionId].Character; SyncBase Target = Spawner.SyncDB.Get(Interaction.InteractSyncBaseID); Interaction.OwnerSyncBaseID = Sender.ID; if (Target != null && Target is Interactable) { Interactable Interacted = (Interactable)Target; Vector3 Delta = Interacted.gameObject.transform.position - Sender.gameObject.transform.position; float ServerInteractionDistance = Sender.InteractionDistance + Sender.MovementSpeed * 0.5f; if (Delta.magnitude <= ServerInteractionDistance) { Interacted.Interact(Sender, Interaction.InteractionType); NetworkServer.SendToAll(PktType.Interact, Interaction); if (Interacted.GetInteractableSyncdata().RequiresSyncing) { Syncer.DirtSyncBase(Interacted.ID); } } } else { Term.Println("Client has reported an erronous SyncBase ID!"); } break; case PktType.ClientSync: ServerSyncHandler.HandleSyncPkt(msg); break; case PktType.Disconnect: msg.conn.Disconnect(); break; case PktType.FailedChecksums: IntListPkt FailedSyncs = new IntListPkt(); FailedSyncs.Deserialize(msg.reader); foreach (int SyncBaseId in FailedSyncs.IntList) { Syncer.DirtSyncBase(SyncBaseId); } break; case PktType.InventoryAction: InventoryActionPkt InventoryActionPkt = new InventoryActionPkt(); InventoryActionPkt.Deserialize(msg.reader); Character Character = Players[msg.conn.connectionId].Character; Inventory CurrInventory = Character.GetComponent <Inventory>(); InventoryActionPkt.SyncBaseID = CurrInventory.ID; if (CurrInventory.ActionHandler.HandleAction(InventoryActionPkt.Action, InventoryActionPkt.IntList)) { SendToAll(PktType.InventoryAction, InventoryActionPkt); } break; default: Debug.LogError("Received an unknown packet, id: " + msg.msgType); Term.Println("Received an unknown packet, id: " + msg.msgType); break; } }