Пример #1
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");
        }
Пример #2
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
                });
            }
        }
Пример #3
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");
        }
Пример #4
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();
        }
Пример #5
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
            });
        }
Пример #6
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
            });
        }
Пример #7
0
        public static void Prefix()
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            ArrayHandler.StartCollecting();
        }
Пример #8
0
        public static void Prefix()
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore("StartEditingBuildingLine");
        }
Пример #9
0
        public static void Prefix(out bool __state)
        {
            if (IgnoreHelper.IsIgnored())
            {
                __state = false;
                return;
            }

            __state = true;
            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore();
        }
Пример #10
0
        public static void Prefix(ushort building, ref Building.Flags changeMask, out bool __state)
        {
            if (IgnoreHelper.IsIgnored())
            {
                __state = false;
                return;
            }

            __state = true;


            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore();
        }
Пример #11
0
        public static void Postfix()
        {
            if (IgnoreHelper.IsIgnored("ResetTool"))
            {
                return;
            }

            IgnoreHelper.EndIgnore("ResetTool");
            ArrayHandler.StopCollecting();

            Command.SendToAll(new TransportLineResetCommand()
            {
                Array16Ids = ArrayHandler.Collected16
            });
        }
Пример #12
0
        public static void Postfix(ushort lineID)
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            ArrayHandler.StopCollecting();

            Command.SendToAll(new TransportLineReleaseCommand()
            {
                Array16Ids = ArrayHandler.Collected16,
                Line       = lineID
            });
        }
Пример #13
0
        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
            });
        }
Пример #14
0
        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
            });
        }
Пример #15
0
        public static void Postfix(TransportInfo info, ushort buildingID)
        {
            if (IgnoreHelper.IsIgnored("StartEditingBuildingLine"))
            {
                return;
            }

            IgnoreHelper.EndIgnore("StartEditingBuildingLine");
            ArrayHandler.StopCollecting();

            Command.SendToAll(new TransportLineStartEditBuildingCommand()
            {
                Array16Ids = ArrayHandler.Collected16,
                Prefab     = (ushort)Mathf.Clamp(info.m_prefabDataIndex, 0, 65535),
                Building   = buildingID
            });
        }
Пример #16
0
        public static void Postfix(object __instance, ref bool __state)
        {
            if (!__state)
            {
                return;
            }

            IgnoreHelper.EndIgnore();
            ArrayHandler.StopCollecting();

            ushort building = ReflectionHelper.GetAttr <ushort>(__instance, "buildingID");

            Command.SendToAll(new BuildingRebuildCommand()
            {
                Building   = building,
                Array16Ids = ArrayHandler.Collected16
            });
        }
Пример #17
0
        public static void Postfix(ushort lineID, int index, Vector3 newPos, bool fixedPlatform)
        {
            if (IgnoreHelper.IsIgnored())
            {
                return;
            }

            ArrayHandler.StopCollecting();

            Command.SendToAll(new TransportLineMoveStopManCommand()
            {
                Array16Ids    = ArrayHandler.Collected16,
                Line          = lineID,
                Index         = index,
                NewPos        = newPos,
                FixedPlatform = fixedPlatform
            });
        }
Пример #18
0
        public static void Prefix(ushort ___m_tempLine, ushort ___m_lastEditLine, int ___m_lastMoveIndex, int ___m_lastAddIndex, Vector3 ___m_lastAddPos, out DataStore __state)
        {
            __state = new DataStore();

            if (IgnoreHelper.IsIgnored() || !TransportHandler.TrackSimulationStep)
            {
                return;
            }

            __state.tempLine = ___m_tempLine;
            __state.editLine = ___m_lastEditLine;
            __state.move     = ___m_lastMoveIndex;
            __state.add      = ___m_lastAddIndex;
            __state.addP     = ___m_lastAddPos;

            ArrayHandler.StartCollecting();
            IgnoreHelper.StartIgnore("EnsureTempLine");
        }
Пример #19
0
        public static void Postfix(ref bool __state)
        {
            if (IgnoreHelper.IsIgnored("AddStop"))
            {
                return;
            }

            if (!__state)
            {
                return;
            }

            IgnoreHelper.EndIgnore("AddStop");
            ArrayHandler.StopCollecting();

            Command.SendToAll(new TransportLineAddStopCommand()
            {
                Array16Ids = ArrayHandler.Collected16
            });
        }
Пример #20
0
        public static void Postfix(ref bool __state, bool ___applyChanges)
        {
            if (IgnoreHelper.IsIgnored("MoveStop"))
            {
                return;
            }

            if (!__state)
            {
                return;
            }

            IgnoreHelper.EndIgnore("MoveStop");
            ArrayHandler.StopCollecting();

            Command.SendToAll(new TransportLineMoveStopCommand()
            {
                Array16Ids   = ArrayHandler.Collected16,
                ApplyChanges = ___applyChanges
            });
        }
Пример #21
0
        public static void Postfix(ref CallState __state, object __instance)
        {
            if (!__state.run)
            {
                return;
            }

            ArrayHandler.StopCollecting();
            IgnoreHelper.EndIgnore();

            BuildingTool   tool       = ReflectionHelper.GetAttr <BuildingTool>(__instance, "$this");
            ToolController controller = ReflectionHelper.GetAttr <ToolController>(tool, "m_toolController");

            ushort prefab = 0;

            if (__state.relocate == 0)
            {
                prefab = (ushort)Mathf.Clamp(tool.m_prefab.m_prefabDataIndex, 0, 65535);
            }

            Vector3 mousePosition = ReflectionHelper.GetAttr <Vector3>(tool, "m_mousePosition");
            float   mouseAngle    = ReflectionHelper.GetAttr <float>(tool, "m_mouseAngle");
            int     elevation     = ReflectionHelper.GetAttr <int>(tool, "m_elevation");

            ulong[] collidingSegments  = ReflectionHelper.GetAttr <ulong[]>(controller, "m_collidingSegments1");
            ulong[] collidingBuildings = ReflectionHelper.GetAttr <ulong[]>(controller, "m_collidingBuildings1");

            Command.SendToAll(new BuildingToolCreateCommand()
            {
                Array16Ids         = ArrayHandler.Collected16,
                Array32Ids         = ArrayHandler.Collected32,
                Prefab             = prefab,
                Relocate           = __state.relocate,
                CollidingSegments  = collidingSegments,
                CollidingBuildings = collidingBuildings,
                MousePosition      = mousePosition,
                MouseAngle         = mouseAngle,
                Elevation          = elevation
            });
        }
Пример #22
0
        public static void Postfix(TransportInfo info, ushort sourceLine, int moveIndex, int addIndex, Vector3 addPos, bool fixedPlatform, ushort ___m_lastEditLine, ushort ___m_tempLine, ref DataStore __state)
        {
            if (IgnoreHelper.IsIgnored("EnsureTempLine") || !TransportHandler.TrackSimulationStep)
            {
                return;
            }

            IgnoreHelper.EndIgnore("EnsureTempLine");
            ArrayHandler.StopCollecting();

            // Make sure we send the command only when needed (Otherwise it would be really often!)
            if (ArrayHandler.Collected16.Length > 0 ||
                __state.tempLine != ___m_tempLine ||
                __state.editLine != ___m_lastEditLine ||
                __state.move != moveIndex ||
                __state.add != addIndex ||
                __state.addP != addPos)
            {
                if ((__state.addP == Vector3.zero || addPos == Vector3.zero) &&
                    moveIndex == __state.moveLast && addIndex == __state.addLast && addPos == __state.addPLast)
                {
                    return;
                }

                __state.addPLast = addPos;
                __state.moveLast = moveIndex;
                __state.addLast  = addIndex;

                Command.SendToAll(new TransportLineTempCommand()
                {
                    InfoIndex     = (ushort)Mathf.Clamp(info.m_prefabDataIndex, 0, 65535),
                    SourceLine    = sourceLine,
                    MoveIndex     = moveIndex,
                    AddIndex      = addIndex,
                    AddPos        = addPos,
                    FixedPlatform = fixedPlatform,
                    Array16Ids    = ArrayHandler.Collected16
                });
            }
        }
Пример #23
0
        public static void Prefix(out CallState __state, bool test, bool visualize,
                                  NetTool.ControlPoint startPoint, NetTool.ControlPoint middlePoint, NetTool.ControlPoint endPoint)
        {
            __state = new CallState();

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

            if (test || visualize)
            {
                __state.valid = false;
                return;
            }

            __state.valid = true;
            __state.SetControlPoints(startPoint, middlePoint, endPoint);

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