Esempio n. 1
0
        private void Redirect()
        // Goes to RedirectionUtil which goes to Redirector which finally goes to the actual detouring in RedirectionHelper, I guess...

        {
            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())

            {
                try

                {
                    var r = RedirectionUtil.RedirectType(type);

                    if (r != null)

                    {
                        foreach (var pair in r)

                        {
                            redirectsOnCreated.Add(pair.Key, pair.Value);
                        }
                    }
                }

                catch (Exception e)

                {
                    UnityEngine.Debug.Log($"An error occured while applying {type.Name} redirects!");

                    UnityEngine.Debug.Log(e.StackTrace);
                }
            }
        }
        private void Redirect(bool onCreated)
        {
            var redirects = onCreated ? redirectsOnCreated : redirectsOnLoaded;

            redirects.Clear();

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                try
                {
                    var r = RedirectionUtil.RedirectType(type, onCreated);
                    if (r != null)
                    {
                        foreach (var pair in r)
                        {
                            redirects.Add(pair.Key, pair.Value);
                        }
                    }
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.Log($"An error occured while applying {type.Name} redirects!");
                    UnityEngine.Debug.Log(e.StackTrace);
                }
            }
        }
Esempio n. 3
0
        private void Redirect(bool onCreated)
        {
            var redirects = onCreated ? redirectsOnCreated : redirectsOnLoaded;

            redirects.Clear();

            foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
            {
                try
                {
                    var r = RedirectionUtil.RedirectType(type, onCreated);
                    if (r == null)
                    {
                        continue;
                    }
                    foreach (var pair in r)
                    {
                        redirects.Add(pair.Key, pair.Value);
                    }
                }
                catch (Exception e)
                {
                    Debug.LogError($"An error occured while applying {type.Name} redirects!");
                    Debug.LogException(e);
                }
            }
        }
Esempio n. 4
0
 public static void Deploy()
 {
     if (_redirects != null)
     {
         return;
     }
     _redirects = RedirectionUtil.RedirectType(typeof(TerrainPropertiesPanelDetour));
 }
 public static void Deploy()
 {
     if (_redirects != null)
     {
         return;
     }
     _redirects = RedirectionUtil.RedirectType(typeof(AsyncOperationDetour));
 }
 public static void Redirect()
 {
     redirects = new Dictionary <MethodInfo, RedirectCallsState>();
     foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
     {
         redirects.AddRange(RedirectionUtil.RedirectType(type));
     }
 }
 public static void Deploy()
 {
     if (_redirects != null)
     {
         return;
     }
     _redirects = RedirectionUtil.RedirectType(typeof(CameraControllerDetour));
 }
 public static void Redirect(this Type type)
 {
     if (IsRedirected(type))
     {
         return;
     }
     Redirects[type] = RedirectionUtil.RedirectType(type);
 }
 public static void Deploy()
 {
     if (_redirects != null)
     {
         return;
     }
     _redirects = RedirectionUtil.RedirectType(typeof(SceneManagerDetour));
 }
Esempio n. 10
0
 public static void Revert(this Type type)
 {
     if (!IsRedirected(type))
     {
         return;
     }
     RedirectionUtil.RevertRedirects(Redirects[type]);
     Redirects[type].Clear();
 }
Esempio n. 11
0
 public Mod()
 {
     if (_detoured)
     {
         return;
     }
     RedirectionUtil.RedirectType(typeof(LoadSavePanelBaseDetour));
     RedirectionUtil.RedirectType(typeof(NewGamePanelDetour));
     RedirectionUtil.RedirectType(typeof(NewScenarioGamePanelDetour));
     _detoured = true;
 }
Esempio n. 12
0
        public static void Deploy()
        {
            if (_deployed)
            {
                return;
            }
            var tuple = RedirectionUtil.RedirectMethod(typeof(DistrictGroupPanel), _detourInfo);

            _originalInfo = tuple.First;
            _state        = tuple.Second;
            _deployed     = true;
        }
Esempio n. 13
0
        public static IDictionary <MethodInfo, RedirectCallsState> Redirect(this Type type)
        {
            IDictionary <MethodInfo, RedirectCallsState> ret = new Dictionary <MethodInfo, RedirectCallsState>();

            if (IsRedirected(type))
            {
                return(ret);
            }

            Redirects[type] = RedirectionUtil.RedirectType(type);
            ret.AddRange(Redirects[type]);
            return(ret);
        }
Esempio n. 14
0
        public static void Deploy()
        {
            if (_deployed)
            {
                return;
            }
            var tuple = RedirectionUtil.RedirectMethod(typeof(GameAreaManager), _detourInfo);

            _originalPtr = tuple.First.MethodHandle.GetFunctionPointer();
            _detourPtr   = _detourInfo.MethodHandle.GetFunctionPointer();
            _state       = tuple.Second;
            _deployed    = true;
        }
Esempio n. 15
0
        public static void Redirect()
        {
            if (!_redirected || ExperimentsToggle.RevertRedirects)
            {
                _redirected = true;

                redirects = new Dictionary <MethodInfo, RedirectCallsState>();
                foreach (var type in Assembly.GetExecutingAssembly().GetTypes())
                {
                    redirects.AddRange(RedirectionUtil.RedirectType(type));
                }
            }
        }
Esempio n. 16
0
        public static void Redirect(this Type type)
        {
            if (IsRedirected(type))
            {
                return;
            }
            var customAttributes = type.GetCustomAttributes(typeof(IgnoreConditionAttribute), false);

            if (customAttributes.Any(a => ((IgnoreConditionAttribute)a).IsIgnored(type)))
            {
                return;
            }
            Redirects[type] = RedirectionUtil.RedirectType(type);
        }
Esempio n. 17
0
 public static bool Deploy(bool cacheDeployState)
 {
     lock (ClassLock)
     {
         if (cacheDeployState)
         {
             _cachedDeployState = true;
         }
         if (IsDeployed())
         {
             return(false);
         }
         _redirects = RedirectionUtil.RedirectAssembly();
         return(true);
     }
 }
 public static void Deploy()
 {
     if (_redirects != null)
     {
         return;
     }
     _redirects              = RedirectionUtil.RedirectType(typeof(WindSpeedExtension));
     fogProperties           = Object.FindObjectOfType <FogProperties>();
     windSpeedBase           = fogProperties.m_WindSpeed;
     dynamicCloudsProperties = Object.FindObjectOfType <DayNightDynamicCloudsProperties>();
     windForceBase           = dynamicCloudsProperties.m_WindForce;
     targetCalm              = 0;
     currentCalm             = 0;
     noCalmCounter           = 0;
     initialized             = true;
 }
Esempio n. 19
0
 public static void Deploy()
 {
     if (_redirects != null)
     {
         return;
     }
     _redirects          = RedirectionUtil.RedirectType(typeof(ToggleSnappingDistrictTool));
     m_district          = typeof(DistrictTool).GetField("m_district", BindingFlags.Instance | BindingFlags.NonPublic);
     m_mousePosition     = typeof(DistrictTool).GetField("m_mousePosition", BindingFlags.Instance | BindingFlags.NonPublic);
     m_lastPaintPosition = typeof(DistrictTool).GetField("m_lastPaintPosition", BindingFlags.Instance | BindingFlags.NonPublic);
     m_mouseRay          = typeof(DistrictTool).GetField("m_mouseRay", BindingFlags.Instance | BindingFlags.NonPublic);
     m_mouseRayLength    = typeof(DistrictTool).GetField("m_mouseRayLength", BindingFlags.Instance | BindingFlags.NonPublic);
     m_painting          = typeof(DistrictTool).GetField("m_painting", BindingFlags.Instance | BindingFlags.NonPublic);
     m_erasing           = typeof(DistrictTool).GetField("m_erasing", BindingFlags.Instance | BindingFlags.NonPublic);
     m_mouseRayValid     = typeof(DistrictTool).GetField("m_mouseRayValid", BindingFlags.Instance | BindingFlags.NonPublic);
     m_errors            = typeof(DistrictTool).GetField("m_errors", BindingFlags.Instance | BindingFlags.NonPublic);
 }
Esempio n. 20
0
        public static void Redirect(bool onCreated)
        {
            if (onCreated)
            {
                redirectsOnCreated = new Dictionary <MethodInfo, RedirectCallsState>();
            }
            else
            {
                redirectsOnLoaded = new Dictionary <MethodInfo, RedirectCallsState>();
            }
            var redirects = onCreated ? redirectsOnCreated : redirectsOnLoaded;
            var types     = Assembly.GetExecutingAssembly().GetTypes().
                            Where(t => t.GetCustomAttributes(typeof(TargetTypeAttribute), false).Length > 0).
                            ToArray();

            foreach (var type in types)
            {
                redirects.AddRange(RedirectionUtil.RedirectType(type, onCreated));
            }
        }
Esempio n. 21
0
 public static void Revert(bool cacheDeployState)
 {
     lock (ClassLock)
     {
         if (cacheDeployState)
         {
             _cachedDeployState = false;
         }
         if (!IsDeployed())
         {
             return;
         }
         if (_redirects == null)
         {
             UnityEngine.Debug.LogError("Prop Anarchy - DetoursManager::Revert() - _redirects field was null");
             return;
         }
         RedirectionUtil.RevertRedirects(_redirects);
         _redirects.Clear();
     }
 }
Esempio n. 22
0
 public override void OnReleased()
 {
     base.OnReleased();
     RedirectionUtil.RevertRedirects(_redirects);
 }
Esempio n. 23
0
 public override void OnCreated(ILoading loading)
 {
     base.OnCreated(loading);
     _redirects = RedirectionUtil.RedirectAssembly();
 }
Esempio n. 24
0
 public override void OnCreated(ILoading loading)
 {
     base.OnCreated(loading);
     _redirects = RedirectionUtil.RedirectAssembly();
     LoadingProfilerDetour.Initialize();
 }
Esempio n. 25
0
 public override void OnReleased()
 {
     base.OnReleased();
     LoadingProfilerDetour.Revert();
     RedirectionUtil.RevertRedirects(_redirects);
 }