示例#1
0
 public void ConstructComponents()
 {
     this.spawnedThings      = new ThingOwner <Thing>(this);
     this.cellIndices        = new CellIndices(this);
     this.listerThings       = new ListerThings(ListerThingsUse.Global);
     this.listerBuildings    = new ListerBuildings();
     this.mapPawns           = new MapPawns(this);
     this.dynamicDrawManager = new DynamicDrawManager(this);
     this.mapDrawer          = new MapDrawer(this);
     this.tooltipGiverList   = new TooltipGiverList();
     this.pawnDestinationReservationManager = new PawnDestinationReservationManager();
     this.reservationManager = new ReservationManager(this);
     this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager();
     this.designationManager             = new DesignationManager(this);
     this.lordManager                    = new LordManager(this);
     this.debugDrawer                    = new DebugCellDrawer();
     this.passingShipManager             = new PassingShipManager(this);
     this.haulDestinationManager         = new HaulDestinationManager(this);
     this.gameConditionManager           = new GameConditionManager(this);
     this.weatherManager                 = new WeatherManager(this);
     this.zoneManager                    = new ZoneManager(this);
     this.resourceCounter                = new ResourceCounter(this);
     this.mapTemperature                 = new MapTemperature(this);
     this.temperatureCache               = new TemperatureCache(this);
     this.areaManager                    = new AreaManager(this);
     this.attackTargetsCache             = new AttackTargetsCache(this);
     this.attackTargetReservationManager = new AttackTargetReservationManager(this);
     this.lordsStarter                   = new VoluntarilyJoinableLordsStarter(this);
     this.thingGrid                  = new ThingGrid(this);
     this.coverGrid                  = new CoverGrid(this);
     this.edificeGrid                = new EdificeGrid(this);
     this.blueprintGrid              = new BlueprintGrid(this);
     this.fogGrid                    = new FogGrid(this);
     this.glowGrid                   = new GlowGrid(this);
     this.regionGrid                 = new RegionGrid(this);
     this.terrainGrid                = new TerrainGrid(this);
     this.pathGrid                   = new PathGrid(this);
     this.roofGrid                   = new RoofGrid(this);
     this.fertilityGrid              = new FertilityGrid(this);
     this.snowGrid                   = new SnowGrid(this);
     this.deepResourceGrid           = new DeepResourceGrid(this);
     this.exitMapGrid                = new ExitMapGrid(this);
     this.linkGrid                   = new LinkGrid(this);
     this.glowFlooder                = new GlowFlooder(this);
     this.powerNetManager            = new PowerNetManager(this);
     this.powerNetGrid               = new PowerNetGrid(this);
     this.regionMaker                = new RegionMaker(this);
     this.pathFinder                 = new PathFinder(this);
     this.pawnPathPool               = new PawnPathPool(this);
     this.regionAndRoomUpdater       = new RegionAndRoomUpdater(this);
     this.regionLinkDatabase         = new RegionLinkDatabase();
     this.moteCounter                = new MoteCounter();
     this.gatherSpotLister           = new GatherSpotLister();
     this.windManager                = new WindManager(this);
     this.listerBuildingsRepairable  = new ListerBuildingsRepairable();
     this.listerHaulables            = new ListerHaulables(this);
     this.listerMergeables           = new ListerMergeables(this);
     this.listerFilthInHomeArea      = new ListerFilthInHomeArea(this);
     this.reachability               = new Reachability(this);
     this.itemAvailability           = new ItemAvailability(this);
     this.autoBuildRoofAreaSetter    = new AutoBuildRoofAreaSetter(this);
     this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this);
     this.roofCollapseBuffer         = new RoofCollapseBuffer();
     this.wildAnimalSpawner          = new WildAnimalSpawner(this);
     this.wildPlantSpawner           = new WildPlantSpawner(this);
     this.steadyEnvironmentEffects   = new SteadyEnvironmentEffects(this);
     this.skyManager                 = new SkyManager(this);
     this.overlayDrawer              = new OverlayDrawer();
     this.floodFiller                = new FloodFiller(this);
     this.weatherDecider             = new WeatherDecider(this);
     this.fireWatcher                = new FireWatcher(this);
     this.dangerWatcher              = new DangerWatcher(this);
     this.damageWatcher              = new DamageWatcher();
     this.strengthWatcher            = new StrengthWatcher(this);
     this.wealthWatcher              = new WealthWatcher(this);
     this.regionDirtyer              = new RegionDirtyer(this);
     this.cellsInRandomOrder         = new MapCellsInRandomOrder(this);
     this.rememberedCameraPos        = new RememberedCameraPos(this);
     this.mineStrikeManager          = new MineStrikeManager();
     this.storyState                 = new StoryState(this);
     this.retainedCaravanData        = new RetainedCaravanData(this);
     this.components.Clear();
     this.FillComponents();
 }
        public override void Regenerate()
        {
            ClearSubMeshes(MeshParts.All);
            TerrainGrid terrainGrid = base.Map.terrainGrid;
            CellRect    cellRect    = section.CellRect;

            TerrainDef[]         array   = new TerrainDef[8];
            HashSet <TerrainDef> hashSet = new HashSet <TerrainDef>();

            bool[] array2 = new bool[8];
            foreach (IntVec3 item in cellRect)
            {
                hashSet.Clear();
                TerrainDef   terrainDef = terrainGrid.TerrainAt(item);
                LayerSubMesh subMesh    = GetSubMesh(GetMaterialFor(terrainDef));
                if (subMesh != null && AllowRenderingFor(terrainDef))
                {
                    int count = subMesh.verts.Count;
                    subMesh.verts.Add(new Vector3(item.x, 0f, item.z));
                    subMesh.verts.Add(new Vector3(item.x, 0f, item.z + 1));
                    subMesh.verts.Add(new Vector3(item.x + 1, 0f, item.z + 1));
                    subMesh.verts.Add(new Vector3(item.x + 1, 0f, item.z));
                    subMesh.colors.Add(ColorWhite);
                    subMesh.colors.Add(ColorWhite);
                    subMesh.colors.Add(ColorWhite);
                    subMesh.colors.Add(ColorWhite);
                    subMesh.tris.Add(count);
                    subMesh.tris.Add(count + 1);
                    subMesh.tris.Add(count + 2);
                    subMesh.tris.Add(count);
                    subMesh.tris.Add(count + 2);
                    subMesh.tris.Add(count + 3);
                }
                for (int i = 0; i < 8; i++)
                {
                    IntVec3 c = item + GenAdj.AdjacentCellsAroundBottom[i];
                    if (!c.InBounds(base.Map))
                    {
                        array[i] = terrainDef;
                        continue;
                    }
                    TerrainDef terrainDef2 = terrainGrid.TerrainAt(c);
                    Thing      edifice     = c.GetEdifice(base.Map);
                    if (edifice != null && edifice.def.coversFloor)
                    {
                        terrainDef2 = TerrainDefOf.Underwall;
                    }
                    array[i] = terrainDef2;
                    if (terrainDef2 != terrainDef && terrainDef2.edgeType != 0 && terrainDef2.renderPrecedence >= terrainDef.renderPrecedence && !hashSet.Contains(terrainDef2))
                    {
                        hashSet.Add(terrainDef2);
                    }
                }
                foreach (TerrainDef item2 in hashSet)
                {
                    LayerSubMesh subMesh2 = GetSubMesh(GetMaterialFor(item2));
                    if (subMesh2 == null || !AllowRenderingFor(item2))
                    {
                        continue;
                    }
                    int count = subMesh2.verts.Count;
                    subMesh2.verts.Add(new Vector3((float)item.x + 0.5f, 0f, item.z));
                    subMesh2.verts.Add(new Vector3(item.x, 0f, item.z));
                    subMesh2.verts.Add(new Vector3(item.x, 0f, (float)item.z + 0.5f));
                    subMesh2.verts.Add(new Vector3(item.x, 0f, item.z + 1));
                    subMesh2.verts.Add(new Vector3((float)item.x + 0.5f, 0f, item.z + 1));
                    subMesh2.verts.Add(new Vector3(item.x + 1, 0f, item.z + 1));
                    subMesh2.verts.Add(new Vector3(item.x + 1, 0f, (float)item.z + 0.5f));
                    subMesh2.verts.Add(new Vector3(item.x + 1, 0f, item.z));
                    subMesh2.verts.Add(new Vector3((float)item.x + 0.5f, 0f, (float)item.z + 0.5f));
                    for (int j = 0; j < 8; j++)
                    {
                        array2[j] = false;
                    }
                    for (int k = 0; k < 8; k++)
                    {
                        if (k % 2 == 0)
                        {
                            if (array[k] == item2)
                            {
                                array2[(k - 1 + 8) % 8] = true;
                                array2[k]           = true;
                                array2[(k + 1) % 8] = true;
                            }
                        }
                        else if (array[k] == item2)
                        {
                            array2[k] = true;
                        }
                    }
                    for (int l = 0; l < 8; l++)
                    {
                        if (array2[l])
                        {
                            subMesh2.colors.Add(ColorWhite);
                        }
                        else
                        {
                            subMesh2.colors.Add(ColorClear);
                        }
                    }
                    subMesh2.colors.Add(ColorClear);
                    for (int m = 0; m < 8; m++)
                    {
                        subMesh2.tris.Add(count + m);
                        subMesh2.tris.Add(count + (m + 1) % 8);
                        subMesh2.tris.Add(count + 8);
                    }
                }
            }
            FinalizeMesh(MeshParts.All);
        }