// Token: 0x06000CD7 RID: 3287 RVA: 0x0005E72C File Offset: 0x0005CB2C public void addCut(IShapeVolume cut) { this.cuts.Add(cut); if (!this.hasInstances) { return; } foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in this.instances) { FoliageInstanceList value = keyValuePair.Value; for (int i = 0; i < value.matrices.Count; i++) { List <Matrix4x4> list = value.matrices[i]; List <bool> list2 = value.clearWhenBaked[i]; for (int j = list.Count - 1; j >= 0; j--) { if (cut.containsPoint(list[j].GetPosition())) { list.RemoveAt(j); list2.RemoveAt(j); } } } } }
// Token: 0x06000CE5 RID: 3301 RVA: 0x0005F0E8 File Offset: 0x0005D4E8 protected void updateBounds() { if (this.hasInstances) { float num = Landscape.TILE_HEIGHT; float num2 = -Landscape.TILE_HEIGHT; foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in this.instances) { FoliageInstanceList value = keyValuePair.Value; foreach (List <Matrix4x4> list in value.matrices) { foreach (Matrix4x4 matrix4x in list) { float m = matrix4x.m13; if (m < num) { num = m; } if (m > num2) { num2 = m; } } } } float num3 = num2 - num; this.worldBounds = new Bounds(new Vector3((float)this.coord.x * FoliageSystem.TILE_SIZE + FoliageSystem.TILE_SIZE / 2f, num + num3 / 2f, (float)this.coord.y * FoliageSystem.TILE_SIZE + FoliageSystem.TILE_SIZE / 2f), new Vector3(FoliageSystem.TILE_SIZE, num3, FoliageSystem.TILE_SIZE)); } else { this.worldBounds = new Bounds(new Vector3((float)this.coord.x * FoliageSystem.TILE_SIZE + FoliageSystem.TILE_SIZE / 2f, 0f, (float)this.coord.y * FoliageSystem.TILE_SIZE + FoliageSystem.TILE_SIZE / 2f), new Vector3(FoliageSystem.TILE_SIZE, Landscape.TILE_HEIGHT, FoliageSystem.TILE_SIZE)); } }
// Token: 0x06000CDE RID: 3294 RVA: 0x0005EA68 File Offset: 0x0005CE68 public void applyScale() { foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in this.instances) { FoliageInstanceList value = keyValuePair.Value; value.applyScale(); } }
// Token: 0x06000CDD RID: 3293 RVA: 0x0005EA04 File Offset: 0x0005CE04 public void clearGeneratedInstances() { foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in this.instances) { FoliageInstanceList value = keyValuePair.Value; value.clearGeneratedInstances(); } }
// Token: 0x06000CDB RID: 3291 RVA: 0x0005E931 File Offset: 0x0005CD31 public void removeInstance(FoliageInstanceList list, int matricesIndex, int matrixIndex) { if (!this.hasInstances) { return; } list.removeInstance(matricesIndex, matrixIndex); this.canSafelyClear = false; }
// Token: 0x06000CC1 RID: 3265 RVA: 0x0005E02C File Offset: 0x0005C42C public static void drawTile(FoliageTile tile, int sqrDistance, float density, Camera camera) { if (tile == null) { return; } if (tile.hasInstances) { foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in tile.instances) { FoliageInstanceList value = keyValuePair.Value; value.loadAsset(); Mesh mesh = value.mesh; if (!(mesh == null)) { Material material = value.material; if (!(material == null)) { bool castShadows = value.castShadows; if (!value.tileDither) { density = 1f; } density *= FoliageSettings.instanceDensity; if (value.sqrDrawDistance == -1 || sqrDistance <= value.sqrDrawDistance) { if (FoliageSettings.forceInstancingOff || !SystemInfo.supportsInstancing) { foreach (List <Matrix4x4> list in value.matrices) { int num = Mathf.RoundToInt((float)list.Count * density); for (int i = 0; i < num; i++) { Graphics.DrawMesh(mesh, list[i], material, LayerMasks.ENVIRONMENT, camera, 0, null, castShadows, true); } } } else { ShadowCastingMode castShadows2 = (!castShadows) ? ShadowCastingMode.Off : ShadowCastingMode.On; foreach (List <Matrix4x4> list2 in value.matrices) { int count = Mathf.RoundToInt((float)list2.Count * density); Graphics.DrawMeshInstanced(mesh, 0, material, list2.GetInternalArray <Matrix4x4>(), count, null, castShadows2, true, LayerMasks.ENVIRONMENT, camera); } } } } } } } else { tile.readInstancesJob(); } }
// Token: 0x06000CDA RID: 3290 RVA: 0x0005E8F0 File Offset: 0x0005CCF0 public void addInstance(FoliageInstanceGroup instance) { if (!this.hasInstances) { return; } FoliageInstanceList orAddList = this.getOrAddList(this.instances, instance.assetReference); orAddList.addInstanceRandom(instance); this.updateBounds(); this.canSafelyClear = false; }
// Token: 0x06000CDC RID: 3292 RVA: 0x0005E950 File Offset: 0x0005CD50 public void clearInstances() { this.hasInstances = false; if (this.instances.Count > 0) { object typeFromHandle = typeof(PoolablePool <FoliageInstanceList>); lock (typeFromHandle) { foreach (KeyValuePair <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> keyValuePair in this.instances) { FoliageInstanceList value = keyValuePair.Value; PoolablePool <FoliageInstanceList> .release(value); } } } this.instances = null; this.isReadingInstances = false; }
// Token: 0x06000CE2 RID: 3298 RVA: 0x0005EBB4 File Offset: 0x0005CFB4 protected virtual void readInstances(object stateInfo) { Dictionary <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList> source = new Dictionary <AssetReference <FoliageInstancedMeshInfoAsset>, FoliageInstanceList>(); string path = string.Concat(new object[] { Level.info.path, "/Foliage/Tile_", this.coord.x, "_", this.coord.y, ".foliage" }); if (File.Exists(path)) { using (FileStream fileStream = new FileStream(path, FileMode.Open)) { BinaryReader binaryReader = new BinaryReader(fileStream); int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); for (int i = 0; i < num2; i++) { GuidBuffer guidBuffer = default(GuidBuffer); object guid_BUFFER = GuidBuffer.GUID_BUFFER; lock (guid_BUFFER) { fileStream.Read(GuidBuffer.GUID_BUFFER, 0, 16); guidBuffer.Read(GuidBuffer.GUID_BUFFER, 0); } AssetReference <FoliageInstancedMeshInfoAsset> assetReference = new AssetReference <FoliageInstancedMeshInfoAsset>(guidBuffer.GUID); FoliageInstanceList orAddList = this.getOrAddList(source, assetReference); int num3 = binaryReader.ReadInt32(); for (int j = 0; j < num3; j++) { Matrix4x4 matrix4x = default(Matrix4x4); for (int k = 0; k < 16; k++) { matrix4x[k] = binaryReader.ReadSingle(); } bool newClearWhenBaked = num <= 2 || binaryReader.ReadBoolean(); if (!this.isInstanceCut(matrix4x.GetPosition())) { orAddList.addInstanceAppend(new FoliageInstanceGroup(assetReference, matrix4x, newClearWhenBaked)); } } } } } object obj = this.thisLock; lock (obj) { if (!this.hasInstances) { this.instances = source; this.updateBounds(); this.hasInstances = true; this.isReadingInstances = false; } } }