Exemplo n.º 1
0
        private static readonly IntVec2 TexturesInAtlas = new IntVec2(2, 2); // two by two, meaning four variants for each worldmaterial.
        public override IEnumerable Regenerate()
        {
            foreach (object obj in base.Regenerate())             // I'll be honest, I don't know what this does.
            {
                yield return(obj);
            }
            Rand.PushState();
            Rand.Seed = Find.World.info.Seed;
            WorldGrid       worldGrid             = Find.WorldGrid;
            List <BiomeDef> allDefsListForReading = DefDatabase <BiomeDef> .AllDefsListForReading;

            foreach (BiomeDef biomeDef in allDefsListForReading.Where(x => x.HasModExtension <BiomesKitControls>()))
            {
                for (int tileID = 0; tileID < Find.WorldGrid.TilesCount; tileID++)
                {
                    Tile tile = Find.WorldGrid[tileID];
                    BiomesKitControls biomesKit = biomeDef.GetModExtension <BiomesKitControls>();
                    if (tile.biome != biomeDef)
                    {
                        continue;
                    }
                    if (biomesKit.materialPath == "World/MapGraphics/Default")
                    {
                        continue;
                    }
                    Material     material = MaterialPool.MatFrom(biomesKit.materialPath, ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                    LayerSubMesh subMesh  = GetSubMesh(material);
                    Vector3      vector   = worldGrid.GetTileCenter(tileID);
                    WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, worldGrid.averageTileSize, 0.01f, subMesh, false, true, false);
                    WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMesh);
                }
            }
            Rand.PopState();
            base.FinalizeMesh(MeshParts.All);
            yield break;
        }
Exemplo n.º 2
0
 public void TargeterUpdate()
 {
     if (this.IsTargeting)
     {
         Vector3          pos = Vector3.zero;
         GlobalTargetInfo globalTargetInfo = this.CurrentTargetUnderMouse();
         if (globalTargetInfo.HasWorldObject)
         {
             pos = globalTargetInfo.WorldObject.DrawPos;
         }
         else if (globalTargetInfo.Tile >= 0)
         {
             pos = Find.WorldGrid.GetTileCenter(globalTargetInfo.Tile);
         }
         if (globalTargetInfo.IsValid && !Mouse.IsInputBlockedNow)
         {
             WorldRendererUtility.DrawQuadTangentialToPlanet(pos, 0.8f * Find.WorldGrid.averageTileSize, 0.018f, WorldMaterials.CurTargetingMat, false, false, null);
         }
         if (this.onUpdate != null)
         {
             this.onUpdate();
         }
     }
 }
Exemplo n.º 3
0
        // Token: 0x06000009 RID: 9 RVA: 0x000023E0 File Offset: 0x000005E0
        public override void Print(LayerSubMesh subMesh)
        {
            float averageTileSize = Find.WorldGrid.averageTileSize;

            WorldRendererUtility.PrintQuadTangentialToPlanet(this.DrawPos, 10.7f * averageTileSize, 0.008f, subMesh, false, false, true);
        }
Exemplo n.º 4
0
        public override void TargeterUpdate()
        {
            if (IsTargeting)
            {
                DrawAirDefenseGrid();
                if (aerialVehicle != null)
                {
                    originOnMap = aerialVehicle.DrawPos;
                }
                Vector3          pos = Vector3.zero;
                GlobalTargetInfo arg = CurrentTargetUnderMouse();
                if (arg.HasWorldObject)
                {
                    pos = arg.WorldObject.DrawPos;
                }
                else if (arg.Tile >= 0)
                {
                    pos = Find.WorldGrid.GetTileCenter(arg.Tile);
                }
                if (arg.IsValid && !Mouse.IsInputBlockedNow)
                {
                    if (vehicle.CompVehicleLauncher.launchProtocol.GetFloatMenuOptionsAt(arg.Tile).NotNullAndAny())
                    {
                        WorldRendererUtility.DrawQuadTangentialToPlanet(pos, BaseFeedbackTexSize * Find.WorldGrid.averageTileSize, 0.018f, WorldMaterials.CurTargetingMat);
                    }
                }

                Vector3  start   = originOnMap;
                var      tiles   = new List <int>(FlightPath.Select(n => n.tile));
                Material lineMat = null;
                switch (vehicle.CompVehicleLauncher.GetShuttleStatus(arg, start))
                {
                case ShuttleLaunchStatus.Valid:
                    lineMat = TexData.WorldLineMatWhite;
                    break;

                case ShuttleLaunchStatus.NoReturnTrip:
                    lineMat = TexData.WorldLineMatYellow;
                    break;

                case ShuttleLaunchStatus.Invalid:
                    lineMat = TexData.WorldLineMatRed;
                    break;
                }
                for (int n = 0; n < FlightPath.Count; n++)
                {
                    int     curTile = tiles.PopAt(0);
                    Vector3 end     = Find.WorldGrid.GetTileCenter(curTile);
                    DrawTravelPoint(start, end, lineMat);
                    start = end;
                }
                if (FlightPath.Count > 0)
                {
                    string  destLabel       = "VehicleDoubleClickShuttleTarget".Translate();
                    Vector2 labelGetterText = Text.CalcSize(destLabel);
                    Rect    destPosition    = new Rect(start.x, start.y, 32f, 32f);
                    Rect    rect            = new Rect(destPosition.xMax, destPosition.y, 9999f, 100f);
                    Rect    bgRect          = new Rect(rect.x - labelGetterText.x * 0.1f, rect.y, labelGetterText.x * 1.2f, labelGetterText.y);
                    var     textColor       = GUI.color;
                    GUI.color = Color.white;
                    Graphics.DrawTexture(bgRect, TexUI.GrayTextBG);
                    GUI.color = textColor;
                    //GUI.Label(rect, destLabel);
                    WorldRendererUtility.DrawQuadTangentialToPlanet(start, BaseFeedbackTexSize * Find.WorldGrid.averageTileSize, 0.018f, WorldMaterials.CurTargetingMat, false, false, null);
                }
                if (FlightPath.Count < vehicle.CompVehicleLauncher.launchProtocol.MaxFlightNodes && arg.IsValid)
                {
                    DrawTravelPoint(start, Find.WorldGrid.GetTileCenter(arg.Tile), lineMat);
                }

                onUpdate?.Invoke();
            }
        }
Exemplo n.º 5
0
 // Token: 0x060000D9 RID: 217 RVA: 0x00006540 File Offset: 0x00004740
 public override void Draw()
 {
     base.Comps_PostDraw();
     WorldRendererUtility.DrawQuadTangentialToPlanet(this.DrawPos, MRC(0f, (float)this.BlastRadius, 5f, 0f, (float)this.shockwave), 0.008f, GraphicDatabase.Get <Graphic_Single>("ra2/Things/Misc/Nuclear/flash", ShaderDatabase.MoteGlow, new Vector2(20f, 20f), Color.white).MatSingle, false, false, null);
 }
Exemplo n.º 6
0
        private static readonly IntVec2 TexturesInAtlas = new IntVec2(2, 2); // two by two, meaning four variants for each worldmaterial.
        public override IEnumerable Regenerate()
        {
            foreach (object obj in base.Regenerate())
            {
                yield return(obj);
            }
            Rand.PushState();
            Rand.Seed = Find.World.info.Seed;
            WorldGrid worldGrid = Find.WorldGrid;

            for (int tileID = 0; tileID < Find.WorldGrid.TilesCount; tileID++)
            {
                Tile tile = Find.WorldGrid[tileID];
                if (tile.biome.HasModExtension <BiomesKitControls>())
                {
                    Dictionary <Tile, Hilliness> backupHilliness = LateBiomeWorker.backupHilliness;
                    BiomesKitControls            biomesKit       = tile.biome.GetModExtension <BiomesKitControls>();
                    Vector3 vector = worldGrid.GetTileCenter(tileID);
                    if (biomesKit.hillMaterialPath != "World/MapGraphics/Default")
                    {
                        tile.hilliness = backupHilliness[tile];
                        Material hill;
                        if (tile.hilliness == Hilliness.SmallHills)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/SmallHills", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                        if (tile.hilliness == Hilliness.LargeHills)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/LargeHills", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                        if (tile.hilliness == Hilliness.Mountainous)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/Mountains", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                        if (tile.hilliness == Hilliness.Impassable)
                        {
                            hill = MaterialPool.MatFrom(biomesKit.hillMaterialPath + "/Hills/Impassable", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            LayerSubMesh subMeshHill = GetSubMesh(hill);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * 1.5f), 0.01f, subMeshHill, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshHill);
                        }
                    }
                    if (biomesKit.materialMaxHilliness != Hilliness.Undefined)
                    {
                        if (tile.hilliness > biomesKit.materialMaxHilliness || tile.hilliness < biomesKit.materialMinHilliness)
                        {
                            continue;
                        }
                    }
                    bool roadPresent = true;
                    if (tile.Roads == null || tile.Roads.Count == 0)
                    {
                        roadPresent = false;
                    }
                    bool riverPresent = true;
                    if (tile.Rivers == null || tile.Rivers.Count == 0)
                    {
                        riverPresent = false;
                    }
                    if (biomesKit.forestMaterialPath != "World/MapGraphics/Default")
                    {
                        if (!riverPresent && !roadPresent)
                        {
                            Material forestMaterial;
                            if (tile.temperature < biomesKit.forestSnowyBelow)
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest_Snowy", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            else if (tile.rainfall < biomesKit.forestSparseBelow)
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest_Sparse", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            else if (tile.rainfall > biomesKit.forestDenseAbove)
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest_Dense", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            else
                            {
                                forestMaterial = MaterialPool.MatFrom(biomesKit.forestMaterialPath + "/Forest", ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                            }
                            LayerSubMesh subMeshForest = GetSubMesh(forestMaterial);
                            WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * biomesKit.materialSizeMultiplier), 0.01f, subMeshForest, false, biomesKit.materialRandomRotation, false);
                            WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMeshForest);
                        }
                    }
                    if (biomesKit.materialPath != "World/MapGraphics/Default")
                    {
                        Material     material = MaterialPool.MatFrom(biomesKit.materialPath, ShaderDatabase.WorldOverlayTransparentLit, biomesKit.materialLayer);
                        LayerSubMesh subMesh  = GetSubMesh(material);
                        WorldRendererUtility.PrintQuadTangentialToPlanet(vector, vector, (worldGrid.averageTileSize * biomesKit.materialSizeMultiplier), 0.01f, subMesh, false, biomesKit.materialRandomRotation, false);
                        WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, TexturesInAtlas.x), Rand.Range(0, TexturesInAtlas.z), TexturesInAtlas.x, TexturesInAtlas.z, subMesh);
                    }
                }
            }
            Rand.PopState();
            base.FinalizeMesh(MeshParts.All);
            yield break;
        }