Ejemplo n.º 1
0
    public void SetSplat(Vector3 worldPos, int id, float opacity, float radius, float fade = 0f)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        this.SetSplat(single, single1, id, opacity, radius, fade);
    }
Ejemplo n.º 2
0
    public void AddSplat(Vector3 worldPos, int id, float delta, float radius, float fade = 0f)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        this.AddSplat(single, single1, id, delta, radius, fade);
    }
Ejemplo n.º 3
0
    public void SetSplat(Vector3 worldPos, int id, float v)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        this.SetSplat(single, single1, id, v);
    }
Ejemplo n.º 4
0
    public Color GetColor(Vector3 worldPos, int mask = -1)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        return(this.GetColor(single, single1, mask));
    }
Ejemplo n.º 5
0
    public void SetAlpha(Vector3 worldPos, float a, float opacity, float radius, float fade = 0f)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        this.SetAlpha(single, single1, a, opacity, radius, fade);
    }
    public void SetHeight(Vector3 worldPos, float height, float opacity)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        this.SetHeight(single, single1, height, opacity);
    }
    public override void Process()
    {
        RaycastHit raycastHit;
        Collider   component = base.GetComponent <Collider>();
        Bounds     bound     = component.bounds;
        int        num       = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeX(bound.min.x));
        int        num1      = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeZ(bound.max.x));
        int        num2      = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeX(bound.min.z));
        int        num3      = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeZ(bound.max.z));

        for (int i = num2; i <= num3; i++)
        {
            float single = TerrainMeta.HeightMap.Coordinate(i);
            for (int j = num; j <= num1; j++)
            {
                float   single1 = TerrainMeta.HeightMap.Coordinate(j);
                Vector3 vector3 = new Vector3(TerrainMeta.DenormalizeX(single1), bound.max.y, TerrainMeta.DenormalizeZ(single));
                Ray     ray     = new Ray(vector3, Vector3.down);
                if (component.Raycast(ray, out raycastHit, bound.size.y))
                {
                    float single2 = TerrainMeta.NormalizeY(raycastHit.point.y);
                    if (single2 > TerrainMeta.HeightMap.GetHeight01(j, i))
                    {
                        TerrainMeta.HeightMap.SetHeight(j, i, single2);
                    }
                }
            }
        }
        GameManager.Destroy(this, 0f);
    }
Ejemplo n.º 8
0
    public float GetSplat(Vector3 worldPos, int mask)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        return(this.GetSplat(single, single1, mask));
    }
Ejemplo n.º 9
0
    public int GetBiomeMaxIndex(Vector3 worldPos, int mask = -1)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);

        return(this.GetBiomeMaxIndex(single, single1, mask));
    }
Ejemplo n.º 10
0
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        Vector3          position1 = TerrainMeta.Position;
        Vector3          size      = TerrainMeta.Size;
        float            x1        = (float)position1.x;
        float            z1        = (float)position1.z;
        float            num1      = (float)(position1.x + size.x);
        float            num2      = (float)(position1.z + size.z);

        PlaceMonument.SpawnInfo spawnInfo1 = new PlaceMonument.SpawnInfo();
        int num3 = int.MinValue;
        Prefab <MonumentInfo> prefab1 = Prefab.Load <MonumentInfo>(this.Monument.resourceID, (GameManager)null, (PrefabAttribute.Library)null);

        for (int index = 0; index < 10000; ++index)
        {
            float  x2     = SeedRandom.Range(ref seed, x1, num1);
            float  z2     = SeedRandom.Range(ref seed, z1, num2);
            float  normX  = TerrainMeta.NormalizeX(x2);
            float  normZ  = TerrainMeta.NormalizeZ(z2);
            float  num4   = SeedRandom.Value(ref seed);
            double factor = (double)this.Filter.GetFactor(normX, normZ);
            if (factor * factor >= (double)num4)
            {
                float   height = heightMap.GetHeight(normX, normZ);
                Vector3 pos;
                ((Vector3) ref pos).\u002Ector(x2, height, z2);
                Quaternion localRotation = prefab1.Object.get_transform().get_localRotation();
                Vector3    localScale    = prefab1.Object.get_transform().get_localScale();
                prefab1.ApplyDecorComponents(ref pos, ref localRotation, ref localScale);
                if ((!Object.op_Implicit((Object)prefab1.Component) || prefab1.Component.CheckPlacement(pos, localRotation, localScale)) && (prefab1.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && prefab1.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter)) && (prefab1.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && prefab1.ApplyWaterChecks(pos, localRotation, localScale) && !prefab1.CheckEnvironmentVolumes(pos, localRotation, localScale, EnvironmentType.Underground)))
                {
                    PlaceMonument.SpawnInfo spawnInfo2 = new PlaceMonument.SpawnInfo();
                    spawnInfo2.prefab   = (Prefab)prefab1;
                    spawnInfo2.position = pos;
                    spawnInfo2.rotation = localRotation;
                    spawnInfo2.scale    = localScale;
                    int num5 = -Mathf.RoundToInt(Vector3Ex.Magnitude2D(pos));
                    if (num5 > num3)
                    {
                        num3       = num5;
                        spawnInfo1 = spawnInfo2;
                    }
                }
            }
        }
        if (num3 == int.MinValue)
        {
            return;
        }
        Prefab     prefab2   = spawnInfo1.prefab;
        Vector3    position2 = spawnInfo1.position;
        Quaternion rotation  = spawnInfo1.rotation;
        Vector3    scale     = spawnInfo1.scale;

        prefab2.ApplyTerrainPlacements(position2, rotation, scale);
        prefab2.ApplyTerrainModifiers(position2, rotation, scale);
        World.AddPrefab("Monument", prefab2.ID, position2, rotation, scale);
    }
    public void SetHeight(Vector3 worldPos, float opacity, float radius, float fade = 0f)
    {
        float single  = TerrainMeta.NormalizeX(worldPos.x);
        float single1 = TerrainMeta.NormalizeZ(worldPos.z);
        float single2 = TerrainMeta.NormalizeY(worldPos.y);

        this.SetHeight(single, single1, single2, opacity, radius, fade);
    }
Ejemplo n.º 12
0
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;
        Vector3          position  = TerrainMeta.Position;
        Vector3          size      = TerrainMeta.Size;
        float            single    = position.x;
        float            single1   = position.z;
        float            single2   = position.x + size.x;
        float            single3   = position.z + size.z;

        PlaceMonument.SpawnInfo spawnInfo = new PlaceMonument.SpawnInfo();
        int num = -2147483648;
        Prefab <MonumentInfo> prefab = Prefab.Load <MonumentInfo>(this.Monument.resourceID, null, null);

        for (int i = 0; i < 10000; i++)
        {
            float single4 = SeedRandom.Range(ref seed, single, single2);
            float single5 = SeedRandom.Range(ref seed, single1, single3);
            float single6 = TerrainMeta.NormalizeX(single4);
            float single7 = TerrainMeta.NormalizeZ(single5);
            float single8 = SeedRandom.Value(ref seed);
            float factor  = this.Filter.GetFactor(single6, single7);
            if (factor * factor >= single8)
            {
                float      height  = heightMap.GetHeight(single6, single7);
                Vector3    vector3 = new Vector3(single4, height, single5);
                Quaternion obj     = prefab.Object.transform.localRotation;
                Vector3    obj1    = prefab.Object.transform.localScale;
                prefab.ApplyDecorComponents(ref vector3, ref obj, ref obj1);
                if ((!prefab.Component || prefab.Component.CheckPlacement(vector3, obj, obj1)) && prefab.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && prefab.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && prefab.ApplyTerrainFilters(vector3, obj, obj1, null) && prefab.ApplyWaterChecks(vector3, obj, obj1) && !prefab.CheckEnvironmentVolumes(vector3, obj, obj1, EnvironmentType.Underground))
                {
                    PlaceMonument.SpawnInfo spawnInfo1 = new PlaceMonument.SpawnInfo()
                    {
                        prefab   = prefab,
                        position = vector3,
                        rotation = obj,
                        scale    = obj1
                    };
                    int num1 = -Mathf.RoundToInt(vector3.Magnitude2D());
                    if (num1 > num)
                    {
                        num       = num1;
                        spawnInfo = spawnInfo1;
                    }
                }
            }
        }
        if (num != -2147483648)
        {
            Prefab     prefab1    = spawnInfo.prefab;
            Vector3    vector31   = spawnInfo.position;
            Quaternion quaternion = spawnInfo.rotation;
            Vector3    vector32   = spawnInfo.scale;
            prefab1.ApplyTerrainPlacements(vector31, quaternion, vector32);
            prefab1.ApplyTerrainModifiers(vector31, quaternion, vector32);
            World.AddPrefab("Monument", prefab1.ID, vector31, quaternion, vector32);
        }
    }
Ejemplo n.º 13
0
    public PathFinder.Point GetPathFinderPoint(int res)
    {
        Vector3 position = base.transform.position;
        float   num      = TerrainMeta.NormalizeX(position.x);
        float   num2     = TerrainMeta.NormalizeZ(position.z);

        PathFinder.Point result = default(PathFinder.Point);
        result.x = Mathf.Clamp((int)(num * (float)res), 0, res - 1);
        result.y = Mathf.Clamp((int)(num2 * (float)res), 0, res - 1);
        return(result);
    }
    public PathFinder.Point GetPoint(int res)
    {
        Vector3 position = ((Component)this).get_transform().get_position();
        float   num1     = TerrainMeta.NormalizeX((float)position.x);
        float   num2     = TerrainMeta.NormalizeZ((float)position.z);

        return(new PathFinder.Point()
        {
            x = Mathf.Clamp((int)((double)num1 * (double)res), 0, res - 1),
            y = Mathf.Clamp((int)((double)num2 * (double)res), 0, res - 1)
        });
    }
Ejemplo n.º 15
0
    public PathFinder.Point GetPoint(int res)
    {
        Vector3 vector3 = base.transform.position;
        float   single  = TerrainMeta.NormalizeX(vector3.x);
        float   single1 = TerrainMeta.NormalizeZ(vector3.z);

        PathFinder.Point point = new PathFinder.Point()
        {
            x = Mathf.Clamp((int)(single * (float)res), 0, res - 1),
            y = Mathf.Clamp((int)(single1 * (float)res), 0, res - 1)
        };
        return(point);
    }
Ejemplo n.º 16
0
    public override void Process()
    {
        Collider component = GetComponent <Collider>();
        Bounds   bounds    = component.bounds;
        int      num       = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeX(bounds.min.x));
        int      num2      = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeZ(bounds.max.x));
        int      num3      = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeX(bounds.min.z));
        int      num4      = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeZ(bounds.max.z));

        if (component is BoxCollider && base.transform.rotation == Quaternion.identity)
        {
            float num5 = TerrainMeta.NormalizeY(bounds.max.y);
            for (int i = num3; i <= num4; i++)
            {
                for (int j = num; j <= num2; j++)
                {
                    float height = TerrainMeta.WaterMap.GetHeight01(j, i);
                    if (num5 > height)
                    {
                        TerrainMeta.WaterMap.SetHeight(j, i, num5);
                    }
                }
            }
        }
        else
        {
            for (int k = num3; k <= num4; k++)
            {
                float normZ = TerrainMeta.WaterMap.Coordinate(k);
                for (int l = num; l <= num2; l++)
                {
                    float      normX  = TerrainMeta.WaterMap.Coordinate(l);
                    Vector3    origin = new Vector3(TerrainMeta.DenormalizeX(normX), bounds.max.y + 1f, TerrainMeta.DenormalizeZ(normZ));
                    Ray        ray    = new Ray(origin, Vector3.down);
                    RaycastHit hitInfo;
                    if (component.Raycast(ray, out hitInfo, bounds.size.y + 1f + 1f))
                    {
                        float num6    = TerrainMeta.NormalizeY(hitInfo.point.y);
                        float height2 = TerrainMeta.WaterMap.GetHeight01(l, k);
                        if (num6 > height2)
                        {
                            TerrainMeta.WaterMap.SetHeight(l, k, num6);
                        }
                    }
                }
            }
        }
        GameManager.Destroy(this);
    }
Ejemplo n.º 17
0
    public void ForEach(Vector3 worldPos, float radius, Action <int, int> action)
    {
        int num1 = this.Index(TerrainMeta.NormalizeX((float)worldPos.x - radius));
        int num2 = this.Index(TerrainMeta.NormalizeX((float)worldPos.x + radius));
        int num3 = this.Index(TerrainMeta.NormalizeZ((float)worldPos.z - radius));
        int num4 = this.Index(TerrainMeta.NormalizeZ((float)worldPos.z + radius));

        for (int index1 = num3; index1 <= num4; ++index1)
        {
            for (int index2 = num1; index2 <= num2; ++index2)
            {
                action(index2, index1);
            }
        }
    }
Ejemplo n.º 18
0
    public void ForEach(Vector3 worldPos, float radius, Action <int, int> action)
    {
        int num  = this.Index(TerrainMeta.NormalizeX(worldPos.x - radius));
        int num1 = this.Index(TerrainMeta.NormalizeX(worldPos.x + radius));
        int num2 = this.Index(TerrainMeta.NormalizeZ(worldPos.z - radius));
        int num3 = this.Index(TerrainMeta.NormalizeZ(worldPos.z + radius));

        for (int i = num2; i <= num3; i++)
        {
            for (int j = num; j <= num1; j++)
            {
                action(j, i);
            }
        }
    }
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;

        Prefab[] array = Prefab.Load("assets/bundled/prefabs/autospawn/" + this.ResourceFolder, (GameManager)null, (PrefabAttribute.Library)null, true);
        if (array == null || array.Length == 0)
        {
            return;
        }
        Vector3 position  = TerrainMeta.Position;
        Vector3 size      = TerrainMeta.Size;
        int     num1      = Mathf.RoundToInt((float)((double)this.ObjectDensity * size.x * size.z * 9.99999997475243E-07));
        float   x1        = (float)position.x;
        float   z1        = (float)position.z;
        float   num2      = (float)(position.x + size.x);
        float   num3      = (float)(position.z + size.z);
        float   num4      = SeedRandom.Range(ref seed, -1000000f, 1000000f);
        float   num5      = SeedRandom.Range(ref seed, -1000000f, 1000000f);
        int     octaves   = this.Cluster.Octaves;
        float   offset    = this.Cluster.Offset;
        float   frequency = this.Cluster.Frequency * 0.01f;
        float   amplitude = this.Cluster.Amplitude;

        for (int index = 0; index < num1; ++index)
        {
            float  x2     = SeedRandom.Range(ref seed, x1, num2);
            float  z2     = SeedRandom.Range(ref seed, z1, num3);
            float  normX  = TerrainMeta.NormalizeX(x2);
            float  normZ  = TerrainMeta.NormalizeZ(z2);
            float  num6   = SeedRandom.Value(ref seed);
            float  factor = this.Filter.GetFactor(normX, normZ);
            Prefab random = array.GetRandom <Prefab>(ref seed);
            if ((double)factor > 0.0 && ((double)offset + (double)Noise.Turbulence(num4 + x2, num5 + z2, octaves, frequency, amplitude, 2f, 0.5f)) * (double)factor * (double)factor >= (double)num6)
            {
                float   height = heightMap.GetHeight(normX, normZ);
                Vector3 pos;
                ((Vector3) ref pos).\u002Ector(x2, height, z2);
                Quaternion localRotation = random.Object.get_transform().get_localRotation();
                Vector3    localScale    = random.Object.get_transform().get_localScale();
                random.ApplyDecorComponents(ref pos, ref localRotation, ref localScale);
                if (random.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && random.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter) && (random.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && random.ApplyWaterChecks(pos, localRotation, localScale)))
                {
                    random.ApplyTerrainModifiers(pos, localRotation, localScale);
                    World.AddPrefab("Decor", random.ID, pos, localRotation, localScale);
                }
            }
        }
    }
Ejemplo n.º 20
0
    public override void Process()
    {
        RaycastHit raycastHit;
        Collider   component = base.GetComponent <Collider>();
        Bounds     bound     = component.bounds;
        int        num       = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeX(bound.min.x));
        int        num1      = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeZ(bound.max.x));
        int        num2      = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeX(bound.min.z));
        int        num3      = TerrainMeta.WaterMap.Index(TerrainMeta.NormalizeZ(bound.max.z));

        if (!(component is BoxCollider) || !(base.transform.rotation == Quaternion.identity))
        {
            for (int i = num2; i <= num3; i++)
            {
                float single = TerrainMeta.WaterMap.Coordinate(i);
                for (int j = num; j <= num1; j++)
                {
                    float   single1 = TerrainMeta.WaterMap.Coordinate(j);
                    Vector3 vector3 = new Vector3(TerrainMeta.DenormalizeX(single1), bound.max.y + 1f, TerrainMeta.DenormalizeZ(single));
                    Ray     ray     = new Ray(vector3, Vector3.down);
                    if (component.Raycast(ray, out raycastHit, bound.size.y + 1f + 1f))
                    {
                        float single2 = TerrainMeta.NormalizeY(raycastHit.point.y);
                        if (single2 > TerrainMeta.WaterMap.GetHeight01(j, i))
                        {
                            TerrainMeta.WaterMap.SetHeight(j, i, single2);
                        }
                    }
                }
            }
        }
        else
        {
            float single3 = TerrainMeta.NormalizeY(bound.max.y);
            for (int k = num2; k <= num3; k++)
            {
                for (int l = num; l <= num1; l++)
                {
                    if (single3 > TerrainMeta.WaterMap.GetHeight01(l, k))
                    {
                        TerrainMeta.WaterMap.SetHeight(l, k, single3);
                    }
                }
            }
        }
        GameManager.Destroy(this, 0f);
    }
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;

        Prefab[] prefabArray = Prefab.Load(string.Concat("assets/bundled/prefabs/autospawn/", this.ResourceFolder), null, null, true);
        if (prefabArray == null || prefabArray.Length == 0)
        {
            return;
        }
        Vector3 position  = TerrainMeta.Position;
        Vector3 size      = TerrainMeta.Size;
        int     num       = Mathf.RoundToInt(this.ObjectDensity * size.x * size.z * 1E-06f);
        float   single    = position.x;
        float   single1   = position.z;
        float   single2   = position.x + size.x;
        float   single3   = position.z + size.z;
        float   single4   = SeedRandom.Range(ref seed, -1000000f, 1000000f);
        float   single5   = SeedRandom.Range(ref seed, -1000000f, 1000000f);
        int     octaves   = this.Cluster.Octaves;
        float   offset    = this.Cluster.Offset;
        float   frequency = this.Cluster.Frequency * 0.01f;
        float   amplitude = this.Cluster.Amplitude;

        for (int i = 0; i < num; i++)
        {
            float  single6  = SeedRandom.Range(ref seed, single, single2);
            float  single7  = SeedRandom.Range(ref seed, single1, single3);
            float  single8  = TerrainMeta.NormalizeX(single6);
            float  single9  = TerrainMeta.NormalizeZ(single7);
            float  single10 = SeedRandom.Value(ref seed);
            float  factor   = this.Filter.GetFactor(single8, single9);
            Prefab random   = prefabArray.GetRandom <Prefab>(ref seed);
            if (factor > 0f && (offset + Noise.Turbulence(single4 + single6, single5 + single7, octaves, frequency, amplitude, 2f, 0.5f)) * factor * factor >= single10)
            {
                float      height  = heightMap.GetHeight(single8, single9);
                Vector3    vector3 = new Vector3(single6, height, single7);
                Quaternion obj     = random.Object.transform.localRotation;
                Vector3    obj1    = random.Object.transform.localScale;
                random.ApplyDecorComponents(ref vector3, ref obj, ref obj1);
                if (random.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && random.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && random.ApplyTerrainFilters(vector3, obj, obj1, null) && random.ApplyWaterChecks(vector3, obj, obj1))
                {
                    random.ApplyTerrainModifiers(vector3, obj, obj1);
                    World.AddPrefab("Decor", random.ID, vector3, obj, obj1);
                }
            }
        }
    }
Ejemplo n.º 22
0
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;

        Prefab[] array = Prefab.Load("assets/bundled/prefabs/autospawn/" + this.ResourceFolder, (GameManager)null, (PrefabAttribute.Library)null, true);
        if (array == null || array.Length == 0)
        {
            return;
        }
        Vector3 position = TerrainMeta.Position;
        Vector3 size     = TerrainMeta.Size;
        float   x1       = (float)position.x;
        float   z1       = (float)position.z;
        float   num1     = (float)(position.x + size.x);
        float   num2     = (float)(position.z + size.z);

        for (float num3 = z1; (double)num3 < (double)num2; num3 += this.ObjectDistance)
        {
            for (float num4 = x1; (double)num4 < (double)num1; num4 += this.ObjectDistance)
            {
                float  x2     = num4 + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering);
                float  z2     = num3 + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering);
                float  normX  = TerrainMeta.NormalizeX(x2);
                float  normZ  = TerrainMeta.NormalizeZ(z2);
                float  num5   = SeedRandom.Value(ref seed);
                double factor = (double)this.Filter.GetFactor(normX, normZ);
                Prefab random = array.GetRandom <Prefab>(ref seed);
                if (factor * factor >= (double)num5)
                {
                    float   height = heightMap.GetHeight(normX, normZ);
                    Vector3 pos;
                    ((Vector3) ref pos).\u002Ector(x2, height, z2);
                    Quaternion localRotation = random.Object.get_transform().get_localRotation();
                    Vector3    localScale    = random.Object.get_transform().get_localScale();
                    random.ApplyDecorComponents(ref pos, ref localRotation, ref localScale);
                    if (random.ApplyTerrainAnchors(ref pos, localRotation, localScale, this.Filter) && random.ApplyTerrainChecks(pos, localRotation, localScale, this.Filter) && (random.ApplyTerrainFilters(pos, localRotation, localScale, (SpawnFilter)null) && random.ApplyWaterChecks(pos, localRotation, localScale)))
                    {
                        random.ApplyTerrainModifiers(pos, localRotation, localScale);
                        World.AddPrefab("Decor", random.ID, pos, localRotation, localScale);
                    }
                }
            }
        }
    }
Ejemplo n.º 23
0
    public override void Process(uint seed)
    {
        TerrainHeightMap heightMap = TerrainMeta.HeightMap;

        Prefab[] prefabArray = Prefab.Load(string.Concat("assets/bundled/prefabs/autospawn/", this.ResourceFolder), null, null, true);
        if (prefabArray == null || prefabArray.Length == 0)
        {
            return;
        }
        Vector3 position = TerrainMeta.Position;
        Vector3 size     = TerrainMeta.Size;
        float   single   = position.x;
        float   single1  = position.z;
        float   single2  = position.x + size.x;
        float   single3  = position.z + size.z;

        for (float i = single1; i < single3; i += this.ObjectDistance)
        {
            for (float j = single; j < single2; j += this.ObjectDistance)
            {
                float  single4 = j + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering);
                float  single5 = i + SeedRandom.Range(ref seed, -this.ObjectDithering, this.ObjectDithering);
                float  single6 = TerrainMeta.NormalizeX(single4);
                float  single7 = TerrainMeta.NormalizeZ(single5);
                float  single8 = SeedRandom.Value(ref seed);
                float  factor  = this.Filter.GetFactor(single6, single7);
                Prefab random  = prefabArray.GetRandom <Prefab>(ref seed);
                if (factor * factor >= single8)
                {
                    float      height  = heightMap.GetHeight(single6, single7);
                    Vector3    vector3 = new Vector3(single4, height, single5);
                    Quaternion obj     = random.Object.transform.localRotation;
                    Vector3    obj1    = random.Object.transform.localScale;
                    random.ApplyDecorComponents(ref vector3, ref obj, ref obj1);
                    if (random.ApplyTerrainAnchors(ref vector3, obj, obj1, this.Filter) && random.ApplyTerrainChecks(vector3, obj, obj1, this.Filter) && random.ApplyTerrainFilters(vector3, obj, obj1, null) && random.ApplyWaterChecks(vector3, obj, obj1))
                    {
                        random.ApplyTerrainModifiers(vector3, obj, obj1);
                        World.AddPrefab("Decor", random.ID, vector3, obj, obj1);
                    }
                }
            }
        }
    }
Ejemplo n.º 24
0
    public override void Process()
    {
        Collider component = GetComponent <Collider>();
        Bounds   bounds    = component.bounds;
        int      num       = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeX(bounds.min.x));
        int      num2      = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeZ(bounds.max.x));
        int      num3      = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeX(bounds.min.z));
        int      num4      = TerrainMeta.HeightMap.Index(TerrainMeta.NormalizeZ(bounds.max.z));

        for (int i = num3; i <= num4; i++)
        {
            float normZ = TerrainMeta.HeightMap.Coordinate(i);
            for (int j = num; j <= num2; j++)
            {
                float      normX  = TerrainMeta.HeightMap.Coordinate(j);
                Vector3    origin = new Vector3(TerrainMeta.DenormalizeX(normX), bounds.max.y, TerrainMeta.DenormalizeZ(normZ));
                Ray        ray    = new Ray(origin, Vector3.down);
                RaycastHit hitInfo;
                if (component.Raycast(ray, out hitInfo, bounds.size.y))
                {
                    float num5   = TerrainMeta.NormalizeY(hitInfo.point.y);
                    float height = TerrainMeta.HeightMap.GetHeight01(j, i);
                    if (num5 > height)
                    {
                        TerrainMeta.HeightMap.SetHeight(j, i, num5);
                    }
                }
            }
        }
        if (DestroyGameObject)
        {
            GameManager.Destroy(base.gameObject);
        }
        else
        {
            GameManager.Destroy(this);
        }
    }
 public int GetTopology(Vector3 worldPos)
 {
     return(this.GetTopology(TerrainMeta.NormalizeX((float)worldPos.x), TerrainMeta.NormalizeZ((float)worldPos.z)));
 }
Ejemplo n.º 26
0
 public void SetHeight(Vector3 worldPos, float height)
 {
     this.SetHeight(TerrainMeta.NormalizeX((float)worldPos.x), TerrainMeta.NormalizeZ((float)worldPos.z), height);
 }
Ejemplo n.º 27
0
 public Vector3 GetNormal(Vector3 worldPos)
 {
     return(this.GetNormal(TerrainMeta.NormalizeX((float)worldPos.x), TerrainMeta.NormalizeZ((float)worldPos.z)));
 }
Ejemplo n.º 28
0
 public float GetHeight01(Vector3 worldPos)
 {
     return(this.GetHeight01(TerrainMeta.NormalizeX((float)worldPos.x), TerrainMeta.NormalizeZ((float)worldPos.z)));
 }
Ejemplo n.º 29
0
 public void SetAlpha(Vector3 worldPos, float a, float opacity, float radius, float fade = 0.0f)
 {
     this.SetAlpha(TerrainMeta.NormalizeX((float)worldPos.x), TerrainMeta.NormalizeZ((float)worldPos.z), a, opacity, radius, fade);
 }
Ejemplo n.º 30
0
 public void SetAlpha(Vector3 worldPos, float a)
 {
     this.SetAlpha(TerrainMeta.NormalizeX((float)worldPos.x), TerrainMeta.NormalizeZ((float)worldPos.z), a);
 }