// Token: 0x06003DB2 RID: 15794 RVA: 0x000DDBB4 File Offset: 0x000DBDB4
        public void Add(global::StructureComponent toAdd)
        {
            switch (toAdd.type)
            {
            case global::StructureComponent.StructureComponentType.Pillar:
                this._pillar = toAdd;
                break;

            case global::StructureComponent.StructureComponentType.Wall:
            case global::StructureComponent.StructureComponentType.Doorway:
            case global::StructureComponent.StructureComponentType.WindowWall:
                this._wall = toAdd;
                break;

            case global::StructureComponent.StructureComponentType.Ceiling:
                this._ceiling = toAdd;
                break;

            case global::StructureComponent.StructureComponentType.Stairs:
                this._stairs = toAdd;
                break;

            case global::StructureComponent.StructureComponentType.Foundation:
                this._foundation = toAdd;
                break;
            }
        }
 // Token: 0x06003D8D RID: 15757 RVA: 0x000DC86C File Offset: 0x000DAA6C
 public void RemoveLinkForComp(global::StructureComponent comp)
 {
     if (this._weightOnMe.ContainsKey(comp))
     {
         foreach (global::StructureComponent key in this._weightOnMe[comp])
         {
             if (this._hasWeightOn[key].Contains(comp))
             {
                 this._hasWeightOn[key].Remove(comp);
                 if (this._hasWeightOn[key].Count == 0)
                 {
                     this._hasWeightOn.Remove(key);
                 }
             }
         }
         this._weightOnMe.Remove(comp);
     }
     if (this._hasWeightOn.ContainsKey(comp))
     {
         foreach (global::StructureComponent key2 in this._hasWeightOn[comp])
         {
             if (this._weightOnMe[key2].Contains(comp))
             {
                 this._weightOnMe[key2].Remove(comp);
                 if (this._weightOnMe[key2].Count == 0)
                 {
                     this._weightOnMe.Remove(key2);
                 }
             }
         }
         this._hasWeightOn.Remove(comp);
     }
 }
 // Token: 0x06003D9D RID: 15773 RVA: 0x000DD274 File Offset: 0x000DB474
 protected void AppendStructureComponent(global::StructureComponent comp, bool nobind)
 {
     if (comp.type == global::StructureComponent.StructureComponentType.Foundation && this._materialType == global::StructureMaster.StructureMaterialType.UNSET)
     {
         this.SetMaterialType(comp.GetMaterialType());
     }
     this._structureComponents.Add(comp);
     this.AddCompPositionEntry(comp);
     this.GenerateLinkForComp(comp);
     this.RecalculateStructureLinks();
     this.MarkBoundsDirty();
     if (!nobind)
     {
         try
         {
             comp.OnOwnedByMasterStructure(this);
         }
         catch (Exception ex)
         {
             Debug.LogError(ex);
         }
     }
     if (this._structureComponents.Count == 1)
     {
         global::StructureMaster.g_StructuresWithBounds.Add(this);
     }
     if (this.meshBatchTargetGraphical)
     {
         foreach (MeshBatchInstance meshBatchInstance in comp.GetComponentsInChildren <MeshBatchInstance>(true))
         {
             meshBatchInstance.graphicalTarget = this.meshBatchTargetGraphical;
         }
     }
 }
    // Token: 0x06003DAD RID: 15789 RVA: 0x000DDA9C File Offset: 0x000DBC9C
    public int FindComponentID(global::StructureComponent component)
    {
        int num = 0;

        foreach (global::StructureComponent structureComponent in this._structureComponents)
        {
            if (!(structureComponent != component))
            {
                return(num);
            }
            num++;
        }
        return(-1);
    }
 // Token: 0x06003DAC RID: 15788 RVA: 0x000DDA40 File Offset: 0x000DBC40
 public bool CullComponent(global::StructureComponent component)
 {
     if (component && this._structureComponents.Remove(component))
     {
         this.RemoveCompPositionEntry(component);
         this.RecalculateStructureLinks();
         this.MarkBoundsDirty();
         if (this._structureComponents.Count == 0)
         {
             global::StructureMaster.g_StructuresWithBounds.Remove(this);
         }
         return(true);
     }
     return(false);
 }
    // Token: 0x06003D97 RID: 15767 RVA: 0x000DD184 File Offset: 0x000DB384
    public bool RemoveCompPositionEntry(global::StructureComponent comp)
    {
        Vector3 v = this.LocalIndexRound(base.transform.InverseTransformPoint(comp.transform.position));
        global::StructureComponentKey key = new global::StructureComponentKey(v);

        global::StructureMaster.CompPosNode compPosNode;
        if (this._structureComponentsByPosition.TryGetValue(key, out compPosNode))
        {
            compPosNode.Remove(comp);
            if (compPosNode.GetAny())
            {
                this._structureComponentsByPosition.Remove(key);
            }
            return(true);
        }
        return(false);
    }
    // Token: 0x06003D96 RID: 15766 RVA: 0x000DD118 File Offset: 0x000DB318
    public bool AddCompPositionEntry(global::StructureComponent comp)
    {
        Vector3 v = this.LocalIndexRound(base.transform.InverseTransformPoint(comp.transform.position));
        global::StructureComponentKey key = new global::StructureComponentKey(v);

        global::StructureMaster.CompPosNode compPosNode;
        if (this._structureComponentsByPosition.TryGetValue(key, out compPosNode))
        {
            compPosNode.Add(comp);
        }
        else
        {
            compPosNode = new global::StructureMaster.CompPosNode();
            compPosNode.Add(comp);
            this._structureComponentsByPosition.Add(key, compPosNode);
        }
        return(true);
    }
 // Token: 0x06003D8B RID: 15755 RVA: 0x000DC7C0 File Offset: 0x000DA9C0
 public void AddWeightLink(global::StructureComponent me, global::StructureComponent weight)
 {
     if (this._weightOnMe.ContainsKey(me))
     {
         this._weightOnMe[me].Add(weight);
     }
     else
     {
         this._weightOnMe.Add(me, new HashSet <global::StructureComponent>());
         this._weightOnMe[me].Add(weight);
     }
     if (this._hasWeightOn.ContainsKey(weight))
     {
         this._hasWeightOn[weight].Add(me);
     }
     else
     {
         this._hasWeightOn.Add(weight, new HashSet <global::StructureComponent>());
         this._hasWeightOn[weight].Add(me);
     }
 }
 // Token: 0x06003DB4 RID: 15796 RVA: 0x000DDCBC File Offset: 0x000DBEBC
 public void Remove(global::StructureComponent toRemove)
 {
     if (this._wall == toRemove)
     {
         this._wall = null;
     }
     else if (this._foundation == toRemove)
     {
         this._foundation = null;
     }
     else if (this._pillar == toRemove)
     {
         this._pillar = null;
     }
     else if (this._stairs == toRemove)
     {
         this._stairs = null;
     }
     else if (this._ceiling == toRemove)
     {
         this._ceiling = null;
     }
 }
Example #10
0
    // Token: 0x060039E7 RID: 14823 RVA: 0x000CC388 File Offset: 0x000CA588
    public virtual void RenderDeployPreview(Vector3 point, Quaternion rot)
    {
        if (this._prefabRenderer == null)
        {
            T datablock = this.datablock;
            global::StructureComponent structureToPlacePrefab = datablock.structureToPlacePrefab;
            if (!structureToPlacePrefab)
            {
                return;
            }
            this._prefabRenderer = global::PrefabRenderer.GetOrCreateRender(structureToPlacePrefab.gameObject);
            this._materialProps  = new MaterialPropertyBlock();
        }
        Material overrideMat = this.datablock.overrideMat;

        if (overrideMat)
        {
            this._prefabRenderer.RenderOneMaterial(global::MountedCamera.main.camera, Matrix4x4.TRS(point, rot, Vector3.one), this._materialProps, overrideMat);
        }
        else
        {
            this._prefabRenderer.Render(global::MountedCamera.main.camera, Matrix4x4.TRS(point, rot, Vector3.one), this._materialProps, null);
        }
    }
Example #11
0
    // Token: 0x060039E4 RID: 14820 RVA: 0x000CBE54 File Offset: 0x000CA054
    protected void RenderPlacementHelpers()
    {
        T datablock = this.datablock;
        global::StructureComponent structureToPlacePrefab = datablock.structureToPlacePrefab;

        this._master       = null;
        this._placePos     = Vector3.zero;
        this._placeRot     = Quaternion.identity;
        this.validLocation = false;
        float axis = Input.GetAxis("Mouse ScrollWheel");

        if (axis > 0f)
        {
            this.desiredRotation *= Quaternion.AngleAxis(90f, Vector3.up);
        }
        else if (axis < 0f)
        {
            this.desiredRotation *= Quaternion.AngleAxis(-90f, Vector3.up);
        }
        global::Character character = base.character;

        if (character == null)
        {
            return;
        }
        Ray        eyesRay = character.eyesRay;
        float      num     = (structureToPlacePrefab.type != global::StructureComponent.StructureComponentType.Ceiling) ? 8f : 4f;
        Vector3    vector  = Vector3.zero;
        Vector3    vector2 = Vector3.up;
        Vector3    zero    = Vector3.zero;
        RaycastHit raycastHit;
        bool       flag;

        if (Physics.Raycast(eyesRay, ref raycastHit, num))
        {
            vector  = raycastHit.point;
            vector2 = raycastHit.normal;
            flag    = true;
        }
        else
        {
            flag   = false;
            vector = eyesRay.origin + eyesRay.direction * num;
        }
        switch (structureToPlacePrefab.type)
        {
        case global::StructureComponent.StructureComponentType.Ceiling:
        case global::StructureComponent.StructureComponentType.Foundation:
        case global::StructureComponent.StructureComponentType.Ramp:
            vector.y -= 3.5f;
            break;
        }
        bool       flag2    = false;
        bool       flag3    = false;
        Vector3    placePos = vector;
        Quaternion placeRot = global::TransformHelpers.LookRotationForcedUp(character.eyesAngles.forward, Vector3.up) * this.desiredRotation;

        foreach (global::StructureMaster structureMaster in global::StructureMaster.RayTestStructures(eyesRay))
        {
            if (structureMaster)
            {
                int num2;
                int num3;
                int num4;
                structureMaster.GetStructureSize(out num2, out num3, out num4);
                this._placePos = global::StructureMaster.SnapToGrid(structureMaster.transform, vector, true);
                this._placeRot = global::TransformHelpers.LookRotationForcedUp(structureMaster.transform.forward, structureMaster.transform.transform.up) * this.desiredRotation;
                if (!flag3)
                {
                    placePos = this._placePos;
                    placeRot = this._placeRot;
                    flag3    = true;
                }
                if (structureToPlacePrefab.CheckLocation(structureMaster, this._placePos, this._placeRot))
                {
                    this._master = structureMaster;
                    flag2        = true;
                    break;
                }
            }
        }
        if (!flag2)
        {
            if (structureToPlacePrefab.type == global::StructureComponent.StructureComponentType.Foundation)
            {
                if (flag && raycastHit.collider is TerrainCollider)
                {
                    bool flag4 = false;
                    foreach (global::StructureMaster structureMaster2 in global::StructureMaster.AllStructuresWithBounds)
                    {
                        if (structureMaster2.containedBounds.Intersects(new Bounds(vector, new Vector3(5f, 5f, 4f))))
                        {
                            flag4 = true;
                            break;
                        }
                    }
                    if (!flag4)
                    {
                        this._placePos     = vector;
                        this._placeRot     = global::TransformHelpers.LookRotationForcedUp(character.eyesAngles.forward, Vector3.up) * this.desiredRotation;
                        this.validLocation = true;
                    }
                }
                else
                {
                    this._placePos     = placePos;
                    this._placeRot     = placeRot;
                    this.validLocation = false;
                }
            }
            else
            {
                this._placePos     = placePos;
                this._placeRot     = placeRot;
                this.validLocation = false;
            }
        }
        else
        {
            this.validLocation = true;
        }
        T datablock2 = this.datablock;

        if (!datablock2.CheckBlockers(this._placePos))
        {
            this.validLocation = false;
        }
        Color color = Color.red;

        if (this.validLocation)
        {
            color = Color.green;
        }
        color.a = 0.5f + Mathf.Abs(Mathf.Sin(Time.time * 8f)) * 0.25f;
        if (this._materialProps != null)
        {
            this._materialProps.Clear();
            this._materialProps.AddColor("_EmissionColor", color);
            this._materialProps.AddVector("_MainTex_ST", new Vector4(1f, 1f, 0f, Mathf.Repeat(Time.time, 30f)));
        }
        if (!this.validLocation)
        {
            this._placePos = vector;
        }
        this.RenderDeployPreview(this._placePos, this._placeRot);
    }
 // Token: 0x06003D9C RID: 15772 RVA: 0x000DD268 File Offset: 0x000DB468
 internal void AppendStructureComponent(global::StructureComponent comp)
 {
     this.AppendStructureComponent(comp, false);
 }
    // Token: 0x06003D66 RID: 15718 RVA: 0x000DBB30 File Offset: 0x000D9D30
    public virtual bool CheckLocation(global::StructureMaster master, Vector3 placePos, Quaternion placeRot)
    {
        bool    flag   = false;
        bool    flag2  = false;
        Vector3 vector = master.transform.InverseTransformPoint(placePos);

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

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

        if (this.type != global::StructureComponent.StructureComponentType.Foundation)
        {
            bool foundationForPoint = master.GetFoundationForPoint(placePos);
            if (foundationForPoint)
            {
                flag2 = true;
            }
        }
        if (this.type == global::StructureComponent.StructureComponentType.Wall || this.type == global::StructureComponent.StructureComponentType.Doorway || this.type == global::StructureComponent.StructureComponentType.WindowWall)
        {
            if (flag)
            {
                return(false);
            }
            Vector3 vector2 = placePos + placeRot * -Vector3.right * 2.5f;
            global::StructureComponent componentFromPositionWorld2 = master.GetComponentFromPositionWorld(vector2);
            Vector3 vector3 = placePos + placeRot * Vector3.right * 2.5f;
            global::StructureComponent componentFromPositionWorld3 = master.GetComponentFromPositionWorld(vector3);
            if (global::StructureComponent.logFailures)
            {
                Debug.DrawLine(vector2, vector3, Color.cyan);
            }
            if (componentFromPositionWorld2 && componentFromPositionWorld3)
            {
                bool flag3;
                if (componentFromPositionWorld2.type != global::StructureComponent.StructureComponentType.Pillar)
                {
                    if (global::StructureComponent.logFailures)
                    {
                        Debug.Log("Left was not acceptable", componentFromPositionWorld2);
                    }
                    flag3 = false;
                }
                else
                {
                    flag3 = true;
                }
                bool flag4;
                if (componentFromPositionWorld3.type != global::StructureComponent.StructureComponentType.Pillar)
                {
                    if (global::StructureComponent.logFailures)
                    {
                        Debug.Log("Right was not acceptable", componentFromPositionWorld3);
                    }
                    flag4 = false;
                }
                else
                {
                    flag4 = true;
                }
                return(flag3 && flag4);
            }
            if (global::StructureComponent.logFailures)
            {
                if (!componentFromPositionWorld2)
                {
                    Debug.Log("Did not find left");
                }
                if (!componentFromPositionWorld3)
                {
                    Debug.Log("Did not find right");
                }
            }
            return(false);
        }
        else
        {
            if (this.type == global::StructureComponent.StructureComponentType.Foundation)
            {
                foreach (global::StructureMaster structureMaster in global::StructureMaster.AllStructuresWithBounds)
                {
                    if (!(structureMaster == master))
                    {
                        if (structureMaster.containedBounds.Intersects(new Bounds(placePos, new Vector3(5f, 5f, 4f))))
                        {
                            if (global::StructureComponent.logFailures)
                            {
                                Debug.Log("Too close to something");
                            }
                            return(false);
                        }
                    }
                }
                bool flag5 = master.IsValidFoundationSpot(placePos);
                if (global::StructureComponent.logFailures)
                {
                    Debug.Log(string.Concat(new object[]
                    {
                        "returning here : mastervalid:",
                        flag5,
                        "compinplace",
                        componentFromPositionWorld
                    }));
                }
                return(flag5 && !componentFromPositionWorld);
            }
            if (this.type == global::StructureComponent.StructureComponentType.Ramp)
            {
                return(componentFromPositionWorld == null && (master.IsValidFoundationSpot(placePos) || (structureComponent && (structureComponent.type == global::StructureComponent.StructureComponentType.Ceiling || structureComponent.type == global::StructureComponent.StructureComponentType.Foundation))));
            }
            if (this.type == global::StructureComponent.StructureComponentType.Pillar)
            {
                return(((structureComponent && structureComponent.type == global::StructureComponent.StructureComponentType.Pillar) || flag2) && !flag);
            }
            if (this.type != global::StructureComponent.StructureComponentType.Stairs && this.type != global::StructureComponent.StructureComponentType.Ceiling)
            {
                return(false);
            }
            if (flag)
            {
                return(false);
            }
            Vector3[] array = 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 array)
            {
                global::StructureComponent structureComponent2 = master.CompByLocal(vector + vector4);
                if (structureComponent2 == null || structureComponent2.type != global::StructureComponent.StructureComponentType.Pillar)
                {
                    return(false);
                }
            }
            return(true);
        }
    }
    // Token: 0x06003D8E RID: 15758 RVA: 0x000DC9FC File Offset: 0x000DABFC
    public void GenerateLinkForComp(global::StructureComponent comp)
    {
        if (this._hasWeightOn == null)
        {
            this._hasWeightOn = new Dictionary <global::StructureComponent, HashSet <global::StructureComponent> >();
        }
        if (this._weightOnMe == null)
        {
            this._weightOnMe = new Dictionary <global::StructureComponent, HashSet <global::StructureComponent> >();
        }
        Vector3 vector = this.LocalIndexRound(base.transform.InverseTransformPoint(comp.transform.position));

        if (comp.type == global::StructureComponent.StructureComponentType.Wall || comp.type == global::StructureComponent.StructureComponentType.Doorway || comp.type == global::StructureComponent.StructureComponentType.WindowWall)
        {
            Vector3 worldPos = comp.transform.position + comp.transform.rotation * -Vector3.right * 2.5f;
            global::StructureComponent componentFromPositionWorld = this.GetComponentFromPositionWorld(worldPos);
            Vector3 worldPos2 = comp.transform.position + comp.transform.rotation * Vector3.right * 2.5f;
            global::StructureComponent componentFromPositionWorld2 = this.GetComponentFromPositionWorld(worldPos2);
            if (componentFromPositionWorld && componentFromPositionWorld.type == global::StructureComponent.StructureComponentType.Pillar)
            {
                this.AddWeightLink(componentFromPositionWorld, comp);
            }
            if (componentFromPositionWorld2 && componentFromPositionWorld2.type == global::StructureComponent.StructureComponentType.Pillar)
            {
                this.AddWeightLink(componentFromPositionWorld2, comp);
            }
        }
        else if (comp.type == global::StructureComponent.StructureComponentType.Pillar)
        {
            global::StructureComponent structureComponent = this.CompByLocal(vector - new Vector3(0f, global::StructureMaster.gridSpacingY, 0f), global::StructureComponent.StructureComponentType.Pillar);
            if (structureComponent)
            {
                this.AddWeightLink(structureComponent, comp);
            }
            float     num   = -global::StructureMaster.gridSpacingY;
            Vector3[] array = new Vector3[]
            {
                new Vector3(-2.5f, num, -2.5f),
                new Vector3(2.5f, num, 2.5f),
                new Vector3(-2.5f, num, 2.5f),
                new Vector3(2.5f, num, -2.5f),
                new Vector3(2.5f, num, 0f),
                new Vector3(-2.5f, num, 0f),
                new Vector3(0f, num, 2.5f),
                new Vector3(0f, num, -2.5f),
                new Vector3(0f, num, 0f)
            };
            foreach (Vector3 vector2 in array)
            {
                global::StructureComponent structureComponent2 = this.CompByLocal(vector + vector2, global::StructureComponent.StructureComponentType.Foundation);
                global::StructureComponent structureComponent3 = this.CompByLocal(vector + vector2, global::StructureComponent.StructureComponentType.Ceiling);
                if (structureComponent2)
                {
                    this.AddWeightLink(structureComponent2, comp);
                }
                if (structureComponent3)
                {
                    this.AddWeightLink(structureComponent3, comp);
                }
            }
        }
        else if (comp.type == global::StructureComponent.StructureComponentType.Ceiling)
        {
            Vector3[] array3 = 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 vector3 in array3)
            {
                global::StructureComponent structureComponent4 = this.CompByLocal(vector + vector3, global::StructureComponent.StructureComponentType.Pillar);
                if (structureComponent4 != null)
                {
                    this.AddWeightLink(structureComponent4, comp);
                }
            }
        }
        else if (comp.type == global::StructureComponent.StructureComponentType.Ramp)
        {
            global::StructureComponent structureComponent5 = this.CompByLocal(vector - new Vector3(0f, global::StructureMaster.gridSpacingY, 0f));
            if (structureComponent5)
            {
                this.AddWeightLink(structureComponent5, comp);
            }
        }
        else if (comp.type == global::StructureComponent.StructureComponentType.Foundation)
        {
            global::StructureComponent structureComponent6 = this.CompByLocal(vector - new Vector3(0f, global::StructureMaster.gridSpacingY, 0f), global::StructureComponent.StructureComponentType.Foundation);
            if (structureComponent6)
            {
                if (structureComponent6 != comp)
                {
                    this.AddWeightLink(structureComponent6, comp);
                }
                else
                {
                    Debug.Log("MAJOR FUCKUP");
                }
            }
        }
        else if (comp.type == global::StructureComponent.StructureComponentType.Stairs)
        {
            Vector3[] array5 = 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 array5)
            {
                global::StructureComponent structureComponent7 = this.CompByLocal(vector + vector4, global::StructureComponent.StructureComponentType.Pillar);
                if (structureComponent7 != null && structureComponent7.type == global::StructureComponent.StructureComponentType.Pillar)
                {
                    this.AddWeightLink(structureComponent7, comp);
                }
            }
        }
    }
 // Token: 0x06003D90 RID: 15760 RVA: 0x000DD018 File Offset: 0x000DB218
 public bool CheckIsWall(global::StructureComponent wallTest)
 {
     return(wallTest != null && wallTest.IsWallType());
 }
 // Token: 0x06003D91 RID: 15761 RVA: 0x000DD030 File Offset: 0x000DB230
 public bool ComponentCarryingWeight(global::StructureComponent comp)
 {
     return(this._weightOnMe != null && this._weightOnMe.ContainsKey(comp) && this._weightOnMe[comp].Count > 0);
 }
 // Token: 0x06003D9E RID: 15774 RVA: 0x000DD360 File Offset: 0x000DB560
 public bool RemoveComponent(global::StructureComponent comp)
 {
     this.RecalculateStructureLinks();
     this.MarkBoundsDirty();
     return(true);
 }