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(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); }
public static void Postfix(object __instance, ref bool __state) { if (IgnoreHelper.IsIgnored("NewLine")) { return; } if (!__state) { return; } IgnoreHelper.EndIgnore("NewLine"); ArrayHandler.StopCollecting(); TransportTool tool = ReflectionHelper.GetAttr <TransportTool>(__instance, "$this"); ushort prefab = (ushort)Mathf.Clamp(tool.m_prefab.m_prefabDataIndex, 0, 65535); int building = tool.m_building; Command.SendToAll(new TransportLineCreateCommand() { Array16Ids = ArrayHandler.Collected16, Prefab = prefab, Building = building }); }
public static void Postfix(bool __result, ref ushort building, ref bool __state) { if (!__state) { return; } IgnoreHelper.EndIgnore(); ArrayHandler.StopCollecting(); if (__result) { Building b = BuildingManager.instance.m_buildings.m_buffer[building]; Command.SendToAll(new BuildingCreateCommand { Array16Ids = ArrayHandler.Collected16, Array32Ids = ArrayHandler.Collected32, Position = b.m_position, InfoIndex = b.m_infoIndex, Angle = b.m_angle, Length = b.Length }); } }
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(BuildingRebuildCommand command) { IgnoreHelper.StartIgnore(); // Using a delegate object because the 'OnRebuildClicked' delegate contains most of the needed code // This code from the CityServiceWorldInfoPanel is the same as in the EventBuildingWorldInfoPanel, // UniqueFactoryWorldInfoPanel and WarehouseWorldInfoPanel if (delegateType == null) { delegateType = typeof(CityServiceWorldInfoPanel).GetNestedType("<OnRebuildClicked>c__AnonStorey2", ReflectionHelper.AllAccessFlags); rebuildClickedDelegate = Activator.CreateInstance(delegateType); } ReflectionHelper.SetAttr(rebuildClickedDelegate, "buildingID", command.Building); ArrayHandler.StartApplying(command.Array16Ids, null); FetchResource.DontFetchResource = true; delegateType.GetMethod("<>m__0", ReflectionHelper.AllAccessFlags)?.Invoke(rebuildClickedDelegate, null); FetchResource.DontFetchResource = false; ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
protected override void Handle(WeatherCommand command) { if (MultiplayerManager.Instance.CurrentRole == MultiplayerRole.Server) { return; } IgnoreHelper.StartIgnore(); WeatherManager.instance.m_currentCloud = command.CurrentCloud; WeatherManager.instance.m_targetCloud = command.TargetCloud; WeatherManager.instance.m_currentFog = command.CurrentFog; WeatherManager.instance.m_targetFog = command.TargetFog; WeatherManager.instance.m_currentNorthernLights = command.CurrentNothernLights; WeatherManager.instance.m_targetNorthernLights = command.TargetNothernLights; WeatherManager.instance.m_currentRain = command.CurrentRain; WeatherManager.instance.m_targetRain = command.TargetRain; WeatherManager.instance.m_currentRainbow = command.CurrentRainbow; WeatherManager.instance.m_targetRainbow = command.TargetRainbow; WeatherManager.instance.m_currentTemperature = command.CurrentTemperature; WeatherManager.instance.m_targetTemperature = command.TargetTemperature; IgnoreHelper.EndIgnore(); }
public static void Postfix(NetInfo info, int maxSegments, bool testEnds, bool autoFix, bool invert, bool switchDir, ushort relocateBuildingID, ref CallState __state) { if (!__state.valid) { return; } ArrayHandler.StopCollecting(); IgnoreHelper.EndIgnore(); ushort prefab = (ushort)Mathf.Clamp(info.m_prefabDataIndex, 0, 65535); Command.SendToAll(new NodeCreateCommand() { Array16Ids = ArrayHandler.Collected16, Array32Ids = ArrayHandler.Collected32, Prefab = prefab, StartPoint = __state.start, MiddlePoint = __state.middle, EndPoint = __state.end, MaxSegments = maxSegments, TestEnds = testEnds, AutoFix = autoFix, Invert = invert, SwitchDir = switchDir, RelocateBuildingId = relocateBuildingID }); }
protected override void Handle(BuildingUpdateFlagsCommand command) { IgnoreHelper.StartIgnore(); BuildingManager.instance.UpdateFlags(command.Building, command.ChangeMask); IgnoreHelper.EndIgnore(); }
public static void Postfix(ref bool __state) { if (!__state || IgnoreHelper.IsIgnored("SetTaxRate")) { return; } IgnoreHelper.EndIgnore("SetTaxRate"); }
protected override void Handle(BuildingUpgradeCommand command) { IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, command.Array32Ids); BuildingManager.instance.UpgradeBuilding(command.Building); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
protected override void Handle(ZoneUpdateCommand command) { ZoneManager.instance.m_blocks.m_buffer[command.ZoneId].m_zone1 = command.Zone1; ZoneManager.instance.m_blocks.m_buffer[command.ZoneId].m_zone2 = command.Zone2; IgnoreHelper.StartIgnore(); // This Command is necessary to get the Zone to render, else it will first show when a building is build on it. ZoneManager.instance.m_blocks.m_buffer[command.ZoneId].RefreshZoning(command.ZoneId); IgnoreHelper.EndIgnore(); }
protected override void Handle(TransportLineMoveStopManCommand command) { IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, null); TransportManager.instance.m_lines.m_buffer[command.Line].MoveStop(command.Line, command.Index, command.NewPos, command.FixedPlatform); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
protected override void Handle(TransportLineReleaseCommand command) { IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, null); TransportManager.instance.ReleaseLine(command.Line); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
protected override void Handle(UnlockAreaCommand command) { IgnoreHelper.StartIgnore(); int area = (command.Z * 5) + command.X; // Calculate the area index GameAreaManager.instance.UnlockArea(area); IgnoreHelper.EndIgnore(); }
protected override void Handle(DistrictAreaModifyCommand command) { IgnoreHelper.StartIgnore(); DistrictTool.ApplyBrush(command.Layer, command.District, command.BrushRadius, command.StartPosition, command.EndPosition); DistrictManager.instance.NamesModified(); DistrictManager.instance.ParkNamesModified(); IgnoreHelper.EndIgnore(); }
protected override void Handle(ChangeNameCommand command) { IgnoreHelper.StartIgnore(); switch (command.Type) { case InstanceType.Building: BuildingManager.instance.SetBuildingName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.Citizen: CitizenManager.instance.SetCitizenName((uint)command.Id, command.Name).MoveNext(); break; case InstanceType.CitizenInstance: CitizenManager.instance.SetInstanceName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.Disaster: DisasterManager.instance.SetDisasterName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.District: DistrictManager.instance.SetDistrictName(command.Id, command.Name).MoveNext(); break; case InstanceType.Park: DistrictManager.instance.SetParkName(command.Id, command.Name).MoveNext(); break; case InstanceType.Event: EventManager.instance.SetEventName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.NetSegment: NetManager.instance.SetSegmentName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.TransportLine: TransportManager.instance.SetLineName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.Vehicle: VehicleManager.instance.SetVehicleName((ushort)command.Id, command.Name).MoveNext(); break; case InstanceType.ParkedVehicle: VehicleManager.instance.SetParkedVehicleName((ushort)command.Id, command.Name).MoveNext(); break; default: LogManager.GetCurrentClassLogger().Warn("Unknown instance type in ChangeNameHandler received!"); break; } IgnoreHelper.EndIgnore(); }
protected override void Handle(EconomyBailoutCommand command) { IgnoreHelper.StartIgnore(); AddResource.DontAddResource = true; // Runs all the required accepted/rejected code UIView.library.Hide(typeof(BailoutPanel).Name, command.Accepted ? 1 : 0); AddResource.DontAddResource = false; IgnoreHelper.EndIgnore(); }
protected override void Handle(TreeCreateCommand command) { TreeInfo info = PrefabCollection <TreeInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(null, new uint[] { command.TreeId }); TreeManager.instance.CreateTree(out uint _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Single); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
protected override void Handle(PropCreateCommand command) { PropInfo info = PrefabCollection <PropInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(new ushort[] { command.PropId }, null); PropManager.instance.CreateProp(out ushort _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Angle, command.Single); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
protected override void Handle(BuildingCreateCommand command) { BuildingInfo info = PrefabCollection <BuildingInfo> .GetPrefab(command.InfoIndex); IgnoreHelper.StartIgnore(); ArrayHandler.StartApplying(command.Array16Ids, command.Array32Ids); BuildingManager.instance.CreateBuilding(out _, ref SimulationManager.instance.m_randomizer, info, command.Position, command.Angle, command.Length, SimulationManager.instance.m_currentBuildIndex++); ArrayHandler.StopApplying(); IgnoreHelper.EndIgnore(); }
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(DistrictCreateCommand command) { IgnoreHelper.StartIgnore(); DistrictManager.instance.CreateDistrict(out byte district); if (district != command.DistrictId) { LogManager.GetCurrentClassLogger().Log(LogLevel.Error, $"District array no longer in sync! Generated {district} instead of {command.DistrictId}"); ChatLogPanel.PrintGameMessage(ChatLogPanel.MessageType.Error, "District array no longer in sync! Please restart the multiplayer session!"); } DistrictManager.instance.m_districts.m_buffer[district].m_randomSeed = command.Seed; IgnoreHelper.EndIgnore(); }
protected override void Handle(ParkCreateCommand command) { IgnoreHelper.StartIgnore(); DistrictManager.instance.CreatePark(out byte park, command.ParkType, command.ParkLevel); if (park != command.ParkId) { Log.Error($"Park array no longer in sync! Generated {park} instead of {command.ParkId}"); ChatLogPanel.PrintGameMessage(ChatLogPanel.MessageType.Error, "Park array no longer in sync! Please restart the multiplayer session!"); } DistrictManager.instance.m_parks.m_buffer[park].m_randomSeed = command.Seed; IgnoreHelper.EndIgnore(); }
public static void Postfix() { if (IgnoreHelper.IsIgnored("ResetTool")) { return; } IgnoreHelper.EndIgnore("ResetTool"); ArrayHandler.StopCollecting(); Command.SendToAll(new TransportLineResetCommand() { Array16Ids = ArrayHandler.Collected16 }); }
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 static void Postfix(ushort building, ref Building.Flags changeMask, ref bool __state) { if (!__state) { return; } IgnoreHelper.EndIgnore(); ArrayHandler.StopCollecting(); Command.SendToAll(new BuildingUpdateFlagsCommand() { Building = building, ChangeMask = changeMask }); }
public static void Postfix(ushort buildingID, ref bool __state) { if (!__state) { return; } IgnoreHelper.EndIgnore(); ArrayHandler.StopCollecting(); Command.SendToAll(new BuildingUpgradeCommand() { Array16Ids = ArrayHandler.Collected16, Array32Ids = ArrayHandler.Collected32, Building = buildingID }); }