Exemple #1
0
        protected override void CreateStructure(bool isRepair = false)
        {
            if (isRepair)
            {
                base.Clear();
                base.StartCoroutine(base.DelayedAwake(true));
            }
            Vector3 size = this._logRenderer.bounds.size;

            this._logLength = size.y;
            this._logWidth  = size.z;
            int layer = LayerMask.NameToLayer("Prop");

            this._wallRoot        = this.SpawnStructure();
            this._wallRoot.parent = base.transform;
            if (this._wasBuilt)
            {
                GameObject gameObject = this._wallRoot.gameObject;
                gameObject.tag   = "jumpObject";
                gameObject.layer = layer;
                BoxCollider boxCollider = this._wallRoot.gameObject.AddComponent <BoxCollider>();
                Vector3     vector      = base.transform.InverseTransformVector(this._p2 - this._p1);
                boxCollider.size = new Vector3(this._logWidth * 2f, 0.85f * this._logLength, Mathf.Abs(vector.z));
                Vector3 center = boxCollider.size / 2f;
                center.x           = 0f;
                boxCollider.center = center;
                this._wallRoot.gameObject.AddComponent <WeaponHitSfxInfo>()._sfx = SfxInfo.SfxTypes.HitBone;
                this._wallRoot.gameObject.AddComponent <gridObjectBlocker>();
                this._wallRoot.gameObject.AddComponent <BuildingHealthHitRelay>();
                BuildingHealth component = base.GetComponent <BuildingHealth>();
                if (component)
                {
                    component._renderersRoot = this._wallRoot.gameObject;
                    if (BoltNetwork.isRunning)
                    {
                        component.SetMpRandomDistortColliders(new Collider[]
                        {
                            boxCollider
                        });
                    }
                }
            }
        }
Exemple #2
0
        protected override void CreateStructure(bool isRepair = false)
        {
            Renderer renderer = null;

            if (isRepair)
            {
                LOD_GroupToggle component = this._wallRoot.GetComponent <LOD_GroupToggle>();
                if (component)
                {
                    renderer = component._levels[1].Renderers[0];
                }
                base.Clear();
                base.StartCoroutine(base.DelayedAwake(true));
            }
            this._logLength = this._offset;
            this._logWidth  = this._offset;
            int layer = LayerMask.NameToLayer("Prop");

            this._wallRoot        = this.SpawnStructure();
            this._wallRoot.parent = base.transform;
            if (this._wasBuilt)
            {
                this._gridToken = InsideCheck.AddWallChunk(this._p1, this._p2, this._colliderHeight + 0.5f);
                GameObject gameObject = this._wallRoot.gameObject;
                gameObject.tag   = "jumpObject";
                gameObject.layer = layer;
                BoxCollider boxCollider = this._wallRoot.gameObject.AddComponent <BoxCollider>();
                Vector3     vector      = base.transform.InverseTransformVector(this._p2 - this._p1);
                boxCollider.size = new Vector3(this._logWidth, this._colliderHeight, Mathf.Abs(vector.z));
                Vector3 center = boxCollider.size / 2f;
                center.x           = 0f;
                boxCollider.center = center;
                this._wallRoot.gameObject.AddComponent <WeaponHitSfxInfo>()._sfx = SfxInfo.SfxTypes.HitRock;
                this._wallRoot.gameObject.AddComponent <BuildingHealthHitRelay>();
                this._wallRoot.gameObject.AddComponent <gridObjectBlocker>();
                foreach (Renderer renderer2 in this._wallRoot.GetComponentsInChildren <Renderer>())
                {
                    renderer2.transform.rotation *= Quaternion.Euler(UnityEngine.Random.Range(-this._randomFactor, this._randomFactor), UnityEngine.Random.Range(-this._randomFactor, this._randomFactor), UnityEngine.Random.Range(-this._randomFactor, this._randomFactor));
                }
                BuildingHealth component2 = base.GetComponent <BuildingHealth>();
                if (component2)
                {
                    component2._renderersRoot = this._wallRoot.gameObject;
                    if (BoltNetwork.isRunning)
                    {
                        component2.SetMpRandomDistortColliders(new Collider[]
                        {
                            boxCollider
                        });
                    }
                }
                if (!renderer)
                {
                    Transform transform = new GameObject("RockWall LOD").transform;
                    transform.gameObject.layer = 21;
                    transform.parent           = base.transform;
                    transform.localRotation    = Quaternion.identity;
                    transform.localPosition    = Vector3.zero;
                    renderer = transform.gameObject.AddComponent <MeshRenderer>();
                    renderer.sharedMaterial = Prefabs.Instance.RockFenceChunksBuiltPrefabsLOD1[0].sharedMaterial;
                    MeshFilter meshFilter = transform.gameObject.AddComponent <MeshFilter>();
                    int        value      = Mathf.RoundToInt(Vector3.Distance(this._p1, this._p2) / this._offset);
                    int        num        = Mathf.Clamp(value, 0, Prefabs.Instance.RockFenceChunksBuiltPrefabsLOD1.Length - 1);
                    meshFilter.sharedMesh = Prefabs.Instance.RockFenceChunksBuiltPrefabsLOD1[num].GetComponent <MeshFilter>().sharedMesh;
                }
                LOD_GroupToggle lod_GroupToggle = this._wallRoot.gameObject.AddComponent <LOD_GroupToggle>();
                lod_GroupToggle.enabled = false;
                lod_GroupToggle._levels = new LOD_GroupToggle.LodLevel[2];
                Renderer[] componentsInChildren;
                lod_GroupToggle._levels[0] = new LOD_GroupToggle.LodLevel
                {
                    Renderers       = componentsInChildren,
                    VisibleDistance = 50f
                };
                lod_GroupToggle._levels[1] = new LOD_GroupToggle.LodLevel
                {
                    Renderers = new Renderer[]
                    {
                        renderer
                    },
                    VisibleDistance = 10000f
                };
            }
        }
Exemple #3
0
        protected override void CreateStructure(bool isRepair = false)
        {
            Renderer renderer = null;

            if (isRepair)
            {
                LOD_GroupToggle component = this._wallRoot.GetComponent <LOD_GroupToggle>();
                if (component)
                {
                    renderer = component._levels[1].Renderers[0];
                }
                base.Clear();
                base.StartCoroutine(base.DelayedAwake(true));
            }
            Vector3 size = this._logRenderer.bounds.size;

            this._logLength = size.y;
            this._logWidth  = size.z;
            int layer = LayerMask.NameToLayer("Prop");

            this._wallRoot        = this.SpawnStructure();
            this._wallRoot.parent = base.transform;
            if (this._wasBuilt)
            {
                this._gridToken = InsideCheck.AddWallChunk(this._p1, this._p2, this._logLength);
                GameObject gameObject = this._wallRoot.gameObject;
                gameObject.tag   = "structure";
                gameObject.layer = layer;
                BoxCollider boxCollider = this._wallRoot.gameObject.AddComponent <BoxCollider>();
                Vector3     vector      = base.transform.InverseTransformVector(this._p2 - this._p1);
                boxCollider.size = new Vector3(this._logWidth, this._logLength, Mathf.Abs(vector.z));
                Vector3 center = boxCollider.size / 2f;
                center.x           = 0f;
                center.y          -= 1f;
                center.z          -= this._logWidth / 2f;
                boxCollider.center = center;
                BuildingHealth component2 = base.GetComponent <BuildingHealth>();
                if (component2)
                {
                    component2._renderersRoot = this._wallRoot.gameObject;
                    if (BoltNetwork.isRunning)
                    {
                        component2.SetMpRandomDistortColliders(new Collider[]
                        {
                            boxCollider
                        });
                    }
                }
                this._wallRoot.gameObject.AddComponent <BuildingHealthHitRelay>();
                getStructureStrength getStructureStrength = this._wallRoot.gameObject.AddComponent <getStructureStrength>();
                getStructureStrength._type     = getStructureStrength.structureType.wall;
                getStructureStrength._strength = getStructureStrength.strength.veryStrong;
                this._wallRoot.gameObject.AddComponent <gridObjectBlocker>();
                if (!renderer)
                {
                    int       logCost   = this.GetLogCost();
                    bool      flag      = logCost % 2 == 0;
                    bool      flag2     = this._p1.y > this._p2.y;
                    Transform transform = new GameObject("DW LOD Skewer").transform;
                    transform.parent           = base.transform;
                    transform.localEulerAngles = ((!flag2) ? new Vector3(0f, 180f, 0f) : Vector3.zero);
                    transform.position         = this._p1 + transform.forward * (((float)logCost * 0.5f - 0.5f) * (float)((!flag2) ? -1 : 1) * base.LogWidth);
                    Transform transform2 = new GameObject("DW LOD").transform;
                    transform2.gameObject.layer = 21;
                    transform2.parent           = transform;
                    transform2.localPosition    = Vector3.zero;
                    Prefabs.Instance.Constructions._defensiveWallSkewLOD.SetSkew(transform, transform2, transform.eulerAngles.x);
                    renderer = transform2.gameObject.AddComponent <MeshRenderer>();
                    renderer.sharedMaterial = Prefabs.Instance.LogWallDefensiveExBuiltPrefabLOD1[0].sharedMaterial;
                    MeshFilter meshFilter = transform2.gameObject.AddComponent <MeshFilter>();
                    meshFilter.sharedMesh = Prefabs.Instance.LogWallDefensiveExBuiltPrefabLOD1[Mathf.Clamp(logCost, 0, Prefabs.Instance.LogWallDefensiveExBuiltPrefabLOD1.Length - 1)].GetComponent <MeshFilter>().sharedMesh;
                }
                LOD_GroupToggle lod_GroupToggle = this._wallRoot.gameObject.AddComponent <LOD_GroupToggle>();
                lod_GroupToggle.enabled    = false;
                lod_GroupToggle._levels    = new LOD_GroupToggle.LodLevel[2];
                lod_GroupToggle._levels[0] = new LOD_GroupToggle.LodLevel
                {
                    Renderers       = this._wallRoot.GetComponentsInChildren <Renderer>(),
                    VisibleDistance = 100f
                };
                lod_GroupToggle._levels[1] = new LOD_GroupToggle.LodLevel
                {
                    Renderers = new Renderer[]
                    {
                        renderer
                    },
                    VisibleDistance = 10000f
                };
            }
        }
Exemple #4
0
        protected virtual void CreateStructure(bool isRepair = false)
        {
            if (isRepair)
            {
                this.Clear();
                base.StartCoroutine(this.DelayedAwake(true));
            }
            int num = LayerMask.NameToLayer("Prop");

            this._wallRoot        = this.SpawnStructure();
            this._wallRoot.parent = base.transform;
            if (this._wasBuilt)
            {
                this._gridToken = InsideCheck.AddWallChunk(this._p1, this._p2, 4.75f * this._logWidth + 1f);
                if (this._lods)
                {
                    UnityEngine.Object.Destroy(this._lods.gameObject);
                }
                this._lods = new GameObject("lods").AddComponent <WallChunkLods>();
                this._lods.transform.parent = base.transform;
                this._lods.DefineChunk(this._p1, this._p2, 4.44f * this._logWidth, this._wallRoot, this.Addition);
                if (!this._wallCollision)
                {
                    GameObject gameObject = new GameObject("collision");
                    gameObject.transform.parent   = this._wallRoot.parent;
                    gameObject.transform.position = this._wallRoot.position;
                    gameObject.transform.rotation = this._wallRoot.rotation;
                    gameObject.tag      = "structure";
                    this._wallCollision = gameObject.transform;
                    GameObject gameObject2 = this._wallRoot.gameObject;
                    int        layer       = num;
                    gameObject.layer  = layer;
                    gameObject2.layer = layer;
                    float   num3;
                    float   num4;
                    Vector3 size;
                    Vector3 vector;
                    if (this.UseHorizontalLogs)
                    {
                        float num2 = Vector3.Distance(this._p1, this._p2) / this._logLength;
                        num3     = 7.4f * num2;
                        num4     = 6.75f * (0.31f + (num2 - 1f) / 2f);
                        size     = new Vector3(1.75f, 0.9f * this._height * this._logWidth, num3 * 1f);
                        vector   = Vector3.Lerp(this._p1, this._p2, 0.5f);
                        vector   = this._wallRoot.InverseTransformPoint(vector);
                        vector.y = size.y / 2f - this._logWidth / 2f;
                    }
                    else
                    {
                        num3   = this._logWidth * (float)(this._wallRoot.childCount - 1) + 1.5f;
                        num4   = 0f;
                        vector = Vector3.zero;
                        IEnumerator enumerator = this._wallRoot.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                object    obj       = enumerator.Current;
                                Transform transform = (Transform)obj;
                                vector += transform.position;
                            }
                        }
                        finally
                        {
                            IDisposable disposable;
                            if ((disposable = (enumerator as IDisposable)) != null)
                            {
                                disposable.Dispose();
                            }
                        }
                        size     = new Vector3(1.75f, 0.92f * this._height * this._logWidth, num3);
                        vector  /= (float)this._wallRoot.childCount;
                        vector   = this._wallRoot.InverseTransformPoint(vector);
                        vector.y = size.y / 2f - this._logWidth / 2f;
                    }
                    getStructureStrength getStructureStrength = gameObject.AddComponent <getStructureStrength>();
                    getStructureStrength._strength = getStructureStrength.strength.strong;
                    BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>();
                    boxCollider.center    = vector;
                    boxCollider.size      = size;
                    boxCollider.isTrigger = true;
                    BuildingHealth component = base.GetComponent <BuildingHealth>();
                    if (component)
                    {
                        component._renderersRoot = this._wallRoot.gameObject;
                    }
                    WallChunkArchitect.Additions addition = this._addition;
                    if (addition != WallChunkArchitect.Additions.Wall)
                    {
                        BoxCollider boxCollider2 = null;
                        if (this._height > 4f)
                        {
                            vector.y           += this._logWidth * 2f;
                            size.y              = 1f * this._logWidth;
                            boxCollider2        = gameObject.AddComponent <BoxCollider>();
                            boxCollider2.center = vector;
                            boxCollider2.size   = size;
                        }
                        FMOD_StudioEventEmitter.CreateAmbientEmitter(gameObject.transform, gameObject.transform.TransformPoint(vector), "event:/ambient/wind/wind_moan_structures");
                        size.y   = Mathf.Clamp(this._height, 0f, 4f) * this._logWidth;
                        size.z   = num4;
                        vector.y = size.y / 2f - this._logWidth / 2f;
                        vector.z = num3 - num4 / 2f;
                        BoxCollider boxCollider3 = gameObject.AddComponent <BoxCollider>();
                        boxCollider3.center = vector;
                        boxCollider3.size   = size;
                        vector.z            = num4 / 2f;
                        BoxCollider boxCollider4 = gameObject.AddComponent <BoxCollider>();
                        boxCollider4.center = vector;
                        boxCollider4.size   = size;
                        if (this._addition == WallChunkArchitect.Additions.Window)
                        {
                            size.y    = this._logWidth * 1.9f;
                            size.z    = num3 - num4 * 2f;
                            vector.z += num4 / 2f + size.z / 2f;
                            vector.y  = size.y / 2f - this._logWidth / 2f;
                            BoxCollider boxCollider5 = gameObject.AddComponent <BoxCollider>();
                            boxCollider5.center = vector;
                            boxCollider5.size   = size;
                            GameObject     gameObject3    = new GameObject("PerchTarget");
                            SphereCollider sphereCollider = gameObject3.AddComponent <SphereCollider>();
                            sphereCollider.isTrigger     = true;
                            sphereCollider.radius        = 0.145f;
                            gameObject3.transform.parent = this._wallRoot;
                            vector.y += size.y / 2f;
                            gameObject3.transform.localPosition = vector;
                            if (BoltNetwork.isRunning)
                            {
                                if (boxCollider2)
                                {
                                    component.SetMpRandomDistortColliders(new Collider[]
                                    {
                                        boxCollider2,
                                        boxCollider4,
                                        boxCollider3,
                                        boxCollider5
                                    });
                                }
                                else
                                {
                                    component.SetMpRandomDistortColliders(new Collider[]
                                    {
                                        boxCollider4,
                                        boxCollider3,
                                        boxCollider5
                                    });
                                }
                            }
                        }
                        else if (BoltNetwork.isRunning)
                        {
                            component.SetMpRandomDistortColliders(new Collider[]
                            {
                                boxCollider2,
                                boxCollider4,
                                boxCollider3
                            });
                        }
                    }
                    else
                    {
                        BoxCollider boxCollider6 = gameObject.AddComponent <BoxCollider>();
                        boxCollider6.center = vector;
                        boxCollider6.size   = size;
                        if (BoltNetwork.isRunning)
                        {
                            component.SetMpRandomDistortColliders(new Collider[]
                            {
                                boxCollider6
                            });
                        }
                    }
                    gridObjectBlocker gridObjectBlocker = gameObject.AddComponent <gridObjectBlocker>();
                    gridObjectBlocker.ignoreOnDisable = true;
                    addToBuilt addToBuilt = gameObject.AddComponent <addToBuilt>();
                    addToBuilt.addToStructures = true;
                    BuildingHealthHitRelay buildingHealthHitRelay = gameObject.AddComponent <BuildingHealthHitRelay>();
                }
                if (this.Addition >= WallChunkArchitect.Additions.Door1 && this._addition <= WallChunkArchitect.Additions.LockedDoor2 && !isRepair)
                {
                    Vector3 position = Vector3.Lerp(this._p1, this._p2, 0.5f);
                    position.y -= this._logWidth / 2f;
                    Vector3 worldPosition = (this._addition != WallChunkArchitect.Additions.Door1 && this._addition != WallChunkArchitect.Additions.LockedDoor1) ? this._p1 : this._p2;
                    worldPosition.y = position.y;
                    Transform transform2 = UnityEngine.Object.Instantiate <Transform>(Prefabs.Instance.DoorPrefab, position, this._wallRoot.rotation);
                    transform2.LookAt(worldPosition);
                    transform2.parent = base.transform;
                }
            }
        }
        protected override void CreateStructure(bool isRepair = false)
        {
            if (isRepair)
            {
                base.Clear();
                base.StartCoroutine(base.DelayedAwake(true));
            }
            Vector3 size = this._logRenderer.bounds.size;

            this._logLength       = size.y;
            this._logWidth        = size.z;
            this._wallRoot        = this.SpawnStructure();
            this._wallRoot.parent = base.transform;
            if (this._wasBuilt)
            {
                this._gridToken = InsideCheck.AddWallChunk(this._p1, this._p2, this._logLength);
                Vector3 vector  = this._wallRoot.InverseTransformVector(this._p2 - this._p1);
                Vector3 vector2 = new Vector3(this._logWidth, this._logLength, (!this.Is2Sided) ? Mathf.Abs(vector.z) : Mathf.Abs(vector.z / 2f));
                Vector3 center  = vector2 / 2f;
                center.x  = 0f;
                center.y -= 1f;
                center.z -= this._logWidth / 2f;
                GameObject gameObject = this._wallRoot.GetChild(0).gameObject;
                gameObject.tag   = "structure";
                gameObject.layer = LayerMask.NameToLayer("Prop");
                Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();
                rigidbody.useGravity  = false;
                rigidbody.isKinematic = true;
                BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>();
                boxCollider.size   = vector2;
                boxCollider.center = center;
                gameObject.AddComponent <gridObjectBlocker>();
                gameObject.AddComponent <BuildingHealthHitRelay>();
                getStructureStrength getStructureStrength = gameObject.AddComponent <getStructureStrength>();
                getStructureStrength._type     = getStructureStrength.structureType.wall;
                getStructureStrength._strength = getStructureStrength.strength.veryStrong;
                GameObject gameObject2;
                if (this._wallRoot.childCount > 1)
                {
                    gameObject2       = this._wallRoot.GetChild(1).gameObject;
                    gameObject2.tag   = "structure";
                    gameObject2.layer = LayerMask.NameToLayer("Prop");
                    Rigidbody rigidbody2 = gameObject2.AddComponent <Rigidbody>();
                    rigidbody2.useGravity  = false;
                    rigidbody2.isKinematic = true;
                    boxCollider            = gameObject2.AddComponent <BoxCollider>();
                    boxCollider.size       = vector2;
                    boxCollider.center     = center;
                    gameObject2.AddComponent <gridObjectBlocker>();
                    gameObject2.AddComponent <BuildingHealthHitRelay>();
                    getStructureStrength getStructureStrength2 = gameObject2.AddComponent <getStructureStrength>();
                    getStructureStrength2._type     = getStructureStrength.structureType.wall;
                    getStructureStrength2._strength = getStructureStrength.strength.veryStrong;
                }
                else
                {
                    gameObject2 = null;
                }
                WallDefensiveGate wallDefensiveGate = UnityEngine.Object.Instantiate <WallDefensiveGate>(Prefabs.Instance.WallDefensiveGateTriggerPrefab);
                wallDefensiveGate.transform.parent        = this._wallRoot;
                wallDefensiveGate.transform.position      = new Vector3(this._wallRoot.position.x, this._wallRoot.position.y + 4f, this._wallRoot.position.z);
                wallDefensiveGate.transform.localRotation = Quaternion.identity;
                wallDefensiveGate._target1 = gameObject.transform;
                wallDefensiveGate._target2 = ((!gameObject2) ? null : gameObject2.transform);
                BuildingHealth component = base.GetComponent <BuildingHealth>();
                if (component)
                {
                    component._renderersRoot = this._wallRoot.gameObject;
                    if (BoltNetwork.isRunning)
                    {
                        component.SetMpRandomDistortColliders(new Collider[]
                        {
                            boxCollider
                        });
                    }
                }
            }
        }