public static void UpdateHousingLightLayers(GameLayers.LayerStrategy layerStrategy) { if (housingLights.IsNullOrEmpty()) { return; } int newLayer = (int)GameLayers.Layer.MapLayer; if (layerStrategy == GameLayers.LayerStrategy.MultiLayer) { newLayer = (int)GameLayers.Layer.MediumObjectLayer; } else if (layerStrategy == GameLayers.LayerStrategy.SingleLayer) { newLayer = (int)GameLayers.Layer.DefaultLayer; } foreach (var housingLight in housingLights) { if (housingLight == null || housingLight.gameObject == null) { continue; } if (housingLight.gameObject.layer == (int)GameLayers.Layer.SmallObjectLayer || housingLight.gameObject.layer == (int)GameLayers.Layer.DefaultLayer || housingLight.gameObject.layer == (int)GameLayers.Layer.MapLayer) { housingLight.gameObject.layer = newLayer; } } }
public static void AdjustCullingMasks(GameLayers.LayerStrategy layerStrategy) { if (layerStrategy == GameLayers.LayerStrategy.MultiLayer) { AddLayerMaskToCullingMasks(GameLayers.LayerMask.MediumObjectLayer | GameLayers.LayerMask.SmallObjectLayer | GameLayers.LayerMask.LargeObjectLayer); } else if (layerStrategy == GameLayers.LayerStrategy.SingleLayer) { AddLayerMaskToCullingMasks(GameLayers.LayerMask.DefaultLayer); } }
public static void AdjustTerrainLayer(GameLayers.LayerStrategy layerStrategy) { if (isHousingIsland) { return; } if (layerStrategy == GameLayers.LayerStrategy.MultiLayer) { MoveTerrainToLayer((int)GameLayers.Layer.LargeObjectLayer); } else if (layerStrategy == GameLayers.LayerStrategy.SingleLayer) { MoveTerrainToLayer((int)GameLayers.Layer.DefaultLayer); } else { MoveTerrainToLayer((int)GameLayers.Layer.MapLayer); } }
public static void AdjustCharacterLighting(GameLayers.LayerStrategy layerStrategy) { var lights = GameObject.FindObjectsOfType(typeof(Light)) as Light[]; if (layerStrategy == GameLayers.LayerStrategy.MultiLayer) { foreach (Light light in lights) { if (light == null) { continue; } if (light.name.Contains("FaceLight")) { light.cullingMask = (int)GameLayers.LayerMask.CharaLayer; } else if (light.name.Contains("Cam Light")) { light.cullingMask = (int)GameLayers.LayerMask.CharaLayer; light.type = LightType.Point; light.intensity = 1.5f; light.range = 20; } else if (light.name.Contains("Back Light")) { light.cullingMask = (int)GameLayers.LayerMask.CharaLayer; light.type = LightType.Spot; light.intensity = 1.5f; light.range = 20; light.spotAngle = 90; light.transform.localEulerAngles = Vector3.zero; } else if (light.name.Contains("Directional Light Dummy")) { light.cullingMask = (int)GameLayers.LayerMask.None; } } } else { foreach (Light light in lights) { if (light == null) { continue; } if (light.name.Contains("FaceLight")) { light.cullingMask = -956304089; } else if (light.name.Contains("Cam Light")) { light.cullingMask = -529271514; light.type = LightType.Directional; light.intensity = 0.55f; light.range = 29.95f; } else if (light.name.Contains("Back Light")) { light.cullingMask = -462162649; light.type = LightType.Directional; light.intensity = 0.5f; light.range = 10; light.spotAngle = 30; light.transform.localEulerAngles = new Vector3(355.7f, 180f, 0); } else if (light.name.Contains("Directional Light Dummy")) { light.cullingMask = 72053030; } } } }
public static void InitializeWorldOptimizations(float detailDistance, bool castShadows, GameLayers.LayerStrategy layerStrategy, bool drawTrees, LightShadows spotLightShadows, LightShadows pointLightShadows, bool enableCityPointLights, float citySpotLightIntensity, AnimatorCullingMode cullingMode) { terrain = GetTerrain(); if (terrain == null) { return; } SetTerrainDetailDistance(detailDistance); SetTerrainShadows(castShadows); EnableTreeRendering(drawTrees); AdjustTerrainLayer(layerStrategy); AdjustCullingMasks(layerStrategy); SetCityLightShadows(spotLightShadows, pointLightShadows); EnableCityPointLights(enableCityPointLights); SetCitySpotLightIntensity(citySpotLightIntensity); UpdateAnimatorCulling(cullingMode); }
private static void UpdateHousingRendererLayers(GameLayers.LayerStrategy layerStrategy, double largeLayerThreshold, double smallLayerThreshold) { List <Renderer> housingRenders = BuildRendererList(); if (housingRenders.IsNullOrEmpty()) { return; } if (layerStrategy == GameLayers.LayerStrategy.MultiLayer) { foreach (var housingRenderer in housingRenders) { if (housingRenderer.gameObject.layer != (int)GameLayers.Layer.MapLayer && housingRenderer.gameObject.layer != (int)GameLayers.Layer.DefaultLayer) { continue; } double rendererFaceSize = housingRenderer.bounds.extents.y * housingRenderer.bounds.extents.y * Math.Sqrt((housingRenderer.bounds.extents.x * housingRenderer.bounds.extents.x) + (housingRenderer.bounds.extents.z * housingRenderer.bounds.extents.z)); if (housingRenderer.name.Contains("house") || rendererFaceSize >= largeLayerThreshold) { housingRenderer.gameObject.layer = (int)GameLayers.Layer.LargeObjectLayer; } else if (rendererFaceSize <= smallLayerThreshold) { housingRenderer.gameObject.layer = (int)GameLayers.Layer.SmallObjectLayer; } else { housingRenderer.gameObject.layer = (int)GameLayers.Layer.MediumObjectLayer; } } } else if (layerStrategy == GameLayers.LayerStrategy.SingleLayer) { foreach (var housingRenderer in housingRenders) { if (housingRenderer.gameObject.layer == (int)GameLayers.Layer.LargeObjectLayer || housingRenderer.gameObject.layer == (int)GameLayers.Layer.SmallObjectLayer || housingRenderer.gameObject.layer == (int)GameLayers.Layer.MediumObjectLayer || housingRenderer.gameObject.layer == (int)GameLayers.Layer.MapLayer) { housingRenderer.gameObject.layer = (int)GameLayers.Layer.DefaultLayer; } } } else { foreach (var housingRenderer in housingRenders) { if (housingRenderer.gameObject.layer == (int)GameLayers.Layer.LargeObjectLayer || housingRenderer.gameObject.layer == (int)GameLayers.Layer.SmallObjectLayer || housingRenderer.gameObject.layer == (int)GameLayers.Layer.MediumObjectLayer || housingRenderer.gameObject.layer == (int)GameLayers.Layer.DefaultLayer) { housingRenderer.gameObject.layer = (int)GameLayers.Layer.MapLayer; } } } }
public static void UpdateHousingLayers(GameLayers.LayerStrategy layerStrategy, double largeLayerThreshold = 1000, double smallLayerThreshold = 100) { UpdateHousingRendererLayers(layerStrategy, largeLayerThreshold, smallLayerThreshold); UpdateHousingLightLayers(layerStrategy); }
public static void InitializeHousingOptimizations(GameObject player, Camera camera, float footStepRange, float cameraColliderRange, float particleRange, AnimatorCullingMode cullingMode, GameLayers.LayerStrategy layerStrategy, double largeLayerThreshold, double smallLayerThreshold, float heightLimit) { _playerObject = player; _playerCamera = camera; SetDetectionRanges(footStepRange, cameraColliderRange, particleRange); BuildHousingOptimizationLists(); UpdateAnimatorCulling(cullingMode); UpdateHousingLayers(layerStrategy, largeLayerThreshold, smallLayerThreshold); UpdateHousingShadows(heightLimit); }