예제 #1
0
        public static void Prefix(ushort eventID, ref EventData data, Color32 newColor, EventAI __instance)
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            Type type = __instance.GetType();

            if (type != typeof(RocketLaunchAI) && type != typeof(ConcertAI) && type != typeof(SportMatchAI))
            {
                return;
            }

            if (newColor.r == data.m_color.r && newColor.g == data.m_color.g && newColor.b == data.m_color.b)
            {
                return;
            }

            Command.SendToAll(new EventColorChangedCommand()
            {
                Event = eventID,
                Color = newColor
            });
        }
예제 #2
0
        public static void Prefix(object __instance, ref bool __state)
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            TransportTool tool    = ReflectionHelper.GetAttr <TransportTool>(__instance, "$this");
            int           counter = ReflectionHelper.GetAttr <int>(__instance, "$PC");

            int mode         = ReflectionHelper.GetAttr <int>(tool, "m_mode");
            int expectedMode = ReflectionHelper.GetEnumValue(
                typeof(TransportTool).GetNestedType("Mode", ReflectionHelper.AllAccessFlags), "MoveStops");

            if (counter != 0 || mode != expectedMode)
            {
                __state = false;
                return;
            }

            __state = true;

            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore("CancelMoveStop");
        }
        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();
        }
예제 #4
0
        public static void Postfix(WeatherManager __instance, ref DataStore __state)
        {
            if (IgnoreHelper.IsIgnored() || MultiplayerManager.Instance.CurrentRole == MultiplayerRole.Client)
            {
                return;
            }

            // don't send command if target values have not been changed
            if (!__state.HasChanged(__instance))
            {
                return;
            }

            Command.SendToAll(new WeatherCommand
            {
                CurrentCloud         = __instance.m_currentCloud,
                TargetCloud          = __instance.m_targetCloud,
                CurrentFog           = __instance.m_currentFog,
                TargetFog            = __instance.m_targetFog,
                CurrentNothernLights = __instance.m_currentNorthernLights,
                TargetNothernLights  = __instance.m_targetNorthernLights,
                CurrentRain          = __instance.m_currentRain,
                TargetRain           = __instance.m_targetRain,
                CurrentRainbow       = __instance.m_currentRainbow,
                TargetRainbow        = __instance.m_targetRainbow,
                CurrentTemperature   = __instance.m_currentTemperature,
                TargetTemperature    = __instance.m_targetTemperature,
            });
        }
예제 #5
0
        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();
        }
예제 #6
0
        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
            });
        }
예제 #7
0
        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();
        }
예제 #8
0
        public static void Prefix(object __instance, ref bool __state)
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            TransportTool tool    = ReflectionHelper.GetAttr <TransportTool>(__instance, "$this");
            int           counter = ReflectionHelper.GetAttr <int>(__instance, "$PC");

            int mode         = ReflectionHelper.GetAttr <int>(tool, "m_mode");
            int expectedMode = ReflectionHelper.GetEnumValue(typeof(TransportTool).GetNestedType("Mode", ReflectionHelper.AllAccessFlags), "NewLine");

            ToolBase.ToolErrors m_errors = ReflectionHelper.GetAttr <ToolBase.ToolErrors>(tool, "m_errors");
            ushort m_lastEditLine        = ReflectionHelper.GetAttr <ushort>(tool, "m_lastEditLine");
            int    m_hoverStopIndex      = ReflectionHelper.GetAttr <int>(tool, "m_hoverStopIndex");
            int    m_building            = ReflectionHelper.GetAttr <int>(tool, "m_building");

            if (counter != 0 || m_errors != ToolBase.ToolErrors.None || mode != expectedMode || m_lastEditLine == 0 || m_hoverStopIndex == -1 || (m_building != 0 && m_hoverStopIndex == 0))
            {
                __state = false;
                return;
            }
            __state = true;

            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore("RemoveStop");
        }
예제 #9
0
        public static void Prefix(out CallState __state, object __instance)
        {
            __state = new CallState();

            if (IgnoreHelper.IsIgnored())
            {
                __state.run = false;
                return;
            }

            BuildingTool tool    = ReflectionHelper.GetAttr <BuildingTool>(__instance, "$this");
            int          counter = ReflectionHelper.GetAttr <int>(__instance, "$PC");

            ToolBase.ToolErrors ___m_placementErrors = ReflectionHelper.GetAttr <ToolBase.ToolErrors>(tool, "m_placementErrors");

            if (counter != 0 || ___m_placementErrors != ToolBase.ToolErrors.None)
            {
                __state.run = false;
                return;
            }

            __state.run      = true;
            __state.relocate = tool.m_relocate; // Save relocate state as it will be cleared at the end of the method

            IgnoreHelper.StartIgnore();
            ArrayHandler.StartCollecting();
        }
예제 #10
0
        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
                });
            }
        }
예제 #11
0
        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
            });
        }
예제 #12
0
        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);
        }
예제 #13
0
        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();
        }
예제 #14
0
        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();
        }
예제 #15
0
        public static void Postfix(TransportInfo ___m_prefab, Vector3 ___m_hitPosition, bool ___m_fixedPlatform, int ___m_hoverStopIndex, int ___m_hoverSegmentIndex, int ___m_mode, ToolBase.ToolErrors ___m_errors, ref DataStore __state)
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            TransportHandler.TrackSimulationStep = false;

            // Only send when values have changed
            if (TransportHandler.DidUpdatePaths ||
                __state.hitPos != ___m_hitPosition || __state.fixedP != ___m_fixedPlatform ||
                __state.hoverStop != ___m_hoverStopIndex || __state.hoverSegment != ___m_hoverSegmentIndex ||
                __state.mode != ___m_mode || __state.errors != ___m_errors)
            {
                Command.SendToAll(new TransportLineSyncCommand()
                {
                    HitPosition       = ___m_hitPosition,
                    FixedPlatform     = ___m_fixedPlatform,
                    HoverStopIndex    = ___m_hoverStopIndex,
                    HoverSegmentIndex = ___m_hoverSegmentIndex,
                    Mode        = ___m_mode,
                    Errors      = ___m_errors,
                    UpdateLines = TransportHandler.DidUpdateLinesNow,
                    UpdatePaths = TransportHandler.DidUpdatePaths
                });

                TransportHandler.DidUpdateLinesNow = false;
                TransportHandler.DidUpdatePaths    = false;
            }
        }
예제 #16
0
        protected override void Handle(BuildingUpdateFlagsCommand command)
        {
            IgnoreHelper.StartIgnore();

            BuildingManager.instance.UpdateFlags(command.Building, command.ChangeMask);

            IgnoreHelper.EndIgnore();
        }
예제 #17
0
        public static bool CanRun(object instance, bool state)
        {
            if (IgnoreHelper.IsIgnored() || !state)
            {
                return(false);
            }

            return(ReflectionHelper.GetAttr <bool>(instance, "$current"));
        }
예제 #18
0
        public static void Postfix()
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            Command.SendToAll(new TransportLineInitCommand());
        }
예제 #19
0
        public static void Postfix(ref bool __state)
        {
            if (!__state || IgnoreHelper.IsIgnored("SetTaxRate"))
            {
                return;
            }

            IgnoreHelper.EndIgnore("SetTaxRate");
        }
예제 #20
0
        public static void Prefix()
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            ArrayHandler.StartCollecting();
        }
예제 #21
0
        public static void Postfix()
        {
            if (IgnoreHelper.IsIgnored() || !TransportHandler.TrackSimulationStep)
            {
                return;
            }

            TransportHandler.DidUpdateLinesNow = true;
        }
예제 #22
0
        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();
        }
예제 #23
0
        protected override void Handle(BuildingUpgradeCommand command)
        {
            IgnoreHelper.StartIgnore();
            ArrayHandler.StartApplying(command.Array16Ids, command.Array32Ids);

            BuildingManager.instance.UpgradeBuilding(command.Building);

            ArrayHandler.StopApplying();
            IgnoreHelper.EndIgnore();
        }
예제 #24
0
        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();
        }
예제 #25
0
 public static void Prefix(ref byte park)
 {
     if (!IgnoreHelper.IsIgnored())
     {
         Command.SendToAll(new ParkReleaseCommand
         {
             ParkId = park
         });
     }
 }
예제 #26
0
 public static void Postfix(byte district)
 {
     if (!IgnoreHelper.IsIgnored())
     {
         Command.SendToAll(new DistrictReleaseCommand
         {
             DistrictId = district,
         });
     }
 }
예제 #27
0
 public static void Postfix(DistrictPolicies.Policies policy)
 {
     if (!IgnoreHelper.IsIgnored())
     {
         Command.SendToAll(new DistrictCityPolicyCommand
         {
             Policy = policy
         });
     }
 }
        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(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();
        }
예제 #30
0
        public static void Prefix()
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore("StartEditingBuildingLine");
        }