protected override void Handle(TransportLineSyncCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); IgnoreHelper.StartIgnore(); if (command.UpdateLines) { TransportManager.instance.UpdateLinesNow(); } if (command.UpdatePaths) { ushort tempLine = ReflectionHelper.GetAttr <ushort>(tool, "m_tempLine"); TransportManager.instance.m_lines.m_buffer[(int)tempLine].UpdatePaths(tempLine); } IgnoreHelper.EndIgnore(); ReflectionHelper.SetAttr(tool, "m_hitPosition", command.HitPosition); ReflectionHelper.SetAttr(tool, "m_fixedPlatform", command.FixedPlatform); ReflectionHelper.SetAttr(tool, "m_hoverStopIndex", command.HoverStopIndex); ReflectionHelper.SetAttr(tool, "m_hoverSegmentIndex", command.HoverSegmentIndex); ReflectionHelper.SetAttr(tool, "m_mode", command.Mode); ReflectionHelper.SetAttr(tool, "m_errors", command.Errors); }
protected override void Handle(TransportLineCreateCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); ArrayHandler.StartApplying(command.Array16Ids, null); tool.m_prefab = PrefabCollection <TransportInfo> .GetPrefab(command.Prefab); ReflectionHelper.SetAttr(tool, "m_building", command.Building); IgnoreHelper.StartIgnore(); int mode = ReflectionHelper.GetEnumValue(typeof(TransportTool).GetNestedType("Mode", ReflectionHelper.AllAccessFlags), "NewLine"); ReflectionHelper.SetAttr(tool, "m_mode", mode); ReflectionHelper.SetAttr(tool, "m_errors", ToolBase.ToolErrors.None); IEnumerator newLine = (IEnumerator)ReflectionHelper.Call(tool, "NewLine"); newLine.MoveNext(); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }
protected override void Handle(BuildingToolCreateCommand command) { BuildingTool tool = ToolSimulator.GetTool <BuildingTool>(command.SenderId); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, command.Array32Ids); BuildingInfo prefab = null; if (command.Relocate == 0) { prefab = PrefabCollection <BuildingInfo> .GetPrefab(command.Prefab); } tool.m_prefab = prefab; tool.m_relocate = command.Relocate; ReflectionHelper.SetAttr(tool, "m_mousePosition", command.MousePosition); ReflectionHelper.SetAttr(tool, "m_mouseAngle", command.MouseAngle); ReflectionHelper.SetAttr(tool, "m_elevation", command.Elevation); ReflectionHelper.SetAttr(tool, "m_placementErrors", ToolBase.ToolErrors.None); ReflectionHelper.SetAttr(tool, "m_constructionCost", 0); ToolController controller = ReflectionHelper.GetAttr <ToolController>(tool, "m_toolController"); ReflectionHelper.SetAttr(controller, "m_collidingSegments1", command.CollidingSegments); ReflectionHelper.SetAttr(controller, "m_collidingBuildings1", command.CollidingBuildings); ReflectionHelper.SetAttr(controller, "m_collidingDepth", 1); ReflectionHelper.Call <IEnumerator>(tool, "CreateBuilding")?.MoveNext(); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
public void HandlePlayerDisconnect(Player player) { MultiplayerManager.Instance.PlayerList.Remove(player.Username); this.ConnectedPlayers.Remove(player.NetPeer.Id); Command.HandleClientDisconnect(player); TransactionHandler.ClearTransactions(player.NetPeer.Id); ToolSimulator.RemoveSender(player.NetPeer.Id); }
protected override void Handle(TransportLineInitCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); ReflectionHelper.SetAttr(tool, "m_errors", ToolBase.ToolErrors.Pending); ReflectionHelper.SetAttr(tool, "m_lastMoveIndex", -2); ReflectionHelper.SetAttr(tool, "m_lastAddIndex", -2); }
protected override void Handle(ClientDisconnectCommand command) { Log.Info($"Player {command.Username} has disconnected!"); ChatLogPanel.PrintGameMessage($"Player {command.Username} has disconnected!"); MultiplayerManager.Instance.PlayerList.Remove(command.Username); TransactionHandler.ClearTransactions(command.ClientId); ToolSimulator.RemoveSender(command.ClientId); }
/// <summary> /// Attempt to disconnect from the server /// </summary> public void Disconnect() { // Update status and stop client Status = ClientStatus.Disconnected; _netClient.Stop(); MultiplayerManager.Instance.PlayerList.Clear(); TransactionHandler.ClearTransactions(); ToolSimulator.Clear(); _logger.Info("Disconnected from server"); }
/// <summary> /// Stops the server /// </summary> public void StopServer() { // Update status and stop the server Status = ServerStatus.Stopped; _netServer.Stop(); MultiplayerManager.Instance.PlayerList.Clear(); TransactionHandler.ClearTransactions(); ToolSimulator.Clear(); _logger.Info("Server stopped."); }
protected override void Handle(TransportLineResetCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); ArrayHandler.StartApplying(command.Array16Ids, null); IgnoreHelper.StartIgnore(); ReflectionHelper.Call(tool, "ResetTool"); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }
protected override void Handle(TransportLineTempCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); ArrayHandler.StartApplying(command.Array16Ids, null); TransportInfo info = PrefabCollection <TransportInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ReflectionHelper.Call(tool, "EnsureTempLine", info, command.SourceLine, command.MoveIndex, command.AddIndex, command.AddPos, command.FixedPlatform); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }
protected override void Handle(TransportLineStartEditBuildingCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); TransportInfo info = PrefabCollection <TransportInfo> .GetPrefab(command.Prefab); ArrayHandler.StartApplying(command.Array16Ids, null); IgnoreHelper.StartIgnore(); IEnumerator cancelPrevStop = (IEnumerator)ReflectionHelper.Call(tool, "StartEditingBuildingLine", info, command.Building); cancelPrevStop.MoveNext(); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }
/// <summary> /// Attempt to disconnect from the server /// </summary> public void Disconnect() { bool needsUnload = (Status == ClientStatus.Connected); // Update status and stop client Status = ClientStatus.Disconnected; _netClient.Stop(); MultiplayerManager.Instance.PlayerList.Clear(); TransactionHandler.ClearTransactions(); ToolSimulator.Clear(); if (needsUnload) { // Go back to the main menu after disconnecting Singleton <LoadingManager> .instance.UnloadLevel(); } _logger.Info("Disconnected from server"); }
protected override void Handle(TransportLineMoveStopCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); ArrayHandler.StartApplying(command.Array16Ids, null); IgnoreHelper.StartIgnore(); int mode = ReflectionHelper.GetEnumValue(typeof(TransportTool).GetNestedType("Mode", ReflectionHelper.AllAccessFlags), "MoveStops"); ReflectionHelper.SetAttr(tool, "m_mode", mode); ReflectionHelper.SetAttr(tool, "m_errors", ToolBase.ToolErrors.None); IEnumerator moveStop = (IEnumerator)ReflectionHelper.Call(tool, "MoveStop", command.ApplyChanges); moveStop.MoveNext(); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }
public override void Handle(TerrainModificationCommand command) { TerrainTool tool = ToolSimulator.GetTool <TerrainTool>(command.SenderId); // Apply data from command command.BrushData.CopyTo(ReflectionHelper.GetAttr <ToolController>(tool, "m_toolController").BrushData, 0); tool.m_brushSize = command.BrushSize; tool.m_strength = command.Strength; ReflectionHelper.SetAttr(tool, "m_mousePosition", command.MousePosition); ReflectionHelper.SetAttr(tool, "m_startPosition", command.StartPosition); ReflectionHelper.SetAttr(tool, "m_endPosition", command.EndPosition); ReflectionHelper.SetAttr(tool, "m_currentCost", 0); tool.m_mode = command.Mode; ReflectionHelper.SetAttr(tool, "m_mouseRightDown", command.MouseRightDown); TerrainHandler.IgnoreAll = true; // Call original method ReflectionHelper.Call(tool, "ApplyBrush"); TerrainHandler.IgnoreAll = false; }
protected override void Handle(TransportLineCancelMoveStopCommand command) { TransportTool tool = ToolSimulator.GetTool <TransportTool>(command.SenderId); tool.m_prefab = PrefabCollection <TransportInfo> .GetPrefab(command.Prefab); ArrayHandler.StartApplying(command.Array16Ids, null); IgnoreHelper.StartIgnore(); int mode = ReflectionHelper.GetEnumValue(typeof(TransportTool).GetNestedType("Mode", ReflectionHelper.AllAccessFlags), "MoveStops"); ReflectionHelper.SetAttr(tool, "m_mode", mode); IEnumerator cancelMoveStop = (IEnumerator)ReflectionHelper.Call(tool, "CancelMoveStop"); cancelMoveStop.MoveNext(); IgnoreHelper.EndIgnore(); ArrayHandler.StopApplying(); }