Ejemplo n.º 1
0
        public void UpdateFeatures()
        {
            if (!this.textsCreated)
            {
                this.textsCreated = true;
                this.CreateTextsAndSetPosition();
            }
            bool showWorldFeatures = Find.PlaySettings.showWorldFeatures;

            for (int i = 0; i < this.features.Count; i++)
            {
                Vector3 position = WorldFeatures.texts[i].transform.position;
                bool    flag     = showWorldFeatures && !WorldRendererUtility.HiddenBehindTerrainNow(position);
                if (flag != WorldFeatures.texts[i].gameObject.activeInHierarchy)
                {
                    WorldFeatures.texts[i].gameObject.SetActive(flag);
                    this.WrapAroundPlanetSurface(WorldFeatures.texts[i]);
                }
                if (flag)
                {
                    this.UpdateAlpha(WorldFeatures.texts[i], this.features[i]);
                }
            }
        }
Ejemplo n.º 2
0
        public float GetHeadingFromTo(Vector3 from, Vector3 to)
        {
            if (from == to)
            {
                return(0f);
            }
            Vector3 northPolePos = this.NorthPolePos;
            Vector3 from2;
            Vector3 rhs;

            WorldRendererUtility.GetTangentialVectorFacing(from, northPolePos, out from2, out rhs);
            Vector3 vector;
            Vector3 vector2;

            WorldRendererUtility.GetTangentialVectorFacing(from, to, out vector, out vector2);
            float num  = Vector3.Angle(from2, vector);
            float num2 = Vector3.Dot(vector, rhs);

            if (num2 < 0f)
            {
                num = 360f - num;
            }
            return(num);
        }
Ejemplo n.º 3
0
        public void UpdateFeatures()
        {
            if (!textsCreated)
            {
                textsCreated = true;
                CreateTextsAndSetPosition();
            }
            bool showWorldFeatures = Find.PlaySettings.showWorldFeatures;

            for (int i = 0; i < features.Count; i++)
            {
                Vector3 position = texts[i].Position;
                bool    flag     = showWorldFeatures && !WorldRendererUtility.HiddenBehindTerrainNow(position);
                if (flag != texts[i].Active)
                {
                    texts[i].SetActive(flag);
                    texts[i].WrapAroundPlanetSurface();
                }
                if (flag)
                {
                    UpdateAlpha(texts[i], features[i]);
                }
            }
        }
Ejemplo n.º 4
0
 public static bool HiddenBehindTerrainNow(this WorldObject o)
 {
     return(WorldRendererUtility.HiddenBehindTerrainNow(o.DrawPos));
 }
Ejemplo n.º 5
0
        public virtual void Print(LayerSubMesh subMesh)
        {
            float averageTileSize = Find.WorldGrid.averageTileSize;

            WorldRendererUtility.PrintQuadTangentialToPlanet(this.DrawPos, (float)(0.699999988079071 * averageTileSize), 0.015f, subMesh, false, true, true);
        }
Ejemplo n.º 6
0
        public virtual void Print(LayerSubMesh subMesh)
        {
            float averageTileSize = Find.WorldGrid.averageTileSize;

            WorldRendererUtility.PrintQuadTangentialToPlanet(DrawPos, 0.7f * averageTileSize, 0.015f, subMesh, counterClockwise: false, randomizeRotation: true);
        }
Ejemplo n.º 7
0
        public override IEnumerable Regenerate()
        {
            IEnumerator enumerator = this.< Regenerate > __BaseCallProxy0().GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object result = enumerator.Current;
                    yield return(result);
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            Rand.PushState();
            Rand.Seed = Find.World.info.Seed;
            WorldGrid grid       = Find.WorldGrid;
            int       tilesCount = grid.TilesCount;
            int       i          = 0;

            while (i < tilesCount)
            {
                Tile       tile = grid[i];
                Material   material;
                FloatRange floatRange;
                switch (tile.hilliness)
                {
                case Hilliness.SmallHills:
                    material   = WorldMaterials.SmallHills;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_SmallHills;
                    goto IL_185;

                case Hilliness.LargeHills:
                    material   = WorldMaterials.LargeHills;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_LargeHills;
                    goto IL_185;

                case Hilliness.Mountainous:
                    material   = WorldMaterials.Mountains;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_Mountains;
                    goto IL_185;

                case Hilliness.Impassable:
                    material   = WorldMaterials.ImpassableMountains;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_ImpassableMountains;
                    goto IL_185;
                }
IL_262:
                i++;
                continue;
IL_185:
                LayerSubMesh subMesh = base.GetSubMesh(material);
                Vector3 vector         = grid.GetTileCenter(i);
                Vector3 posForTangents = vector;
                float   magnitude      = vector.magnitude;
                vector = (vector + Rand.UnitVector3 * floatRange.RandomInRange * grid.averageTileSize).normalized * magnitude;
                WorldRendererUtility.PrintQuadTangentialToPlanet(vector, posForTangents, WorldLayer_Hills.BaseSizeRange.RandomInRange * grid.averageTileSize, 0.005f, subMesh, false, true, false);
                WorldRendererUtility.PrintTextureAtlasUVs(Rand.Range(0, WorldLayer_Hills.TexturesInAtlas.x), Rand.Range(0, WorldLayer_Hills.TexturesInAtlas.z), WorldLayer_Hills.TexturesInAtlas.x, WorldLayer_Hills.TexturesInAtlas.z, subMesh);
                goto IL_262;
            }
            Rand.PopState();
            base.FinalizeMesh(MeshParts.All);
            yield break;
        }
        public override IEnumerable Regenerate()
        {
            IEnumerator enumerator = base.Regenerate().GetEnumerator();

            try
            {
                if (enumerator.MoveNext())
                {
                    object result = enumerator.Current;
                    yield return(result);

                    /*Error: Unable to find new state assignment for yield return*/;
                }
            }
            finally
            {
                IDisposable disposable;
                IDisposable disposable2 = disposable = (enumerator as IDisposable);
                if (disposable != null)
                {
                    disposable2.Dispose();
                }
            }
            Rand.PushState();
            Rand.Seed = Find.World.info.Seed;
            WorldGrid grid       = Find.WorldGrid;
            int       tilesCount = grid.TilesCount;

            for (int i = 0; i < tilesCount; i++)
            {
                Tile         tile = grid[i];
                Material     material;
                FloatRange   floatRange;
                LayerSubMesh subMesh;
                Vector3      vector;
                Vector3      posForTangents;
                float        magnitude;
                IntVec2      texturesInAtlas;
                int          indexX;
                IntVec2      texturesInAtlas2;
                int          indexY;
                IntVec2      texturesInAtlas3;
                int          x;
                IntVec2      texturesInAtlas4;
                switch (tile.hilliness)
                {
                case Hilliness.SmallHills:
                    material   = WorldMaterials.SmallHills;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_SmallHills;
                    goto IL_0180;

                case Hilliness.LargeHills:
                    material   = WorldMaterials.LargeHills;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_LargeHills;
                    goto IL_0180;

                case Hilliness.Mountainous:
                    material   = WorldMaterials.Mountains;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_Mountains;
                    goto IL_0180;

                case Hilliness.Impassable:
                {
                    material   = WorldMaterials.ImpassableMountains;
                    floatRange = WorldLayer_Hills.BasePosOffsetRange_ImpassableMountains;
                    goto IL_0180;
                }
IL_0180:
                    subMesh        = base.GetSubMesh(material);
                    vector         = grid.GetTileCenter(i);
                    posForTangents = vector;
                    magnitude      = vector.magnitude;
                    vector        += Rand.UnitVector3 * floatRange.RandomInRange * grid.averageTileSize;
                    vector         = vector.normalized * magnitude;
                    WorldRendererUtility.PrintQuadTangentialToPlanet(vector, posForTangents, WorldLayer_Hills.BaseSizeRange.RandomInRange * grid.averageTileSize, 0.005f, subMesh, false, true, false);
                    texturesInAtlas  = WorldLayer_Hills.TexturesInAtlas;
                    indexX           = Rand.Range(0, texturesInAtlas.x);
                    texturesInAtlas2 = WorldLayer_Hills.TexturesInAtlas;
                    indexY           = Rand.Range(0, texturesInAtlas2.z);
                    texturesInAtlas3 = WorldLayer_Hills.TexturesInAtlas;
                    x = texturesInAtlas3.x;
                    texturesInAtlas4 = WorldLayer_Hills.TexturesInAtlas;
                    WorldRendererUtility.PrintTextureAtlasUVs(indexX, indexY, x, texturesInAtlas4.z, subMesh);
                    break;
                }
            }
            Rand.PopState();
            base.FinalizeMesh(MeshParts.All);
            yield break;
IL_0287:
            /*Error near IL_0288: Unexpected return in MoveNext()*/;
        }
 public static void PrintQuadTangentialToPlanet(Vector3 pos, float size, float altOffset, LayerSubMesh subMesh, bool counterClockwise = false, bool randomizeRotation = false, bool printUVs = true)
 {
     WorldRendererUtility.PrintQuadTangentialToPlanet(pos, pos, size, altOffset, subMesh, counterClockwise, randomizeRotation, printUVs);
 }