Exemplo n.º 1
0
 private bool CheckCombineGate()
 {
     foreach (WallDefensiveGateAddition wallDefensiveGateAddition in UnityEngine.Object.FindObjectsOfType <WallDefensiveGateAddition>())
     {
         if (wallDefensiveGateAddition != this && !wallDefensiveGateAddition.GetComponent <WallDefensiveGateArchitect>().Is2Sided&& Mathf.Abs(Vector3.Dot(base.transform.forward, wallDefensiveGateAddition.transform.forward)) > 0.95f)
         {
             WallDefensiveChunkArchitect  component  = wallDefensiveGateAddition.GetComponent <WallDefensiveChunkArchitect>();
             WallDefensiveChunkArchitect  component2 = base.GetComponent <WallDefensiveChunkArchitect>();
             WallChunkArchitect.Additions addition   = component.Addition;
             if (Vector3.Distance(component.P2, component2.P1) < 0.2f && Vector3.Distance(component.P1, component2.P2) < 22f)
             {
                 this.SpawnGate(component.P1, component2.P2, addition, component.Height);
                 base.GetComponentInChildren <Craft_Structure>().CancelBlueprintSafe();
                 wallDefensiveGateAddition.GetComponentInChildren <Craft_Structure>().CancelBlueprintSafe();
                 return(true);
             }
             if (Vector3.Distance(component.P1, component2.P2) < 0.2f && Vector3.Distance(component.P2, component2.P1) < 22f)
             {
                 this.SpawnGate(component2.P1, component.P2, addition, component.Height);
                 base.GetComponentInChildren <Craft_Structure>().CancelBlueprintSafe();
                 wallDefensiveGateAddition.GetComponentInChildren <Craft_Structure>().CancelBlueprintSafe();
                 return(true);
             }
         }
     }
     return(false);
 }
 private void CheckTargetingSupport(WallDefensiveChunkArchitect WDCA)
 {
     if (WDCA)
     {
         if (WDCA.WasBuilt && !WDCA.Reinforcement && !(WDCA is WallDefensiveGateArchitect))
         {
             Quaternion rotation;
             if (Vector3.Dot((WDCA.transform.position - this._caster.LastHit.point).normalized, WDCA.transform.right) < 0f)
             {
                 rotation = Quaternion.LookRotation(WDCA.P2 - WDCA.P1);
             }
             else
             {
                 rotation = Quaternion.LookRotation(WDCA.P1 - WDCA.P2);
             }
             if (WDCA != this._chunk || Mathf.Abs((rotation.eulerAngles.y + 360f) % 360f - (base.transform.eulerAngles.y + 360f) % 360f) > 3f)
             {
                 base.transform.rotation = rotation;
                 this._chunk             = WDCA;
                 this.Clear();
                 base.GetComponent <Renderer>().enabled = false;
             }
         }
     }
     else if (this._chunk)
     {
         this._chunk = null;
         this.Clear();
         base.GetComponent <Renderer>().enabled = true;
     }
 }
Exemplo n.º 3
0
        public void Start()
        {
            WallDefensiveChunkArchitect component  = base.GetComponent <WallDefensiveChunkArchitect>();
            WallDefensiveGateArchitect  component2 = base.GetComponent <WallDefensiveGateArchitect>();

            if (component && !component2)
            {
                if (!this.CheckCombineGate())
                {
                    this.SpawnGate(component.P1, component.P2, component.Addition, component.Height);
                    base.GetComponentInChildren <Craft_Structure>().CancelBlueprintSafe();
                }
            }
            else if (component2 && component2.Addition == WallChunkArchitect.Additions.Wall)
            {
                this.ToggleBackToWall();
            }
        }