public static bool Prefix(ref InstanceRenderer __instance) { Camera mainCamera = Utils.GetMainCamera(); if (__instance.m_instanceCount == 0 || mainCamera == null) { return(false); } if (__instance.m_frustumCull) { if (__instance.m_dirtyBounds) { __instance.UpdateBounds(); } if (!Utils.InsideMainCamera(__instance.m_bounds)) { return(false); } } Graphics.DrawMeshInstanced(__instance.m_mesh, 0, __instance.m_material, __instance.m_instances, __instance.m_instanceCount, null, __instance.m_shadowCasting); // Skip original code. return(false); }
void Update() { //TODO: instance render each type of unit and landmark UpdateUnitData(enemyUnitData); for (int i = 0; i < enemyUnitData.Length; i++) { InstanceRenderer.Render(enemyUnitData[i].mesh, enemyUnitData[i].material, enemyUnitData[i].transforms, enemyUnitData[i].activeCount); } }
static void Postfix(InstanceRenderer __instance) { if (!modEnabled.Value) { return; } __instance.m_lodMinDistance *= lodMinDistanceMult.Value; __instance.m_lodMaxDistance *= lodMaxDistanceMult.Value; __instance.m_shadowCasting = shadowCastingMode.Value; __instance.m_useLod = useLod.Value; __instance.m_useXZLodDistance = useXZLodDistance.Value; }
static void Prefix(InstanceRenderer __instance) { __instance.m_lodMaxDistance = 1000; }
// Token: 0x06000CA0 RID: 3232 RVA: 0x0005A324 File Offset: 0x00058524 private ClutterSystem.PatchData GenerateVegPatch(Vector2Int patchID, float size) { Vector3 vegPatchCenter = this.GetVegPatchCenter(patchID); float num = size / 2f; Heightmap.Biome patchBiomes = this.GetPatchBiomes(vegPatchCenter, num); if (patchBiomes == Heightmap.Biome.None) { return(null); } float realtimeSinceStartup = Time.realtimeSinceStartup; UnityEngine.Random.State state = UnityEngine.Random.state; ClutterSystem.PatchData patchData = this.AllocatePatch(); patchData.center = vegPatchCenter; for (int i = 0; i < this.m_clutter.Count; i++) { ClutterSystem.Clutter clutter = this.m_clutter[i]; if (clutter.m_enabled && (patchBiomes & clutter.m_biome) != Heightmap.Biome.None) { InstanceRenderer instanceRenderer = null; UnityEngine.Random.InitState(patchID.x * (patchID.y * 1374) + i * 9321); Vector3 b = new Vector3(clutter.m_fractalOffset, 0f, 0f); float num2 = Mathf.Cos(0.017453292f * clutter.m_maxTilt); int num3 = (this.m_quality == ClutterSystem.Quality.High) ? clutter.m_amount : (clutter.m_amount / 2); num3 = (int)((float)num3 * this.m_amountScale); int j = 0; while (j < num3) { Vector3 vector = new Vector3(UnityEngine.Random.Range(vegPatchCenter.x - num, vegPatchCenter.x + num), 0f, UnityEngine.Random.Range(vegPatchCenter.z - num, vegPatchCenter.z + num)); float num4 = (float)UnityEngine.Random.Range(0, 360); if (!clutter.m_inForest) { goto IL_161; } float forestFactor = WorldGenerator.GetForestFactor(vector); if (forestFactor >= clutter.m_forestTresholdMin && forestFactor <= clutter.m_forestTresholdMax) { goto IL_161; } IL_3D5: j++; continue; IL_161: if (clutter.m_fractalScale > 0f) { float num5 = Utils.Fbm(vector * 0.01f * clutter.m_fractalScale + b, 3, 1.6f, 0.7f); if (num5 < clutter.m_fractalTresholdMin || num5 > clutter.m_fractalTresholdMax) { goto IL_3D5; } } Vector3 vector2; Vector3 vector3; Heightmap heightmap; Heightmap.Biome biome; if (!this.GetGroundInfo(vector, out vector2, out vector3, out heightmap, out biome) || (clutter.m_biome & biome) == Heightmap.Biome.None) { goto IL_3D5; } float num6 = vector2.y - this.m_waterLevel; if (num6 < clutter.m_minAlt || num6 > clutter.m_maxAlt || vector3.y < num2) { goto IL_3D5; } if (clutter.m_minOceanDepth != clutter.m_maxOceanDepth) { float oceanDepth = heightmap.GetOceanDepth(vector); if (oceanDepth < clutter.m_minOceanDepth || oceanDepth > clutter.m_maxOceanDepth) { goto IL_3D5; } } if (!clutter.m_onCleared || !clutter.m_onUncleared) { bool flag = heightmap.IsCleared(vector2); if ((clutter.m_onCleared && !flag) || (clutter.m_onUncleared && flag)) { goto IL_3D5; } } vector = vector2; if (clutter.m_snapToWater) { vector.y = this.m_waterLevel; } if (clutter.m_randomOffset != 0f) { vector.y += UnityEngine.Random.Range(-clutter.m_randomOffset, clutter.m_randomOffset); } Quaternion quaternion = Quaternion.identity; if (clutter.m_terrainTilt) { quaternion = Quaternion.AngleAxis(num4, vector3); } else { quaternion = Quaternion.Euler(0f, num4, 0f); } if (clutter.m_instanced) { if (instanceRenderer == null) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(clutter.m_prefab, vegPatchCenter, Quaternion.identity, this.m_grassRoot.transform); instanceRenderer = gameObject.GetComponent <InstanceRenderer>(); if (instanceRenderer.m_lodMaxDistance > this.m_distance - this.m_grassPatchSize / 2f) { instanceRenderer.m_lodMaxDistance = this.m_distance - this.m_grassPatchSize / 2f; } patchData.m_objects.Add(gameObject); } float scale = UnityEngine.Random.Range(clutter.m_scaleMin, clutter.m_scaleMax); instanceRenderer.AddInstance(vector, quaternion, scale); goto IL_3D5; } GameObject item = UnityEngine.Object.Instantiate <GameObject>(clutter.m_prefab, vector, quaternion, this.m_grassRoot.transform); patchData.m_objects.Add(item); goto IL_3D5; } } } UnityEngine.Random.state = state; return(patchData); }