예제 #1
0
    public BuildingAction[] GetBuildingActionOptions(Vector3Int position)
    {
        if (!HasActiveBuilding(position))
        {
            Debug.LogError($"Position {position} does not have a working building to act on");
            return(null);
        }

        List <BuildingAction> options       = new List <BuildingAction>();
        GameObject            buildingLogic = _positionToBuildingLogic[position];

        if (buildingLogic.GetComponent <BuildingLogicBase>().CanUpgradeProduction())
        {
            options.Add(BuildingAction.UPGRADE_PRODUCTION);
        }
        BuildingHealth buildingHealth = buildingLogic.GetComponent <BuildingHealth>();

        if (buildingHealth.CanUpgradeHealth())
        {
            options.Add(BuildingAction.UPGRADE_HEALTH);
        }
        if (buildingHealth.CurrentHealth < buildingHealth.MaxHealth)
        {
            options.Add(BuildingAction.REPAIR);
        }
        return(options.ToArray());
    }
예제 #2
0
        private void SetupRepairButton(AbstractBuildingTile tile, AbstractMarketManager manager)
        {
            int            price          = tile.Building.Data.RepairCost;
            BuildingHealth buildingHealth = tile.Building.GetComponent <BuildingHealth>();

            float percentage = buildingHealth.CurrentBuildingHealthPercentage;

            price = (int)((1 - percentage) * price);

            repairText.text = price.ToString();

            if (!CanAffort(price))
            {
                BlockButton(btnRepair);
                return;
            }

            UnblockButton(btnRepair);

            SetButton(btnRepair, OnClick);

            void OnClick()
            {
                ReduceMoney(price);

                buildingHealth.ResetBuildingHealth();
                manager.CloseMarket();
            }
        }
예제 #3
0
    private void ApplyTooltip(Vector3Int mapPosition, SelectionCoinController coinController, BuildingManager.BuildingAction buildingAction)
    {
        GameObject        buildingLogic = BuildingManager.instance._positionToBuildingLogic[mapPosition];
        BuildingHealth    health        = buildingLogic.GetComponent <BuildingHealth>();
        BuildingLogicBase logic         = buildingLogic.GetComponent <BuildingLogicBase>();

        switch (buildingAction)
        {
        case BuildingManager.BuildingAction.UPGRADE_HEALTH:
            coinController.titleText = "Upgrade: Add Walls";
            coinController.bodyText  = "Add walls to the building, upgrading its health.";
            coinController.cost      = BuildingManager.GetHealthUpgradeCost(health);
            coinController.benefit   = health.PredictHealthUpgradeIncrease();
            return;

        case BuildingManager.BuildingAction.UPGRADE_PRODUCTION:
            coinController.titleText = "Upgrade: Renovate Building";
            coinController.bodyText  = "Improve the efficiency of this building.";
            coinController.cost      = BuildingManager.GetProductionUpgradeCost(logic);
            return;

        case BuildingManager.BuildingAction.REPAIR:
            coinController.titleText = "Repair";
            coinController.bodyText  = "Repair this building to full health. Cost based on damage.";
            coinController.cost      = BuildingManager.instance.GetRepairCost(health);
            coinController.benefit   = health.MaxHealth - health.CurrentHealth;
            return;
        }
    }
예제 #4
0
 public void RestoreSafe()
 {
     if (this.TrapTrigger)
     {
         this.TrapTrigger.SendMessage("releaseTrapped", SendMessageOptions.DontRequireReceiver);
     }
     else
     {
         trapTrigger componentInChildren = base.transform.root.GetComponentInChildren <trapTrigger>();
         if (componentInChildren != null)
         {
             componentInChildren.releaseTrapped();
         }
     }
     if (!BoltNetwork.isRunning)
     {
         GameObject     gameObject        = UnityEngine.Object.Instantiate <GameObject>(this.Built, this.Ghost.transform.position, this.Ghost.transform.rotation);
         BuildingHealth componentInParent = base.GetComponentInParent <BuildingHealth>();
         quickBuild     component         = gameObject.GetComponent <quickBuild>();
         if (componentInParent && componentInParent.Hp < componentInParent._maxHP && component)
         {
             component.newBuildingDamage = componentInParent._maxHP - componentInParent.Hp;
         }
         TreeStructure component2 = this.Ghost.GetComponent <TreeStructure>();
         if (component2 && component)
         {
             component.TreeId = component2.TreeId;
         }
         if (this.Ghost)
         {
             UnityEngine.Object.Destroy(this.Ghost);
         }
     }
 }
예제 #5
0
        private static void SpawnBuildings()
        {
            for (int y = 0; y < grid.GetLength(0); y++)
            {
                for (int x = 0; x < grid.GetLength(1); x++)
                {
                    AbstractTile tile = grid[y, x];

                    if (!(tile is AbstractBuildingTile buildingTile))
                    {
                        continue;
                    }

                    TileData tileData = UserSettings.GameData.GridData[new Vector2IntSerializable(x, y)];

                    buildingTile.SetSoilType(tileData.SoilType);
                    buildingTile.SetFoundationType(tileData.FoundationType);
                    buildingTile.SetBuildingType(tileData.BuildingType);

                    if (tileData.HasDebris)
                    {
                        buildingTile.SpawnDebris(tileData.BuildingType, tileData.BuildingTier);
                        continue;
                    }

                    // If there's a building, the tier would be higher than 0
                    if (tileData.BuildingTier > 0)
                    {
                        buildingTile.SpawnBuilding(false);

                        BuildingHealth buildingHealth = buildingTile.Building.GetComponent <BuildingHealth>();

                        buildingHealth.SetCurrentHealth(tileData.SoilHealth, tileData.FoundationHealth, tileData.BuildingHealth);
                    }
                    else
                    {
                        if (tileData.HasSoil)
                        {
                            buildingTile.SpawnSoil();

                            if (tileData.HasFoundation)
                            {
                                buildingTile.SpawnFoundation();
                            }
                        }

                        continue;
                    }

                    BuildingUpgrade buildingUpgrade = buildingTile.Building.GetComponent <BuildingUpgrade>();

                    while (buildingTile.Building.CurrentTier != tileData.BuildingTier)
                    {
                        buildingUpgrade.Upgrade();
                    }
                }
            }
        }
예제 #6
0
        private void Awake()
        {
            animator       = GetComponent <Animator>();
            buildingHealth = GetComponentInParent <BuildingHealth>();

            buildingHealth.OnBuildingRepair   += TriggerRepairPopup;
            buildingHealth.OnFoundationRepair += TriggerRepairPopup;
            buildingHealth.OnSoilRepair       += TriggerRepairPopup;
        }
    /// <summary>
    /// Starts the battle.
    /// </summary>
    /// <param name="_friendlyUnits">List of friendly units to have in the battle.</param>
    /// <param name="_enemyUnits">List of enemy units to have in the battle.</param>
    public void StartSiege(BuildingHealth _building, List <Unit> _enemyUnits)
    {
        enemyGroups    = new List <EnemyBehaviour>();
        buildingHealth = _building;

        enemyUnits     = _enemyUnits;
        buildingHealth = _building;

        m_currentTimer = m_siegeTimer;
        m_siegeStarted = true;
    }
예제 #8
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.collider.tag == "MainHome")
     {
         BuildingHealth buildingHealth = collision.collider.GetComponent <BuildingHealth>();
         if (buildingHealth != null)
         {
             buildingHealth.TakeDamage(damage);
         }
         Destroy(this.gameObject);
     }
 }
 protected void OnDeserialized()
 {
     if (!this._initialized && (!BoltNetwork.isRunning || (base.entity && base.entity.isAttached)))
     {
         if (!this._chunk)
         {
             this._chunk = base.GetComponentInParent <WallDefensiveChunkArchitect>();
             if (!this._chunk)
             {
                 if (!BoltNetwork.isRunning)
                 {
                     UnityEngine.Object.Destroy(base.gameObject);
                 }
                 return;
             }
         }
         if (!this._chunk.Reinforcement)
         {
             this._chunk.Reinforcement = this;
         }
         if (!this._chunk.Reinforcement.Equals(this) && !BoltNetwork.isClient)
         {
             if (BoltNetwork.isRunning)
             {
                 BoltNetwork.Destroy(base.gameObject);
             }
             else
             {
                 UnityEngine.Object.Destroy(base.gameObject);
             }
             return;
         }
         if (BoltNetwork.isServer)
         {
             base.StartCoroutine(this.SetParentHack(this._chunk.GetComponent <BoltEntity>()));
         }
         this._initialized = true;
         if (this._wasBuilt)
         {
             BuildingHealth component = this._chunk.GetComponent <BuildingHealth>();
             component._maxHP *= this._hpBonus;
             this.CreateStructure(false);
             this._wallRoot.transform.parent = base.transform;
         }
         else
         {
             base.transform.position = Vector3.Lerp(this._chunk.P2, this._chunk.P1, 0.5f);
             this.CreateStructure(false);
             base.StartCoroutine(this.OnPlaced());
         }
     }
 }
예제 #10
0
        void IAnchorableStructure.AnchorDestroyed(StructureAnchor anchor)
        {
            BuildingHealth component = base.GetComponent <BuildingHealth>();

            if (component)
            {
                component.Collapse(anchor.transform.position);
            }
            else if (base.gameObject)
            {
                UnityEngine.Object.Destroy(base.gameObject);
            }
        }
예제 #11
0
        private void OnSelectedBuilding(SelectedBuildingTileEvent selectedBuildingEvent)
        {
            AbstractBuildingTile tile = selectedBuildingEvent.Tile;

            if (tile == null || tile.HasDebris)
            {
                SetActive(false);
                return;
            }

            selectedTile   = tile;
            buildingHealth = tile.Building.GetComponent <BuildingHealth>();

            SetActive(true);
            SetButtons();
        }
예제 #12
0
    public int GetRepairCost(BuildingHealth health)
    {
        int healthLost   = health.MaxHealth - health.CurrentHealth;
        int buildingCost = health.GetComponent <BuildingInfo>().BaseCost;

        foreach (RepairConfig config in RepairCosts)
        {
            if (healthLost * config.HealthDenominator < health.MaxHealth * config.HealthNumerator)
            {
                return(buildingCost * config.CostNumerator / config.CostDenominator);
            }
        }
        Debug.LogError("Unexpected branch in GetRepairCost");
        Debug.LogError($"Building health {health.CurrentHealth} max health {health.MaxHealth} health lost {healthLost}");
        Debug.LogError("Defaulting to full cost");
        return(buildingCost);
    }
예제 #13
0
        private void Update()
        {
            if (!child.activeSelf)
            {
                return;
            }

            if (selectedTile && selectedTile.HasDebris)
            {
                selectedTile   = null;
                buildingHealth = null;
                SetActive(false);
                return;
            }

            SetBars();
            SetButtons();
        }
예제 #14
0
    public int GetHealthUpgradeCost(BuildingHealth health)
    {
        int baseCost = health.GetComponent <BuildingInfo>().BaseCost;

        switch (health.HealthUpgradeLevel)
        {
        case 0:
            return(baseCost / 4);

        case 1:
            return(baseCost / 3);

        default:
            Debug.LogError("Unexpected branch in GetUpgradeCost");
            Debug.LogError($"Building health level {health.HealthUpgradeLevel}");
            return(baseCost);
        }
    }
예제 #15
0
        private void SetBars(AbstractBuildingTile tile)
        {
            bool active = tile != null;

            buildingHealthBar.CachedGameObject.SetActive(active);
            foundationHealthBar.CachedGameObject.SetActive(active);
            soilHealthBar.CachedGameObject.SetActive(active);

            if (!active)
            {
                return;
            }

            BuildingHealth health = tile.Building.GetComponent <BuildingHealth>();

            health.SetBuildingHealthBar(buildingHealthBar);
            health.SetFoundationHealthBar(foundationHealthBar);
            health.SetSoilHealthBar(soilHealthBar);
        }
예제 #16
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
                        });
                    }
                }
            }
        }
예제 #17
0
    private void FixedUpdate()
    {
        GameObject[] bldgList = GameObject.FindGameObjectsWithTag("Building");


        float totalBldgHealth = 0.0f;

        //float buildingCost = 0.0f;
        // find building target
        foreach (GameObject bldg in bldgList)
        {
            BuildingHealth bh = bldg.GetComponent <BuildingHealth>();
            //BuildingInfo bi = bldg.GetComponent<BuildingInfo>();
            totalBldgHealth += bh.CurrentHealth;
            //buildingCost += bi.BaseCost;
        }

        pss.SetBody(totalBldgHealth);
        //pss.SetMind(pss.GetMind() - buildingCost);
    }
예제 #18
0
        private static void FirstTimeSetup()
        {
            foreach (AbstractTile tile in grid)
            {
                if (tile is AbstractBuildingTile buildingTile)
                {
                    buildingTile.SetSoilType(SoilType.Sand);
                    buildingTile.SetFoundationType(FoundationType.Wooden_Poles);
                    buildingTile.SetBuildingType(BuildingType.House);

                    buildingTile.SpawnBuilding(false);

                    BuildingHealth buildingHealth = buildingTile.Building.GetComponent <BuildingHealth>();

                    buildingHealth.DamageFoundation(buildingHealth.CurrentFoundationHealth * 0.80f);
                    buildingHealth.DamageSoil(buildingHealth.CurrentSoilHealth * 0.75f);

                    return;
                }
            }
        }
예제 #19
0
        public void GetType(AbstractTile tile)
        {
            // check and cast to approriate type directly
            if (tile is AbstractBuildingTile buildingTile)
            {
                hasSoil       = buildingTile.HasSoil;
                hasFoundation = buildingTile.HasFoundation;
                hasDebris     = buildingTile.HasDebris;

                if (!hasSoil)
                {
                    return;
                }

                soilType = buildingTile.GetSoilType();

                if (!hasFoundation)
                {
                    return;
                }

                foundationType = buildingTile.GetFoundationType();

                if (!buildingTile.HasBuilding || hasDebris)
                {
                    return;
                }

                buildingType = buildingTile.GetBuildingType();
                buildingTier = buildingTile.Building.CurrentTier;

                BuildingHealth buildingHealth = buildingTile.Building.GetComponent <BuildingHealth>();

                this.buildingHealth = buildingHealth.CurrentBuildingHealth;
                foundationHealth    = buildingHealth.CurrentFoundationHealth;
                soilHealth          = buildingHealth.CurrentSoilHealth;
            }
        }
예제 #20
0
 private bool MatchingExclusionGroup(Collider other, bool enter)
 {
     if (LocalPlayer.Create.CurrentBlueprint._exclusionGroup != ExclusionGroups.None)
     {
         PrefabIdentifier componentInParent = other.GetComponentInParent <PrefabIdentifier>();
         if (componentInParent)
         {
             BuildingHealth component = componentInParent.GetComponent <BuildingHealth>();
             if (component && component._type != BuildingTypes.None && Prefabs.Instance.Constructions.GetBlueprintExclusionGroup(component._type) == LocalPlayer.Create.CurrentBlueprint._exclusionGroup)
             {
                 if (enter)
                 {
                     this._inExclusionGroup = true;
                 }
                 else
                 {
                     this._inExclusionGroup = false;
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
예제 #21
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
                };
            }
        }
예제 #22
0
    public void ExecuteActionOnBuilding(Vector3Int position, BuildingAction action)
    {
        GameObject        buildingLogic = _positionToBuildingLogic[position];
        BuildingHealth    health        = buildingLogic.GetComponent <BuildingHealth>();
        BuildingLogicBase logic         = buildingLogic.GetComponent <BuildingLogicBase>();

        switch (action)
        {
        case BuildingAction.UPGRADE_HEALTH:
            int healthUpgradeCost = GetHealthUpgradeCost(health);
            if (healthUpgradeCost > playerStats.GetMind())
            {
                Debug.Log("Upgrade health failed");
                return;
            }
            health.DoUpgradeHealth();
            playerStats.UpdateMind(-healthUpgradeCost);

            ConstructionSpace space = _positionToConstructionSpace[position];
            if (health.WallSprite != null && !_constructionSpaceToWallSprite.ContainsKey(space))
            {
                GameObject wallSprite = Instantiate(WallPrefab);
                wallSprite.GetComponent <SpriteRenderer>().sprite = health.WallSprite;
                wallSprite.transform.position         = GetConstructionSpaceWorldCenter(space) + Vector3.back;
                _constructionSpaceToWallSprite[space] = wallSprite;
            }

            switch (logic.GetBuildingType())
            {
            case "library":
                audioManager.PlayUpLibrary();
                break;

            case "market":
                audioManager.PlayUpMarket();
                break;

            case "gym":
                audioManager.PlayUpGym();
                break;

            case "amp":
                audioManager.PlayUpAmp();
                break;

            case "vice":
                audioManager.PlayUpVice();
                break;
            }
            return;

        case BuildingAction.UPGRADE_PRODUCTION:
            int productionUpgradeCost = GetProductionUpgradeCost(logic);
            if (productionUpgradeCost > playerStats.GetMind())
            {
                Debug.Log("Upgrade production failed");
                return;
            }
            logic.DoUpgradeProduction();
            playerStats.UpdateMind(-productionUpgradeCost);
            switch (logic.GetBuildingType())
            {
            case "library":
                audioManager.PlayUpLibrary();
                break;

            case "market":
                audioManager.PlayUpMarket();
                break;

            case "gym":
                audioManager.PlayUpGym();
                break;

            case "amp":
                audioManager.PlayUpAmp();
                break;

            case "vice":
                audioManager.PlayUpVice();
                break;
            }
            return;

        case BuildingAction.REPAIR:
            audioManager.PlayBuildingBuilt();
            int repairCost = GetRepairCost(health);
            if (repairCost > playerStats.GetMind())
            {
                Debug.Log("Repair failed");
                return;
            }
            health.DoRepair();
            playerStats.UpdateMind(-repairCost);
            return;
        }
    }
예제 #23
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;
            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
                        });
                    }
                }
            }
        }
    // Update is called once per frame
    void Update()
    {
        //Check to see if level Ended (main base blown up)
        GameObject Building  = GameObject.FindWithTag("MainBuilding");
        GameObject Building2 = GameObject.FindWithTag("MainBuilding2");

        if (Building == null || Building2 == null)
        {
            if (TowerUpgrader.GetLevel() == 5 || Building == null)
            {
                //Start the countdown to reload
                StartCoroutine(Wait());

                //Possible reload display message.

                //If we want to destory enemies when level ends

                /*	GameObject[] enemiesDestory = GameObject.FindGameObjectsWithTag("Enemy");
                 *
                 * for (int i = 0; i < enemiesDestory.Length; i++) {
                 * Destroy (enemiesDestory [i]);
                 * }
                 *
                 */
                //Blow up buildings when level ends



                GameObject[] buildingsDestory = GameObject.FindGameObjectsWithTag("Building");
                for (int i = 0; i < buildingsDestory.Length; i++)
                {
                    GameObject temp = buildingsDestory [i];

                    BuildingHealth sn = temp.gameObject.GetComponent <BuildingHealth> ();

                    if (sn != null)
                    {
                        sn.goDestroy();
                    }

                    //Destroy (buildingsDestory [i]);
                }
            }
        }



        GameObject[] enemies     = GameObject.FindGameObjectsWithTag("Enemy");
        int          enemiesLeft = enemies.Length;

        if (enemiesLeft == 0)
        {         //print ("Triggered");
            if (waveCount <= 0 && gameController != null)
            {
                FadeIn.ChangeToWin(1);
                FadeIn.BeginFade(1);

                //FadeIn.ChangeToWin (0);

                if (SceneManager.GetActiveScene().name == "level1")
                {
                    gameController.SetScore(ScoreManager.score);
                    gameController.SetCash(EnergyManager.energy);
                    TowerUpgrader.SetLevel(2);
                    StartCoroutine(Wait2());
                    //SceneManager.LoadScene("Upgrades");
                }
                else if (SceneManager.GetActiveScene().name == "level2")
                {
                    gameController.SetScore(ScoreManager.score);
                    gameController.SetCash(EnergyManager.energy);
                    TowerUpgrader.SetLevel(3);
                    StartCoroutine(Wait2());

                    //SceneManager.LoadScene("Upgrades");
                }
                else if (SceneManager.GetActiveScene().name == "level3")
                {
                    gameController.SetScore(ScoreManager.score);
                    gameController.SetCash(EnergyManager.energy);
                    TowerUpgrader.SetLevel(4);
                    StartCoroutine(Wait2());

                    //SceneManager.LoadScene("Upgrades");
                }
                else if (SceneManager.GetActiveScene().name == "level4")
                {
                    gameController.SetScore(ScoreManager.score);
                    gameController.SetCash(EnergyManager.energy);
                    TowerUpgrader.SetLevel(5);
                    StartCoroutine(Wait2());
                    //SceneManager.LoadScene("Upgrades");
                }
                else if (SceneManager.GetActiveScene().name == "level5")
                {
                    gameController.SetScore(ScoreManager.score);
                    gameController.SetCash(EnergyManager.energy);
                    TowerUpgrader.SetLevel(1);
                    StartCoroutine(Wait2());

                    //SceneManager.LoadScene("Upgrades");
                }
            }

            // do something
        }
    }
예제 #25
0
 private void Awake()
 {
     health = GetComponent <BuildingHealth>();
 }
예제 #26
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
                };
            }
        }
    /// <summary>
    /// Runs a regular attack. Considers whether the player is large or small whilst raycasting.
    /// </summary>
    /// <param name="_controller">Controller to run the effect from.</param>
    private void regularAttack(GameObject _controller)
    {
        if (m_currentlyAttacking == true)
        {
            return;
        }
        RumbleManager.Instance.heavyVibration(InputManager.Instance.Handedness);
        //Player is large, attack a hex.
        if (InputManager.Instance.CurrentSize == InputManager.SizeOptions.large)
        {
            RaycastHit _hit;
            if (Physics.Raycast(m_pointPosition.position, _controller.transform.forward - (_controller.transform.up * 0.5f), out _hit, 1000, 1 << LayerMask.NameToLayer("Environment")))
            {
                StartCoroutine(regularAttackEffect(0.7f, _controller, _hit.point));

                //Show the dust effect on the hex you hit
                Vector3    _effectPos  = new Vector3(_hit.collider.gameObject.transform.position.x, _hit.collider.gameObject.transform.position.y + GameBoardGeneration.Instance.BuildingValidation.CurrentHeightOffset, _hit.collider.gameObject.transform.position.z);
                GameObject _dustEffect = Instantiate(m_lightningHitEffect, _effectPos, Quaternion.Euler(-90, 0, 0));
                Destroy(_dustEffect, 0.5f);

                //If you hit a collider of the environment which has an enemy on it.
                if (_hit.collider.gameObject.GetComponent <NodeComponent>().node.navigability == nodeTypes.enemyUnit)
                {
                    //Find each unit within that group, and deal damage to them.
                    EnemyBehaviour _enemies    = _hit.collider.gameObject.GetComponentInChildren <EnemyBehaviour>();
                    List <Unit>    _enemyUnits = new List <Unit>();
                    foreach (GameObject _go in _enemies.m_units)
                    {
                        _enemyUnits.Add(_go.GetComponent <UnitComponent>().unit);
                    }
                    foreach (Unit _unit in _enemyUnits)
                    {
                        _unit.health -= m_playerLargeDamage;
                        if (_unit.health < 0)
                        {
                            _unit.unitComp.Die();
                        }
                    }
                }
                if (_hit.collider.gameObject.GetComponent <NodeComponent>().node.navigability == nodeTypes.wall || _hit.collider.gameObject.GetComponent <NodeComponent>().node.navigability == nodeTypes.mine)
                {
                    //Find each unit within that group, and deal damage to them.
                    BuildingHealth _buildingHealth = _hit.collider.gameObject.GetComponentInChildren <BuildingHealth>();
                    _buildingHealth.currentHealth -= 70.0f;
                    if (_buildingHealth.currentHealth < 0)
                    {
                        Destroy(_buildingHealth.gameObject);
                        _hit.collider.gameObject.GetComponent <NodeComponent>().node.navigability = nodeTypes.navigable;
                    }
                }
            }
        }
        else
        {
            RaycastHit _hit;
            if (Physics.Raycast(m_pointPosition.position, _controller.transform.forward, out _hit, 1000))
            {
                StartCoroutine(regularAttackEffect(0.1f, _controller, _hit.point));
                //If it's a unit;
                if (_hit.collider.gameObject.GetComponentInParent <UnitComponent>() != null)
                {
                    Unit _unit = _hit.collider.gameObject.GetComponentInParent <UnitComponent>().unit;
                    _unit.health -= m_playerSmallDamage;
                    if (_unit.health < 0)
                    {
                        _unit.unitComp.Die();
                    }
                }
            }
            else
            {
                //Miss
                StartCoroutine(regularAttackEffect(0.2f, _controller, m_pointPosition.position + _controller.transform.forward * 20f));
            }
        }
    }
예제 #28
0
        public void Collapse()
        {
            if (!BoltNetwork.isClient)
            {
                for (int i = base.transform.childCount - 1; i >= 0; i--)
                {
                    Transform      child     = base.transform.GetChild(i);
                    BuildingHealth component = child.GetComponent <BuildingHealth>();
                    if (component)
                    {
                        child.parent = null;
                        component.Collapse(child.position);
                    }
                    else
                    {
                        FoundationHealth component2 = child.GetComponent <FoundationHealth>();
                        if (component2)
                        {
                            child.parent = null;
                            component2.Collapse(child.position);
                        }
                        else if (BoltNetwork.isRunning && child.GetComponent <BoltEntity>())
                        {
                            child.parent = null;
                            destroyAfter destroyAfter = child.gameObject.AddComponent <destroyAfter>();
                            destroyAfter.destroyTime = 1f;
                        }
                    }
                }
            }
            bool flag = true;

            MeshRenderer[] componentsInChildren = (this._destroyTarget ?? base.gameObject).GetComponentsInChildren <MeshRenderer>();
            int            mask = LayerMask.GetMask(new string[]
            {
                "Default",
                "ReflectBig",
                "Prop",
                "PropSmall",
                "PickUp"
            });

            foreach (MeshRenderer renderer in componentsInChildren)
            {
                GameObject gameObject = renderer.gameObject;
                if (gameObject.activeInHierarchy && (1 << gameObject.layer & mask) != 0)
                {
                    Transform transform = renderer.transform;
                    transform.parent = null;
                    if (gameObject == base.gameObject)
                    {
                        flag = false;
                    }
                    gameObject.layer = this._detachedLayer;
                    if (!gameObject.GetComponent <Collider>())
                    {
                        CapsuleCollider capsuleCollider = gameObject.AddComponent <CapsuleCollider>();
                        capsuleCollider.radius    = 0.1f;
                        capsuleCollider.height    = 1.5f;
                        capsuleCollider.direction = (int)this._capsuleDirection;
                    }
                    Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>();
                    if (rigidbody)
                    {
                        rigidbody.AddForce((transform.position.normalized + Vector3.up) * (2.5f * this._destructionForceMultiplier), ForceMode.Impulse);
                        rigidbody.AddRelativeTorque(Vector3.up * (2f * this._destructionForceMultiplier), ForceMode.Impulse);
                    }
                    destroyAfter destroyAfter2 = gameObject.AddComponent <destroyAfter>();
                    destroyAfter2.destroyTime = 2.5f;
                }
            }
            if (BoltNetwork.isClient)
            {
                BoltEntity component3 = base.GetComponent <BoltEntity>();
                if (component3 && component3.isAttached && !component3.isOwner)
                {
                    return;
                }
            }
            if (flag)
            {
                UnityEngine.Object.Destroy(base.gameObject);
            }
        }
예제 #29
0
        protected override void CreateStructure(bool isRepair = false)
        {
            if (isRepair)
            {
                base.Clear();
                base.StartCoroutine(base.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);
                BuildingHealth component = base.GetComponent <BuildingHealth>();
                if (component)
                {
                    component._renderersRoot = this._wallRoot.gameObject;
                }
                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;
                    Vector3 vector;
                    Vector3 size;
                    if (this.UseHorizontalLogs)
                    {
                        float num2 = Vector3.Distance(this._p1, this._p2) / this._logLength;
                        float num3 = 7.4f * num2;
                        float num4 = 6.75f * (0.31f + (num2 - 1f) / 2f);
                        vector    = Vector3.Lerp(this._p1, this._p2, 0.5f);
                        vector.y += this._logWidth * 0.9f;
                        vector    = this._wallRoot.InverseTransformPoint(vector);
                        size      = new Vector3(1.75f, 1.8f * this._logWidth, num3 * 1f);
                    }
                    else
                    {
                        float num3 = this._logWidth * (float)(this._wallRoot.childCount - 1) + 1.5f;
                        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();
                            }
                        }
                        vector   /= (float)this._wallRoot.childCount;
                        vector.y += this.GetHeight() / 2f;
                        vector    = this._wallRoot.InverseTransformPoint(vector);
                        size      = new Vector3(1.75f, this.GetHeight(), num3);
                    }
                    getStructureStrength getStructureStrength = gameObject.AddComponent <getStructureStrength>();
                    getStructureStrength._strength = getStructureStrength.strength.strong;
                    BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>();
                    boxCollider.center    = vector;
                    boxCollider.size      = size;
                    boxCollider.isTrigger = true;
                    BoxCollider boxCollider2 = gameObject.AddComponent <BoxCollider>();
                    boxCollider2.center = vector;
                    boxCollider2.size   = size;
                    gridObjectBlocker gridObjectBlocker = gameObject.AddComponent <gridObjectBlocker>();
                    gridObjectBlocker.ignoreOnDisable = true;
                    addToBuilt addToBuilt = gameObject.AddComponent <addToBuilt>();
                    addToBuilt.addToStructures = true;
                    BuildingHealthHitRelay buildingHealthHitRelay = gameObject.AddComponent <BuildingHealthHitRelay>();
                }
            }
        }
예제 #30
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;
                }
            }
        }