Пример #1
0
    private bool CheckObjects(Prefab[] prefabs, Vector3 pos, Vector3 dir, PathList.BasicObject obj)
    {
        if (!obj.AlignToNormal)
        {
            Vector3 vector3 = Vector3Ex.XZ3D(dir);
            dir = ((Vector3) ref vector3).get_normalized();
        }
        SpawnFilter filter    = obj.Filter;
        Vector3     vector3_1 = Vector3.op_Multiply(this.Width * 0.5f + obj.Offset, Quaternion.op_Multiply(PathList.rot90, dir));

        for (int index = 0; index < PathList.placements.Length; ++index)
        {
            if ((obj.Placement != PathList.Placement.Center || index == 0) && (obj.Placement != PathList.Placement.Side || index != 0))
            {
                Vector3 vector3_2 = Vector3.op_Addition(pos, Vector3.op_Multiply(PathList.placements[index], vector3_1));
                if (obj.HeightToTerrain)
                {
                    vector3_2.y = (__Null)(double)TerrainMeta.HeightMap.GetHeight(vector3_2);
                }
                if (filter.Test(vector3_2))
                {
                    Quaternion rotation = index == 2 ? Quaternion.LookRotation(Quaternion.op_Multiply(PathList.rot180, dir)) : Quaternion.LookRotation(dir);
                    if (this.CheckObjects(prefabs, vector3_2, rotation, filter))
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Пример #2
0
    private bool CheckObjects(Prefab[] prefabs, Vector3 pos, Vector3 dir, PathList.BasicObject obj)
    {
        if (!obj.AlignToNormal)
        {
            dir = dir.XZ3D().normalized;
        }
        SpawnFilter filter = obj.Filter;
        Vector3     width  = (this.Width * 0.5f + obj.Offset) * PathList.rot90 * dir;

        for (int i = 0; i < (int)PathList.placements.Length; i++)
        {
            if ((obj.Placement != PathList.Placement.Center || i == 0) && (obj.Placement != PathList.Placement.Side || i != 0))
            {
                Vector3 height = pos + (PathList.placements[i] * width);
                if (obj.HeightToTerrain)
                {
                    height.y = TerrainMeta.HeightMap.GetHeight(height);
                }
                if (filter.Test(height))
                {
                    if (this.CheckObjects(prefabs, height, (i == 2 ? Quaternion.LookRotation(PathList.rot180 * dir) : Quaternion.LookRotation(dir)), filter))
                    {
                        return(true);
                    }
                }
            }
        }
        return(false);
    }
Пример #3
0
    public void SpawnEnd(ref uint seed, PathList.BasicObject obj)
    {
        if (!this.End)
        {
            return;
        }
        if (string.IsNullOrEmpty(obj.Folder))
        {
            return;
        }
        Prefab[] prefabArray = Prefab.Load(string.Concat("assets/bundled/prefabs/autospawn/", obj.Folder), null, null, true);
        if (prefabArray == null || prefabArray.Length == 0)
        {
            Debug.LogError(string.Concat("Empty decor folder: ", obj.Folder));
            return;
        }
        Vector3 endPoint   = this.Path.GetEndPoint();
        Vector3 endTangent = -this.Path.GetEndTangent();

        this.SpawnObject(ref seed, prefabArray, endPoint, endTangent, obj);
    }