protected override void Handle(TransportLineChangeSliderCommand command) { IgnoreHelper.StartIgnore(); TransportLine[] lines = TransportManager.instance.m_lines.m_buffer; if (command.IsTicketPrice) { lines[command.LineId].m_ticketPrice = (ushort)command.Value; } else { lines[command.LineId].m_budget = (ushort)command.Value; } // Update info panel if open: PublicTransportWorldInfoPanel panel = UIView.library.Get <PublicTransportWorldInfoPanel>(typeof(PublicTransportWorldInfoPanel).Name); ushort lineId = ReflectionHelper.Call <ushort>(panel, "GetLineID"); if (lineId == command.LineId) { UISlider slider = ReflectionHelper.GetAttr <UISlider>(panel, command.IsTicketPrice ? "m_ticketPriceSlider" : "m_vehicleCountModifier"); if (slider != null) { SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => { slider.value = command.Value; }); } } IgnoreHelper.EndIgnore(); }
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(); }
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(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(EconomySetTaxRateCommand command) { IgnoreHelper.StartIgnore(); EconomyManager.instance.SetTaxRate(command.Service, command.SubService, command.Level, command.Rate); EconomyPanel panel = typeof(ToolsModifierControl).GetField("m_EconomyPanel", ReflectionHelper.AllAccessFlags)?.GetValue(null) as EconomyPanel; if (panel != null) { SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => ReflectionHelper.Call(panel, "PopulateTaxesTab")); } IgnoreHelper.EndIgnore(); }
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(); }
public override void Handle(ChangeCityNameCommand command) { NameHandler.IgnoreAll = true; // Update name internally CityInfoPanel.instance.SetCityName(command.Name).MoveNext(); // Update name in panel ReflectionHelper.GetAttr <UITextField>(CityInfoPanel.instance, "m_CityName").text = command.Name; // Update name in bottom bar if (Panel != null) { ReflectionHelper.Call(Panel, "SetName"); } NameHandler.IgnoreAll = false; }
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(); }
protected override void Handle(EconomyTakeLoanCommand command) { IgnoreHelper.StartIgnore(); AddResource.DontAddResource = true; EconomyManager.instance.TakeNewLoan(command.Index, command.Amount, command.Interest, command.Length).MoveNext(); AddResource.DontAddResource = false; EconomyPanel panel = typeof(ToolsModifierControl).GetField("m_EconomyPanel", ReflectionHelper.AllAccessFlags)?.GetValue(null) as EconomyPanel; if (panel != null) { SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => ReflectionHelper.Call(panel, "PopulateLoansTab")); } IgnoreHelper.EndIgnore(); }
protected override void Handle(EconomyPayLoanCommand command) { IgnoreHelper.StartIgnore(); FetchResource.DontFetchResource = true; FetchResource.ReturnFetchedAmount = command.Paid; EconomyManager.instance.PayLoanNow(command.Index).MoveNext(); FetchResource.DontFetchResource = false; EconomyPanel panel = typeof(ToolsModifierControl).GetField("m_EconomyPanel", ReflectionHelper.AllAccessFlags)?.GetValue(null) as EconomyPanel; if (panel != null) { SimulationManager.instance.m_ThreadingWrapper.QueueMainThread(() => ReflectionHelper.Call(panel, "PopulateLoansTab")); } IgnoreHelper.EndIgnore(); }
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 static void Prefix(float value, PublicTransportWorldInfoPanel __instance) { if (IgnoreHelper.IsIgnored()) { return; } ushort lineId = ReflectionHelper.Call <ushort>(__instance, "GetLineID"); if ((ushort)value == TransportManager.instance.m_lines.m_buffer[lineId].m_ticketPrice) { return; } Command.SendToAll(new TransportLineChangeSliderCommand() { LineId = lineId, Value = value, IsTicketPrice = true }); }
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(ChangeCityNameCommand command) { IgnoreHelper.StartIgnore(); // Update name internally CityInfoPanel.instance.SetCityName(command.Name).MoveNext(); // Update name in panel ReflectionHelper.GetAttr <UITextField>(CityInfoPanel.instance, "m_CityName").text = command.Name; // Update name in bottom bar if (Panel != null) { ReflectionHelper.Call(Panel, "SetName"); } else { Log.Warn("Bottom bar city name not found. Can't update name!"); } IgnoreHelper.EndIgnore(); }
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(); }
public static void CreateOrUpdateMultiplayerButton() { Log.Info("Creating multiplayer button..."); // Find pause menu view. UIPanel pauseUiPanel = UIView.GetAView()?.FindUIComponent("Menu") as UIPanel; if (pauseUiPanel == null) { return; } // Find button. UIButton _multiplayerButton = UIView.GetAView().FindUIComponent("Multiplayer") as UIButton; // Find divider. UIPanel _multiplayerDivider = UIView.GetAView().FindUIComponent("multiplayerDivider") as UIPanel; // Add the button & divider if it does not exist and assign // the click event. if (_multiplayerButton == null) { // Add multiplayer button. _multiplayerButton = (UIButton)pauseUiPanel.AddUIComponent(typeof(UIButton)); // Add multiplayer divider. _multiplayerDivider = (UIPanel)pauseUiPanel.AddUIComponent(typeof(UIPanel)); // Respond to button click. _multiplayerButton.eventClick += (component, param) => { // Close pause menu. ReflectionHelper.Call(new PauseMenu(), "Resume"); // Open host game menu if not in multiplayer session, else open connection panel if (MultiplayerManager.Instance.CurrentRole == MultiplayerRole.None) { PanelManager.TogglePanel <HostGamePanel>(); // Display warning if DLCs or other mods are enabled if (DLCHelper.GetOwnedDLCs() != SteamHelper.DLC_BitMask.None || Singleton <PluginManager> .instance.enabledModCount > 1) { MessagePanel msgPanel = PanelManager.ShowPanel <MessagePanel>(); msgPanel.DisplayContentWarning(); } } else { PanelManager.TogglePanel <ConnectionPanel>(); } }; } // Set multiplayer button properties. _multiplayerButton.name = "Multiplayer"; _multiplayerButton.text = "MULTIPLAYER"; _multiplayerButton.width = 310; _multiplayerButton.height = 57; _multiplayerButton.textScale = 1.25f; _multiplayerButton.normalBgSprite = "ButtonMenu"; _multiplayerButton.disabledBgSprite = "ButtonMenuDisabled"; _multiplayerButton.hoveredBgSprite = "ButtonMenuHovered"; _multiplayerButton.focusedBgSprite = "ButtonMenuFocused"; _multiplayerButton.pressedBgSprite = "ButtonMenuPressed"; _multiplayerButton.textColor = new Color32(255, 255, 255, 255); _multiplayerButton.disabledTextColor = new Color32(7, 7, 7, 255); _multiplayerButton.hoveredTextColor = new Color32(7, 132, 255, 255); _multiplayerButton.focusedTextColor = new Color32(255, 255, 255, 255); _multiplayerButton.pressedTextColor = new Color32(30, 30, 44, 255); // Set multiplayer divider properties. _multiplayerDivider.height = 7; _multiplayerDivider.name = "multiplayerDivider"; // Enable button sounds. _multiplayerButton.playAudioEvents = true; }