Example #1
0
 public Scatterable(ScatterableDef def, Vector3 loc, Map map)
 {
     this.def      = def;
     this.loc      = loc;
     this.map      = map;
     this.size     = Rand.Range(def.minSize, def.maxSize);
     this.rotation = Rand.Range(0f, 360f);
 }
Example #2
0
        public override void Regenerate()
        {
            base.ClearSubMeshes(MeshParts.All);
            this.scats.RemoveAll((Scatterable scat) => !scat.IsOnValidTerrain);
            int num = 0;

            TerrainDef[] topGrid     = base.Map.terrainGrid.topGrid;
            CellRect     cellRect    = base.section.CellRect;
            CellIndices  cellIndices = base.Map.cellIndices;

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    if (topGrid[cellIndices.CellToIndex(j, i)].scatterType != null)
                    {
                        num++;
                    }
                }
            }
            num /= 40;
            int num2 = 0;

            while (this.scats.Count < num && num2 < 200)
            {
                num2++;
                IntVec3        randomCell   = base.section.CellRect.RandomCell;
                string         terrScatType = base.Map.terrainGrid.TerrainAt(randomCell).scatterType;
                ScatterableDef def2         = default(ScatterableDef);
                if (terrScatType != null && !randomCell.Filled(base.Map) && (from def in DefDatabase <ScatterableDef> .AllDefs
                                                                             where def.scatterType == terrScatType
                                                                             select def).TryRandomElement <ScatterableDef>(out def2))
                {
                    Vector3     loc         = new Vector3((float)randomCell.x + Rand.Value, (float)randomCell.y, (float)randomCell.z + Rand.Value);
                    Scatterable scatterable = new Scatterable(def2, loc, base.Map);
                    this.scats.Add(scatterable);
                    scatterable.PrintOnto(this);
                }
            }
            for (int k = 0; k < this.scats.Count; k++)
            {
                this.scats[k].PrintOnto(this);
            }
            base.FinalizeMesh(MeshParts.All);
        }
Example #3
0
 internal bool <> m__0(ScatterableDef def)
 {
     return(def.scatterType == this.terrScatType);
 }