Example #1
0
    public virtual bool CheckLocation(StructureMaster master, Vector3 placePos, Quaternion placeRot)
    {
        bool    flag   = false;
        bool    flag2  = false;
        Vector3 vector = master.transform.InverseTransformPoint(placePos);

        if ((master.GetMaterialType() != StructureMaster.StructureMaterialType.UNSET) && (master.GetMaterialType() != this.GetMaterialType()))
        {
            if (logFailures)
            {
                Debug.Log("Not proper material type, master is :" + master.GetMaterialType());
            }
            return(false);
        }
        StructureComponent componentFromPositionWorld = master.GetComponentFromPositionWorld(placePos);

        if (componentFromPositionWorld != null)
        {
            if (logFailures)
            {
                Debug.Log("Occupied space", componentFromPositionWorld);
            }
            flag = true;
        }
        StructureComponent component2 = master.CompByLocal(vector - new Vector3(0f, StructureMaster.gridSpacingY, 0f));

        if ((this.type != StructureComponentType.Foundation) && master.GetFoundationForPoint(placePos))
        {
            flag2 = true;
        }
        if (((this.type == StructureComponentType.Wall) || (this.type == StructureComponentType.Doorway)) || (this.type == StructureComponentType.WindowWall))
        {
            if (!flag)
            {
                Vector3            worldPos   = placePos + ((Vector3)((placeRot * -Vector3.right) * 2.5f));
                StructureComponent context    = master.GetComponentFromPositionWorld(worldPos);
                Vector3            vector3    = placePos + ((Vector3)((placeRot * Vector3.right) * 2.5f));
                StructureComponent component4 = master.GetComponentFromPositionWorld(vector3);
                if (logFailures)
                {
                    Debug.DrawLine(worldPos, vector3, Color.cyan);
                }
                if ((context != null) && (component4 != null))
                {
                    bool flag4;
                    bool flag5;
                    if (context.type != StructureComponentType.Pillar)
                    {
                        if (logFailures)
                        {
                            Debug.Log("Left was not acceptable", context);
                        }
                        flag4 = false;
                    }
                    else
                    {
                        flag4 = true;
                    }
                    if (component4.type != StructureComponentType.Pillar)
                    {
                        if (logFailures)
                        {
                            Debug.Log("Right was not acceptable", component4);
                        }
                        flag5 = false;
                    }
                    else
                    {
                        flag5 = true;
                    }
                    return(flag4 && flag5);
                }
                if (logFailures)
                {
                    if (context == null)
                    {
                        Debug.Log("Did not find left");
                    }
                    if (component4 == null)
                    {
                        Debug.Log("Did not find right");
                    }
                }
            }
            return(false);
        }
        if (this.type == StructureComponentType.Foundation)
        {
            foreach (StructureMaster master2 in StructureMaster.AllStructuresWithBounds)
            {
                if ((master2 != master) && master2.containedBounds.Intersects(new Bounds(placePos, new Vector3(5f, 5f, 4f))))
                {
                    if (logFailures)
                    {
                        Debug.Log("Too close to something");
                    }
                    return(false);
                }
            }
            bool flag6 = master.IsValidFoundationSpot(placePos);
            if (logFailures)
            {
                Debug.Log(string.Concat(new object[] { "returning here : mastervalid:", flag6, "compinplace", componentFromPositionWorld }));
            }
            return(flag6 && (componentFromPositionWorld == 0));
        }
        if (this.type == StructureComponentType.Ramp)
        {
            return((componentFromPositionWorld == null) && (master.IsValidFoundationSpot(placePos) || ((component2 != null) && ((component2.type == StructureComponentType.Ceiling) || (component2.type == StructureComponentType.Foundation)))));
        }
        if (this.type == StructureComponentType.Pillar)
        {
            return((((component2 != null) && (component2.type == StructureComponentType.Pillar)) || flag2) && !flag);
        }
        if ((this.type != StructureComponentType.Stairs) && (this.type != StructureComponentType.Ceiling))
        {
            return(false);
        }
        if (flag)
        {
            return(false);
        }
        Vector3[] vectorArray = new Vector3[] { new Vector3(-2.5f, 0f, -2.5f), new Vector3(2.5f, 0f, 2.5f), new Vector3(-2.5f, 0f, 2.5f), new Vector3(2.5f, 0f, -2.5f) };
        foreach (Vector3 vector4 in vectorArray)
        {
            StructureComponent component5 = master.CompByLocal(vector + vector4);
            if ((component5 == null) || (component5.type != StructureComponentType.Pillar))
            {
                return(false);
            }
        }
        return(true);
    }
Example #2
0
 public virtual bool CheckLocation(StructureMaster master, Vector3 placePos, Quaternion placeRot)
 {
     bool flag;
     bool flag1;
     bool flag2;
     bool flag3 = false;
     bool flag4 = false;
     Vector3 vector3 = master.transform.InverseTransformPoint(placePos);
     if (master.GetMaterialType() != StructureMaster.StructureMaterialType.UNSET && master.GetMaterialType() != this.GetMaterialType())
     {
         if (StructureComponent.logFailures)
         {
             Debug.Log(string.Concat("Not proper material type, master is :", master.GetMaterialType()));
         }
         return false;
     }
     StructureComponent componentFromPositionWorld = master.GetComponentFromPositionWorld(placePos);
     if (componentFromPositionWorld != null)
     {
         if (StructureComponent.logFailures)
         {
             Debug.Log("Occupied space", componentFromPositionWorld);
         }
         flag3 = true;
     }
     StructureComponent structureComponent = master.CompByLocal(vector3 - new Vector3(0f, StructureMaster.gridSpacingY, 0f));
     if (this.type != StructureComponent.StructureComponentType.Foundation && master.GetFoundationForPoint(placePos))
     {
         flag4 = true;
     }
     if (this.type == StructureComponent.StructureComponentType.Wall || this.type == StructureComponent.StructureComponentType.Doorway || this.type == StructureComponent.StructureComponentType.WindowWall)
     {
         if (flag3)
         {
             return false;
         }
         Vector3 vector31 = placePos + ((placeRot * -Vector3.right) * 2.5f);
         StructureComponent componentFromPositionWorld1 = master.GetComponentFromPositionWorld(vector31);
         Vector3 vector32 = placePos + ((placeRot * Vector3.right) * 2.5f);
         StructureComponent structureComponent1 = master.GetComponentFromPositionWorld(vector32);
         if (StructureComponent.logFailures)
         {
             Debug.DrawLine(vector31, vector32, Color.cyan);
         }
         if (!componentFromPositionWorld1 || !structureComponent1)
         {
             if (StructureComponent.logFailures)
             {
                 if (!componentFromPositionWorld1)
                 {
                     Debug.Log("Did not find left");
                 }
                 if (!structureComponent1)
                 {
                     Debug.Log("Did not find right");
                 }
             }
             return false;
         }
         if (componentFromPositionWorld1.type == StructureComponent.StructureComponentType.Pillar)
         {
             flag = true;
         }
         else
         {
             if (StructureComponent.logFailures)
             {
                 Debug.Log("Left was not acceptable", componentFromPositionWorld1);
             }
             flag = false;
         }
         if (structureComponent1.type == StructureComponent.StructureComponentType.Pillar)
         {
             flag1 = true;
         }
         else
         {
             if (StructureComponent.logFailures)
             {
                 Debug.Log("Right was not acceptable", structureComponent1);
             }
             flag1 = false;
         }
         return (!flag ? false : flag1);
     }
     if (this.type == StructureComponent.StructureComponentType.Foundation)
     {
         List<StructureMaster>.Enumerator enumerator = StructureMaster.AllStructuresWithBounds.GetEnumerator();
         try
         {
             while (enumerator.MoveNext())
             {
                 StructureMaster current = enumerator.Current;
                 if (current != master)
                 {
                     if (!current.containedBounds.Intersects(new Bounds(placePos, new Vector3(5f, 5f, 4f))))
                     {
                         continue;
                     }
                     if (StructureComponent.logFailures)
                     {
                         Debug.Log("Too close to something");
                     }
                     flag2 = false;
                     return flag2;
                 }
             }
             bool flag5 = master.IsValidFoundationSpot(placePos);
             if (StructureComponent.logFailures)
             {
                 Debug.Log(string.Concat(new object[] { "returning here : mastervalid:", flag5, "compinplace", componentFromPositionWorld }));
             }
             return (!flag5 ? false : !componentFromPositionWorld);
         }
         finally
         {
             ((IDisposable)(object)enumerator).Dispose();
         }
         return flag2;
     }
     if (this.type == StructureComponent.StructureComponentType.Ramp)
     {
         if (componentFromPositionWorld == null && (master.IsValidFoundationSpot(placePos) || structureComponent && (structureComponent.type == StructureComponent.StructureComponentType.Ceiling || structureComponent.type == StructureComponent.StructureComponentType.Foundation)))
         {
             return true;
         }
         return false;
     }
     if (this.type == StructureComponent.StructureComponentType.Pillar)
     {
         return ((!structureComponent || structureComponent.type != StructureComponent.StructureComponentType.Pillar) && !flag4 ? false : !flag3);
     }
     if (this.type != StructureComponent.StructureComponentType.Stairs && this.type != StructureComponent.StructureComponentType.Ceiling)
     {
         return false;
     }
     if (flag3)
     {
         return false;
     }
     Vector3[] vector3Array = new Vector3[] { new Vector3(-2.5f, 0f, -2.5f), new Vector3(2.5f, 0f, 2.5f), new Vector3(-2.5f, 0f, 2.5f), new Vector3(2.5f, 0f, -2.5f) };
     for (int i = 0; i < (int)vector3Array.Length; i++)
     {
         Vector3 vector33 = vector3Array[i];
         StructureComponent structureComponent2 = master.CompByLocal(vector3 + vector33);
         if (structureComponent2 == null || structureComponent2.type != StructureComponent.StructureComponentType.Pillar)
         {
             return false;
         }
     }
     return true;
 }
Example #3
0
    public virtual bool CheckLocation(StructureMaster master, Vector3 placePos, Quaternion placeRot)
    {
        bool    flag;
        bool    flag1;
        bool    flag2;
        bool    flag3   = false;
        bool    flag4   = false;
        Vector3 vector3 = master.transform.InverseTransformPoint(placePos);

        if (master.GetMaterialType() != StructureMaster.StructureMaterialType.UNSET && master.GetMaterialType() != this.GetMaterialType())
        {
            if (StructureComponent.logFailures)
            {
                Debug.Log(string.Concat("Not proper material type, master is :", master.GetMaterialType()));
            }
            return(false);
        }
        StructureComponent componentFromPositionWorld = master.GetComponentFromPositionWorld(placePos);

        if (componentFromPositionWorld != null)
        {
            if (StructureComponent.logFailures)
            {
                Debug.Log("Occupied space", componentFromPositionWorld);
            }
            flag3 = true;
        }
        StructureComponent structureComponent = master.CompByLocal(vector3 - new Vector3(0f, StructureMaster.gridSpacingY, 0f));

        if (this.type != StructureComponent.StructureComponentType.Foundation && master.GetFoundationForPoint(placePos))
        {
            flag4 = true;
        }
        if (this.type == StructureComponent.StructureComponentType.Wall || this.type == StructureComponent.StructureComponentType.Doorway || this.type == StructureComponent.StructureComponentType.WindowWall)
        {
            if (flag3)
            {
                return(false);
            }
            Vector3            vector31 = placePos + ((placeRot * -Vector3.right) * 2.5f);
            StructureComponent componentFromPositionWorld1 = master.GetComponentFromPositionWorld(vector31);
            Vector3            vector32            = placePos + ((placeRot * Vector3.right) * 2.5f);
            StructureComponent structureComponent1 = master.GetComponentFromPositionWorld(vector32);
            if (StructureComponent.logFailures)
            {
                Debug.DrawLine(vector31, vector32, Color.cyan);
            }
            if (!componentFromPositionWorld1 || !structureComponent1)
            {
                if (StructureComponent.logFailures)
                {
                    if (!componentFromPositionWorld1)
                    {
                        Debug.Log("Did not find left");
                    }
                    if (!structureComponent1)
                    {
                        Debug.Log("Did not find right");
                    }
                }
                return(false);
            }
            if (componentFromPositionWorld1.type == StructureComponent.StructureComponentType.Pillar)
            {
                flag = true;
            }
            else
            {
                if (StructureComponent.logFailures)
                {
                    Debug.Log("Left was not acceptable", componentFromPositionWorld1);
                }
                flag = false;
            }
            if (structureComponent1.type == StructureComponent.StructureComponentType.Pillar)
            {
                flag1 = true;
            }
            else
            {
                if (StructureComponent.logFailures)
                {
                    Debug.Log("Right was not acceptable", structureComponent1);
                }
                flag1 = false;
            }
            return(!flag ? false : flag1);
        }
        if (this.type == StructureComponent.StructureComponentType.Foundation)
        {
            List <StructureMaster> .Enumerator enumerator = StructureMaster.AllStructuresWithBounds.GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    StructureMaster current = enumerator.Current;
                    if (current != master)
                    {
                        if (!current.containedBounds.Intersects(new Bounds(placePos, new Vector3(5f, 5f, 4f))))
                        {
                            continue;
                        }
                        if (StructureComponent.logFailures)
                        {
                            Debug.Log("Too close to something");
                        }
                        flag2 = false;
                        return(flag2);
                    }
                }
                bool flag5 = master.IsValidFoundationSpot(placePos);
                if (StructureComponent.logFailures)
                {
                    Debug.Log(string.Concat(new object[] { "returning here : mastervalid:", flag5, "compinplace", componentFromPositionWorld }));
                }
                return(!flag5 ? false : !componentFromPositionWorld);
            }
            finally
            {
                ((IDisposable)(object)enumerator).Dispose();
            }
            return(flag2);
        }
        if (this.type == StructureComponent.StructureComponentType.Ramp)
        {
            if (componentFromPositionWorld == null && (master.IsValidFoundationSpot(placePos) || structureComponent && (structureComponent.type == StructureComponent.StructureComponentType.Ceiling || structureComponent.type == StructureComponent.StructureComponentType.Foundation)))
            {
                return(true);
            }
            return(false);
        }
        if (this.type == StructureComponent.StructureComponentType.Pillar)
        {
            return((!structureComponent || structureComponent.type != StructureComponent.StructureComponentType.Pillar) && !flag4 ? false : !flag3);
        }
        if (this.type != StructureComponent.StructureComponentType.Stairs && this.type != StructureComponent.StructureComponentType.Ceiling)
        {
            return(false);
        }
        if (flag3)
        {
            return(false);
        }
        Vector3[] vector3Array = new Vector3[] { new Vector3(-2.5f, 0f, -2.5f), new Vector3(2.5f, 0f, 2.5f), new Vector3(-2.5f, 0f, 2.5f), new Vector3(2.5f, 0f, -2.5f) };
        for (int i = 0; i < (int)vector3Array.Length; i++)
        {
            Vector3            vector33            = vector3Array[i];
            StructureComponent structureComponent2 = master.CompByLocal(vector3 + vector33);
            if (structureComponent2 == null || structureComponent2.type != StructureComponent.StructureComponentType.Pillar)
            {
                return(false);
            }
        }
        return(true);
    }