Exemple #1
0
        public void Awake()
        {
            RedirectorInstance = KlyteMonoUtils.CreateElement <Redirector>(transform);
            LogUtils.DoLog("Loading Building Manager Overrides");
            MethodInfo posRename = GetType().GetMethod("OnBuildingNameChanged", RedirectorUtils.allFlags);
            MethodInfo calcGroup = typeof(BuildingManager).GetMethod("CalculateGroupData");
            MethodInfo popGroup  = typeof(BuildingManager).GetMethod("PopulateGroupData");


            System.Reflection.MethodInfo postRenderMeshs = GetType().GetMethod("TranspileEndRenderingImpl", RedirectorUtils.allFlags);
            var        orMeth = typeof(BuildingManager).GetMethod("EndRenderingImpl", RedirectorUtils.allFlags & ~BindingFlags.Public);
            MethodInfo AfterCalculateGroupData = GetType().GetMethod("AfterCalculateGroupData", RedirectorUtils.allFlags);
            MethodInfo AfterPopulateGroupData  = GetType().GetMethod("AfterPopulateGroupData", RedirectorUtils.allFlags);


            MethodInfo zoneUpdated           = typeof(BuildingManager).GetMethod("AfterTerrainUpdate");
            MethodInfo zonesUpdatedTranspile = GetType().GetMethod("AfterTerrainUpdateTranspile", RedirectorUtils.allFlags);

            LogUtils.DoLog($"Patching=> {posRename}");
            //RedirectorInstance.AddRedirect(BuildingManager.instance.SetBuildingName(0, "").GetType().GetMethod("MoveNext", RedirectorUtils.allFlags), null, posRename);
            LogUtils.DoLog($"Patching=> {AfterCalculateGroupData}");
            RedirectorInstance.AddRedirect(calcGroup, null, AfterCalculateGroupData);
            LogUtils.DoLog($"Patching=> {AfterPopulateGroupData}");
            RedirectorInstance.AddRedirect(popGroup, null, AfterPopulateGroupData);
            LogUtils.DoLog($"Patching=> {postRenderMeshs}");
            RedirectorInstance.AddRedirect(orMeth, null, null, postRenderMeshs);
            LogUtils.DoLog($"Patching=> {zonesUpdatedTranspile}");
            RedirectorInstance.AddRedirect(zoneUpdated, null, null, zonesUpdatedTranspile);
        }
        public void Start()
        {
            RedirectorInstance = KlyteMonoUtils.CreateElement <Redirector>(transform);
            LogUtils.DoLog("Loading District Manager Overrides");
            #region Release Line Hooks
            MethodInfo posChange = typeof(VMCController).GetMethod("OnDistrictChanged", RedirectorUtils.allFlags);

            RedirectorInstance.AddRedirect(typeof(DistrictManager).GetMethod("SetDistrictName", RedirectorUtils.allFlags), null, posChange);
            RedirectorInstance.AddRedirect(typeof(DistrictManager).GetMethod("AreaModified", RedirectorUtils.allFlags), null, posChange);
            #endregion
        }
        public void Awake()
        {
            RedirectorInstance = KlyteMonoUtils.CreateElement <Redirector>(transform);
            LogUtils.DoLog("Loading Transport Manager Overrides");
            #region Release Line Hooks
            MethodInfo posUpdate     = typeof(TransportManagerOverrides).GetMethod("PushIntoStackLine", RedirectorUtils.allFlags);
            MethodInfo posAddStop    = typeof(TransportManagerOverrides).GetMethod("PushIntoStackBuilding", RedirectorUtils.allFlags);
            MethodInfo preRemoveStop = typeof(TransportManagerOverrides).GetMethod("BeforeRemoveStop", RedirectorUtils.allFlags);
            MethodInfo posRemoveLine = typeof(TransportManagerOverrides).GetMethod("AfterRemoveLine", RedirectorUtils.allFlags);

            RedirectorInstance.AddRedirect(typeof(TransportManager).GetMethod("UpdateLine", RedirectorUtils.allFlags), null, posUpdate);
            RedirectorInstance.AddRedirect(typeof(TransportLine).GetMethod("AddStop", RedirectorUtils.allFlags), null, posAddStop);
            RedirectorInstance.AddRedirect(typeof(TransportLine).GetMethod("RemoveStop", RedirectorUtils.allFlags, null, new Type[] { typeof(ushort), typeof(int), typeof(Vector3).MakeByRefType() }, null), preRemoveStop);
            RedirectorInstance.AddRedirect(typeof(TransportManager).GetMethod("ReleaseLine", RedirectorUtils.allFlags), null, posRemoveLine);
            #endregion
        }
        public void Awake()
        {
            RedirectorInstance = KlyteMonoUtils.CreateElement <Redirector>(transform);
            LogUtils.DoLog("Loading Instance Manager Overrides");
            #region Release Line Hooks
            MethodInfo posRename = typeof(InstanceManagerOverrides).GetMethod("OnInstanceRenamed", RedirectorUtils.allFlags);

            RedirectorInstance.AddRedirect(typeof(InstanceManager).GetMethod("SetName", RedirectorUtils.allFlags), null, posRename);
            #endregion
        }
        public void Awake()
        {
            RedirectorInstance = new Redirector();

            MethodInfo from  = typeof(ResidentAI).GetMethod("GetVehicleInfo", RedirectorUtils.allFlags);
            MethodInfo from2 = typeof(TouristAI).GetMethod("GetVehicleInfo", RedirectorUtils.allFlags);
            MethodInfo to    = typeof(ResidentAIOverrides).GetMethod("GetVehicleInfoPost", RedirectorUtils.allFlags);

            LogUtils.DoLog($"REDIRECT VW {from}=>{to}");
            RedirectorInstance.AddRedirect(from, null, to);
            LogUtils.DoLog($"REDIRECT VW {from2}=>{to}");
            RedirectorInstance.AddRedirect(from2, null, to);

            var customResident = Type.GetType("TrafficManager.Custom.AI.CustomResidentAI");

            if (customResident != null)
            {
                MethodInfo to2   = typeof(ResidentAIOverrides).GetMethod("CustomGetVehicleInfoPost", RedirectorUtils.allFlags);
                MethodInfo from3 = customResident.GetMethod("CustomGetVehicleInfo");
                LogUtils.DoLog($"REDIRECT VW {from3}=>{to}");
                RedirectorInstance.AddRedirect(from3, null, to2);
            }
        }
Exemple #6
0
#pragma warning restore IDE0051 // Remover membros privados não utilizados

        #region Hooking

        public void Awake()
        {
            LogUtils.DoLog("Loading Net Manager Overrides");
            RedirectorInstance = KlyteMonoUtils.CreateElement <Redirector>(transform);
            #region Net Manager Hooks
            MethodInfo OnNodeChanged               = GetType().GetMethod("OnNodeChanged", RedirectorUtils.allFlags);
            MethodInfo OnSegmentCreated            = GetType().GetMethod("OnSegmentCreated", RedirectorUtils.allFlags);
            MethodInfo OnSegmentReleased           = GetType().GetMethod("OnSegmentReleased", RedirectorUtils.allFlags);
            MethodInfo OnSegmentNameChanged        = GetType().GetMethod("OnSegmentNameChanged", RedirectorUtils.allFlags);
            MethodInfo AfterTerrainUpdateTranspile = GetType().GetMethod("AfterTerrainUpdateTranspile", RedirectorUtils.allFlags);

            RedirectorInstance.AddRedirect(typeof(NetManager).GetMethod("CreateNode", RedirectorUtils.allFlags), null, OnNodeChanged);
            RedirectorInstance.AddRedirect(typeof(NetManager).GetMethod("ReleaseNode", RedirectorUtils.allFlags), null, OnNodeChanged);
            RedirectorInstance.AddRedirect(typeof(NetManager).GetMethod("CreateSegment", RedirectorUtils.allFlags, null, new[] { typeof(ushort).MakeByRefType(), typeof(Randomizer).MakeByRefType(), typeof(NetInfo), typeof(TreeInfo), typeof(ushort), typeof(ushort), typeof(Vector3), typeof(Vector3), typeof(uint), typeof(uint), typeof(bool) }, null), null, OnSegmentCreated);
            RedirectorInstance.AddRedirect(typeof(NetManager).GetMethod("ReleaseSegment", RedirectorUtils.allFlags), OnSegmentReleased);
            RedirectorInstance.AddRedirect(typeof(NetManager).GetMethod("SetSegmentNameImpl", RedirectorUtils.allFlags), null, OnSegmentNameChanged);
            RedirectorInstance.AddRedirect(typeof(NetManager).GetMethod("AfterTerrainUpdate", RedirectorUtils.allFlags), null, null, AfterTerrainUpdateTranspile);
            #endregion
        }