Пример #1
0
 public static void DestroyOptimizers()
 {
     HousingOptimizations.DestroyOptimizers();
     CharacterOptimizations.DestroyOptimizers();
     UIOptimizations.DestroyOptimizers();
     WorldOptimizations.DestroyOptimizers();
 }
Пример #2
0
        public static void InitializeOptimizers()
        {
            if (_playerObject == null || _playerCamera == null)
            {
                return;
            }

            HousingOptimizations.InitializeHousingOptimizations(_playerObject, _playerCamera, _footstepRange.Value, _cameraColliderRange.Value, _particleEmitterRange.Value, _housingAnimatorCulling.Value, _layerStrategy.Value, _housingLargeObjectSize.Value, _housingSmallObjectSize.Value, _housingDisableShadowHeight.Value);
            CharacterOptimizations.InitializeCharacterOptimizations(_playerObject, _dynamicBoneGenitalRange.Value, _dynamicBoneHairRange.Value, _dynamicBoneClothingRange.Value, _dynamicBoneBodyRange.Value, _characterAnimationCulling.Value);
            UIOptimizations.InitializeUserInterfaceOptimizations();
            LightOptimizations.AdjustCharacterLighting(_layerStrategy.Value);
            WorldOptimizations.InitializeWorldOptimizations(_basemapDistance.Value, _terrainCastShadows.Value, _layerStrategy.Value, _drawTreesAndFoliage.Value, _citySpotLightShadows.Value, _cityPointLightShadows.Value, _enableCityPointLights.Value, _citySpotLightIntensity.Value, _worldAnimatorCulling.Value);
            AnimalOptimizations.InitializeAnimalOptimizations(_animalAnimatorCulling.Value);
            CharacterOptimizations.SetPlayerDynamicBones(_playerDynamicBones.Value);
        }
Пример #3
0
        private void Awake()
        {
            _dynamicBoneUpdateRate = Config.Bind("Character Optimizations", "Dynamic Bone Enable Rate", 10, new ConfigDescription("(ILLUSION DEFAULT 1) Number of frames to spread out enabling/disabling dynamic bone checks, quicker response but lower perfomance", new AcceptableValueRange <int>(1, 60)));
            (_dynamicBoneClothingRange = Config.Bind("Character Optimizations", "Dynamic Bone Range - Accesories/Clothing", 250f, new ConfigDescription("(ILLUSION DEFAULT 10000) Range where clothing dynamic bones are enabled, always enabled during HScenes", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { CharacterOptimizations.SetColliderRanges(_dynamicBoneGenitalRange.Value * _dynamicBoneGenitalRange.Value, _dynamicBoneHairRange.Value * _dynamicBoneHairRange.Value, _dynamicBoneClothingRange.Value * _dynamicBoneClothingRange.Value, _dynamicBoneBodyRange.Value * _dynamicBoneBodyRange.Value); };
            (_dynamicBoneHairRange = Config.Bind("Character Optimizations", "Dynamic Bone Range - Hair", 150f, new ConfigDescription("(ILLUSION DEFAULT 10000) Range where hair dynamic bones are enabled, always enabled during HScenes", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { CharacterOptimizations.SetColliderRanges(_dynamicBoneGenitalRange.Value * _dynamicBoneGenitalRange.Value, _dynamicBoneHairRange.Value * _dynamicBoneHairRange.Value, _dynamicBoneClothingRange.Value * _dynamicBoneClothingRange.Value, _dynamicBoneBodyRange.Value * _dynamicBoneBodyRange.Value); };
            (_dynamicBoneBodyRange = Config.Bind("Character Optimizations", "Dynamic Bone Range - TnA", 100f, new ConfigDescription("(ILLUSION DEFAULT 10000) Range where body dynamic bones are enabled, always enabled during HScenes", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { CharacterOptimizations.SetColliderRanges(_dynamicBoneGenitalRange.Value * _dynamicBoneGenitalRange.Value, _dynamicBoneHairRange.Value * _dynamicBoneHairRange.Value, _dynamicBoneClothingRange.Value * _dynamicBoneClothingRange.Value, _dynamicBoneBodyRange.Value * _dynamicBoneBodyRange.Value); };
            (_dynamicBoneGenitalRange = Config.Bind("Character Optimizations", "Dynamic Bone Range - V****a", 1f, new ConfigDescription("(ILLUSION DEFAULT 10000) Range where genital dynamic bones are enabled, always enabled during HScenes", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { CharacterOptimizations.SetColliderRanges(_dynamicBoneGenitalRange.Value * _dynamicBoneGenitalRange.Value, _dynamicBoneHairRange.Value * _dynamicBoneHairRange.Value, _dynamicBoneClothingRange.Value * _dynamicBoneClothingRange.Value, _dynamicBoneBodyRange.Value * _dynamicBoneBodyRange.Value); };
            (_characterAnimationCulling = Config.Bind("Character Optimizations", "Optimizations - Animation Culling", AnimatorCullingMode.CullUpdateTransforms, "(ILLUSION DEFAULT AlwaysAnimate) What animators should do when they are not visible")).SettingChanged += (s, e) =>
            { CharacterOptimizations.UpdateAnimatorCulling(_characterAnimationCulling.Value); };
            _IKSolverChecks       = Config.Bind("Character Optimizations", "Optimizations - IK Solver Checks", true, "(ILLUSION DEFAULT true) Skip IK solvers if character is not visible");
            _LookControllerChecks = Config.Bind("Character Optimizations", "Optimizations - Look Controller Checks", true, "(ILLUSION DEFAULT true) Skip head look controls if character is not visible");

            _searchUpdateRate = Config.Bind("Character Optimizations", "Search Update Rate", 30, new ConfigDescription("Number of frames to spread out character checks to see what objects are closeby to interact with, lower values = quicker response but lower perfomance", new AcceptableValueRange <int>(1, 60)));

            (_shadowDistance = Config.Bind("Shadow Optimizations", "Shadow Distance", 400f, new ConfigDescription("(ILLUSION DEFAULT 10000) Overall maximum shadow distance", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { QualitySettings.shadowDistance = _shadowDistance.Value; };
            (_shadowProjection = Config.Bind("Shadow Optimizations", "Shadow Projection Mode", ShadowProjection.StableFit, "(ILLUSION DEFAULT CloseFit) Close fit shadows update more often, but stable fit jitter less and render slightly quicker")).SettingChanged += (s, e) =>
            { QualitySettings.shadowProjection = _shadowProjection.Value; };
            (_characterShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - Characters", 150, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render character shadows", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.CharaLayer, _characterShadowDistance.Value); };
            (_largeShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - Objects, Large/Terrain", 250, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render terrain shadows", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.LargeObjectLayer, _largeShadowDistance.Value); };
            (_mediumShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - Objects, Medium", 200, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render large housing shadows", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.MediumObjectLayer, _mediumShadowDistance.Value); };
            (_smallShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - Objects, Small", 150, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render small housing shadows", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.SmallObjectLayer, _smallShadowDistance.Value); };
            (_worldShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - World", 250, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render world shadows", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.MapLayer, _worldShadowDistance.Value); };
            (_waterShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - Water", 100, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render water shadows", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.WaterLayer, _waterShadowDistance.Value); };
            (_defaultShadowDistance = Config.Bind("Shadow Optimizations", "Shadows Distance - Single Layer", 250, new ConfigDescription("(ILLUSION DEFAULT 10000) Distance to render the single layer", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { LightOptimizations.UpdateShadowClipPlane((int)GameLayers.Layer.DefaultLayer, _defaultShadowDistance.Value); };

            _housingColliderUpdateRate = Config.Bind("Housing Optimizations", "Collider Update Rate", 30, new ConfigDescription("(ILLUSION DEFAULT N/A) Number of frames to spread out housing collider checks, lower values = more responsive colliders but lower perfomance", new AcceptableValueRange <int>(1, 60)));
            _housingParticleUpdateRate = Config.Bind("Housing Optimizations", "Light/Particle Update Rate", 10, new ConfigDescription("(ILLUSION DEFAULT N/A) Number of frames to spread out housing particle enable checks, lower values = more responsive particle enabling but lower perfomance", new AcceptableValueRange <int>(1, 60)));
            (_footstepRange = Config.Bind("Housing Optimizations", "Collider Range - Footsteps", 50f, new ConfigDescription("(ILLUSION DEFAULT N/A) Range at which to enable footstep colliders for activating different footstep sounds", new AcceptableValueRange <float>(1f, 10000f)))).SettingChanged += (s, e) =>
            { HousingOptimizations.SetDetectionRanges(_footstepRange.Value, _cameraColliderRange.Value, _particleEmitterRange.Value); };
            (_cameraColliderRange = Config.Bind("Housing Optimizations", "Collider Range - Camera", 50f, new ConfigDescription("(ILLUSION DEFAULT N/A) Range where camera colliders are enabled", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { HousingOptimizations.SetDetectionRanges(_footstepRange.Value, _cameraColliderRange.Value, _particleEmitterRange.Value); };
            (_particleEmitterRange = Config.Bind("Housing Optimizations", "Light/Particle Range", 100f, new ConfigDescription("(ILLUSION DEFAULT N/A) Range where housing lights and particle emitters (like torches/steam) are enabled.  Visible emitters are always enabled.", new AcceptableValueRange <float>(1, 10000)))).SettingChanged += (s, e) =>
            { HousingOptimizations.SetDetectionRanges(_footstepRange.Value, _cameraColliderRange.Value, _particleEmitterRange.Value); };
            (_layerStrategy = Config.Bind("Housing Optimizations", "Alternate Layer Strategy", GameLayers.LayerStrategy.SingleLayer, "(ILLUSION DEFAULT None) Moves Housing/Terrain Objects to alternate Layers so they can be clipped.  Single Layer moves everything to the Single Layer.  MultiLayer moves objects to multiple layers and has better FPS but can result in lighting artifacts depending on settings.")).SettingChanged += (s, e) =>
            { HousingOptimizations.UpdateHousingLayers(_layerStrategy.Value, _housingLargeObjectSize.Value, _housingSmallObjectSize.Value);
              LightOptimizations.AdjustCharacterLighting(_layerStrategy.Value);
              WorldOptimizations.AdjustTerrainLayer(_layerStrategy.Value);
              WorldOptimizations.AdjustCullingMasks(_layerStrategy.Value); };
            (_housingLargeObjectSize = Config.Bind("Housing Optimizations", "Housing objects - Large Object Threshold", 1000f, "(ILLUSION DEFAULT N/A) Objects larger than this will be moved to Large Object Layer.  Size is computed by Y axis squared times X/Z diagonal")).SettingChanged += (s, e) =>
            { HousingOptimizations.UpdateHousingLayers(_layerStrategy.Value, _housingLargeObjectSize.Value, _housingSmallObjectSize.Value); };
            (_housingSmallObjectSize = Config.Bind("Housing Optimizations", "Housing objects - Small Object Threshold", 100f, "(ILLUSION DEFAULT N/A) Objects smaller than this will be moved to Small Object Layer.  Size is computed by Y axis squared times X/Z diagonal")).SettingChanged += (s, e) =>
            { HousingOptimizations.UpdateHousingLayers(_layerStrategy.Value, _housingLargeObjectSize.Value, _housingSmallObjectSize.Value); };
            (_housingAnimatorCulling = Config.Bind("Housing Optimizations", "Housing Animator Culling", AnimatorCullingMode.CullCompletely, "(ILLUSION DEFAULT CullUpdateTransforms) What animators should do when they are not visible")).SettingChanged += (s, e) =>
            { HousingOptimizations.UpdateAnimatorCulling(_housingAnimatorCulling.Value); };
            (_housingDisableShadowHeight = Config.Bind("Housing Optimizations", "Shadow Height Limit", 0f, new ConfigDescription("(ILLUSION DEFAULT 0) Disable shadows for housing items shorter than limit (Items like clover patches, ground ivy, etc).", new AcceptableValueRange <float>(0, 5)))).SettingChanged += (s, e) =>
            { HousingOptimizations.UpdateHousingShadows(_housingDisableShadowHeight.Value); };

            (_sphericalCulling = Config.Bind("Camera Clip Optimizations", "Spherical Clipping", true, new ConfigDescription("(ILLUSION DEFAULT false) Clips objects in a spherical radius so items don't appear/dissapear as you rotate the camera."))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraSphericalCulling(_sphericalCulling.Value); };
            (_characterClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - Characters", 250, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for Characters", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.CharaLayer, _characterClipDistance.Value); };
            (_terrainClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - Objects, Large/Terrain", 500, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for the Terrain (ground)", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.LargeObjectLayer, _terrainClipDistance.Value); };
            (_mediumClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - Objects, Medium", 350, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for Large Housing Objects", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.MediumObjectLayer, _mediumClipDistance.Value); };
            (_smallClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - Objects, Small", 200, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for Small Housing Objects", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.SmallObjectLayer, _smallClipDistance.Value); };
            (_waterClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - Water", 2000, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for Water", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.WaterLayer, _waterClipDistance.Value); };
            (_worldClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - World", 2000, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for the Map", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.MapLayer, _worldClipDistance.Value); };
            (_defaultClipDistance = Config.Bind("Camera Clip Optimizations", "Clip Distance - Single Layer", 500, new ConfigDescription("(ILLUSION DEFAULT 10000) Clipping Distance for the Single Layer", new AcceptableValueRange <int>(1, 10000)))).SettingChanged += (s, e) =>
            { CameraOptimizations.UpdateCameraFarClipPlane(GameLayers.Layer.DefaultLayer, _defaultClipDistance.Value); };
            _hSceneClipDistance = Config.Bind("Camera Clip Optimizations", "HScene Clip Distance", 250, new ConfigDescription("(ILLUSION DEFAULT 10000) Max Clipping Distance during hScenes", new AcceptableValueRange <int>(1, 10000)));

            (_cityPointLightShadows = Config.Bind("World Optimizations", "City Point Light Shadows", LightShadows.None, "(ILLUSION DEFAULT Hard) Turn shadows on/off for the point lights on the main island.  Point lights are very expensive to cast shadows.")).SettingChanged += (s, e) =>
            { WorldOptimizations.SetCityLightShadows(_citySpotLightShadows.Value, _cityPointLightShadows.Value); };
            (_enableCityPointLights = Config.Bind("World Optimizations", "City Point Lights Enabled", false, "(ILLUSION DEFAULT true) Disable City Point Lights.  All city lights have a spot light and a point light.  Point lights can be expensive to render, especially if they have shadows.")).SettingChanged += (s, e) =>
            { WorldOptimizations.EnableCityPointLights(_enableCityPointLights.Value); };
            (_citySpotLightShadows = Config.Bind("World Optimizations", "City Spot Light Shadows", LightShadows.Hard, "(ILLUSION DEFAULT Hard) Turn shadows on/off for the city lights on the main island")).SettingChanged += (s, e) =>
            { WorldOptimizations.SetCityLightShadows(_citySpotLightShadows.Value, _cityPointLightShadows.Value); };
            (_citySpotLightIntensity = Config.Bind("World Optimizations", "City Spot Lights Intensity", 2.0f, new ConfigDescription("(ILLUSION DEFAULT 1.5) City spot light intensity. Can be increased to counteract loss of point lights if they are disabled.", new AcceptableValueRange <float>(0, 4)))).SettingChanged += (s, e) =>
            { WorldOptimizations.SetCitySpotLightIntensity(_citySpotLightIntensity.Value); };
            (_LODBias = Config.Bind("World Optimizations", "Terrain Level of Detail Bias", 2.0f, new ConfigDescription("(ILLUSION DEFAULT 2.0) Deterimines how far away to swith to higher detail models. Higher values means use higher detail further away", new AcceptableValueRange <float>(0, 10)))).SettingChanged += (s, e) =>
            { QualitySettings.lodBias = _LODBias.Value; };
            (_maximumLOD = Config.Bind("World Optimizations", "Terrain Level of Detail Maximum", 0, new ConfigDescription("(ILLUSION DEFAULT 0) Maximum Level of Detail to use for objects. LOD 0 is highest detail, LOD 3 is lowest", new AcceptableValueRange <int>(0, 3)))).SettingChanged += (s, e) =>
            { QualitySettings.maximumLODLevel = _maximumLOD.Value; };
            (_basemapDistance = Config.Bind("World Optimizations", "Terrain Detail Distance", 300f, new ConfigDescription("(ILLUSION DEFAULT 0 for Main Island, 2000 for Residential Island) Distance to render high res textures for the terrain", new AcceptableValueRange <float>(0, 10000)))).SettingChanged += (s, e) =>
            { WorldOptimizations.SetTerrainDetailDistance(_basemapDistance.Value); };
            (_drawTreesAndFoliage = Config.Bind("World Optimizations", "Terrain Trees and Foliage", true, "(ILLUSION DEFAULT true) Set to false to disable rendering trees and foliage baked in to the terrain")).SettingChanged += (s, e) =>
            { WorldOptimizations.EnableTreeRendering(_drawTreesAndFoliage.Value); };
            (_terrainCastShadows = Config.Bind("World Optimizations", "Terrain Casts Shadows", false, "(ILLUSION DEFAULT true) Turn shadows on/off for the terrain on Residential Island")).SettingChanged += (s, e) =>
            { WorldOptimizations.SetTerrainShadows(_terrainCastShadows.Value); };
            (_animalAnimatorCulling = Config.Bind("World Optimizations", "Animal Animator Culling", AnimatorCullingMode.CullCompletely, "(ILLUSION DEFAULT CullUpdateTransforms) What animal animators should do when they are not visible")).SettingChanged += (s, e) =>
            { AnimalOptimizations.UpdateAnimatorCulling(_animalAnimatorCulling.Value); };
            (_worldAnimatorCulling = Config.Bind("World Optimizations", "Main Island Animator Culling", AnimatorCullingMode.CullCompletely, "(ILLUSION DEFAULT AlwaysAnimate) What world animators should do when they are not visible")).SettingChanged += (s, e) =>
            { WorldOptimizations.UpdateAnimatorCulling(_worldAnimatorCulling.Value); };

            _miniMapMaxFPS     = Config.Bind("Player Optimizations", "MiniMap Maximum FPS", 15, new ConfigDescription("(ILLUSION DEFAULT 60) FPS to render the MiniMap, higher values = more responsive but lower perfomance", new AcceptableValueRange <int>(1, 60)));
            _commandUpdateRate = Config.Bind("Player Optimizations", "Command Update Rate", 15, new ConfigDescription("(ILLUSION DEFAULT 1) Number of frames to spread out command checks, lower values = more responsive but lower perfomance", new AcceptableValueRange <int>(1, 60)));
            _UIMenuUpdateRate  = Config.Bind("Player Optimizations", "Inactive UI Update Rate", 5, new ConfigDescription("(ILLUSION DEFAULT 1) Number of frames to spread out checks to see if a UI has become active and needs to be displayed, lower values = more responsive but lower perfomance", new AcceptableValueRange <int>(1, 60)));
            (_enableInactiveUIChecks = Config.Bind("Player Optimizations", "Inactive UI Checks", true, "(ILLUSION DEFAULT false) When enabled, disables UI windows that aren't visible, so they aren't being rendered in the background")).SettingChanged += (s, e) =>
            { if (_enableInactiveUIChecks.Value)
              {
                  UIOptimizations.InitializeUserInterfaceOptimizations();
              }
              else
              {
                  UIOptimizations.DestroyOptimizers();
              } };
            (_playerDynamicBones = Config.Bind("Player Optimizations", "Dynamic Bones", true, "(ILLUSION DEFAULT true) Enable/disable player dynamic bones")).SettingChanged += (s, e) =>
            { CharacterOptimizations.SetPlayerDynamicBones(_playerDynamicBones.Value); };

            SceneManager.sceneUnloaded += SceneManager_sceneUnloaded;
            Harmony.CreateAndPatchAll(typeof(AIMainGameOptimizations));
        }