use() public method

public use ( ) : bool
return bool
Example #1
0
 public override void tick()
 {
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         this.wear = true;
         Equipment.use();
     }
 }
Example #2
0
 public override void tick()
 {
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         SpawnProjectiles.throwProjectile(Equipment.id, Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward * 1500f);
         Equipment.use();
     }
 }
Example #3
0
 public override void tick()
 {
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         if (this.target != null)
         {
             InteractionInterface.sendFertilize(this.target.transform.parent.position);
         }
         Equipment.use();
     }
 }
Example #4
0
 public override void tick()
 {
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         if (!Network.isServer)
         {
             base.networkView.RPC("askHeal", RPCMode.Server, new object[0]);
         }
         else
         {
             this.askHeal();
         }
         base.GetComponent <Life>().rest(MedicalStats.getStamina(Equipment.id));
         //HUDGame.pain = HUDGame.pain + (float)MedicalStats.getPain(Equipment.id);
         Equipment.use();
     }
 }
Example #5
0
 public override void tick()
 {
     if (!this.yum && Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length * 0.1f)
     {
         this.yum = true;
         NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
     }
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         if (!Network.isServer)
         {
             base.networkView.RPC("askConsume", RPCMode.Server, new object[0]);
         }
         else
         {
             this.askConsume();
         }
         base.GetComponent <Life>().rest(ConsumeableStats.getStamina(Equipment.id));
         Equipment.use();
     }
 }
Example #6
0
 public override void tick()
 {
     if (this.startedUse == Single.MaxValue)
     {
         Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out Structure.hit, 10f, RayMasks.PLACEABLE);
         if (Structure.hit.collider == null)
         {
             this.bad();
             Interact.hint = "Cannot Reach";
             Interact.icon = "Textures/Icons/error";
             this.help.transform.position = Vector3.zero;
         }
         else
         {
             this.help.transform.position = Structure.hit.point;
             Transform  transforms = this.help.transform;
             Quaternion quaternion = this.help.transform.rotation;
             Vector3    vector3    = base.transform.rotation.eulerAngles;
             transforms.rotation = Quaternion.Lerp(quaternion, Quaternion.Euler(0f, vector3.y + (float)this.rotation, 0f), 4f * Time.deltaTime);
             if (Structure.hit.point.y <= Ocean.level)
             {
                 this.bad();
                 Interact.hint = "Not Waterproof";
                 Interact.icon = "Textures/Icons/error";
             }
             else if (StructureStats.isFloor(Equipment.id))
             {
                 if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name)))
                 {
                     this.bad();
                     Interact.hint = "No Base";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((int)Physics.OverlapSphere(Structure.hit.collider.transform.position + new Vector3(0f, 3f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0)
                 {
                     this.bad();
                     Interact.hint = "No Supports";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + new Vector3(0f, 3f, 0f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, (float)(this.rotation * 2), 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
             }
             else if (StructureStats.isPillar(Equipment.id))
             {
                 if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name)))
                 {
                     this.bad();
                     Interact.hint = "No Base";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else if (Structure.hit.normal.y > 0f)
                 {
                     if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                     {
                         this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f);
                         this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                         this.good();
                         Interact.hint = string.Empty;
                         Interact.icon = string.Empty;
                     }
                     else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                     {
                         this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f);
                         this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                         this.good();
                         Interact.hint = string.Empty;
                         Interact.icon = string.Empty;
                     }
                     else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                     {
                         this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f);
                         this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                         this.good();
                         Interact.hint = string.Empty;
                         Interact.icon = string.Empty;
                     }
                     else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0)
                     {
                         this.bad();
                         Interact.hint = "No Corners";
                         Interact.icon = "Textures/Icons/error";
                     }
                     else
                     {
                         this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f);
                         this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                         this.good();
                         Interact.hint = string.Empty;
                         Interact.icon = string.Empty;
                     }
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -3f, 0f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -3f, 0f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, -3f, 0f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0)
                 {
                     this.bad();
                     Interact.hint = "No Corners";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else
                 {
                     this.help.transform.position = ((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, -3f, 0f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
             }
             else if (StructureStats.isPost(Equipment.id))
             {
                 if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name)))
                 {
                     this.bad();
                     Interact.hint = "No Base";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
                 {
                     this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if ((((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0)
                 {
                     this.bad();
                     Interact.hint = "No Corners";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else
                 {
                     this.help.transform.position = (Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
             }
             else if (StructureStats.isWall(Equipment.id))
             {
                 if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name)))
                 {
                     this.bad();
                     Interact.hint = "No Base";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 1.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0)
                 {
                     this.bad();
                     Interact.hint = "No Pillars";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
             }
             else if (StructureStats.isRampart(Equipment.id))
             {
                 if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)) && !StructureStats.isFloor(int.Parse(Structure.hit.collider.transform.parent.name)))
                 {
                     this.bad();
                     Interact.hint = "No Base";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0 && (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * 3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length > 0)
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
                 else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0 || (int)Physics.OverlapSphere(((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) + (Structure.hit.collider.transform.right * -3f)) + new Vector3(0f, 0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length <= 0)
                 {
                     this.bad();
                     Interact.hint = "No Posts";
                     Interact.icon = "Textures/Icons/error";
                 }
                 else
                 {
                     this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f);
                     this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation * Quaternion.Euler(0f, 90f, 0f);
                     this.good();
                     Interact.hint = string.Empty;
                     Interact.icon = string.Empty;
                 }
             }
             else if (!StructureStats.isFoundation(Equipment.id))
             {
                 if (StructureStats.isLadder(Equipment.id))
                 {
                     if (!(Structure.hit.collider.tag == "Structure") || !(Structure.hit.collider.transform.parent.tag == "Structure") || !StructureStats.isLadder(int.Parse(Structure.hit.collider.transform.parent.name)))
                     {
                         this.help.transform.position = Structure.hit.point;
                         this.good();
                         Interact.hint = string.Empty;
                         Interact.icon = string.Empty;
                     }
                     else if ((int)Physics.OverlapSphere(Structure.hit.collider.transform.position + new Vector3(0f, 4.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0)
                     {
                         this.bad();
                         Interact.hint = "No Space";
                         Interact.icon = "Textures/Icons/error";
                     }
                     else
                     {
                         this.help.transform.position = Structure.hit.collider.transform.position + new Vector3(0f, 3f, 0f);
                         this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                         this.good();
                         Interact.hint = string.Empty;
                         Interact.icon = string.Empty;
                     }
                 }
             }
             else if ((double)Structure.hit.normal.y <= 0.5)
             {
                 this.bad();
                 Interact.hint = "Too Steep";
                 Interact.icon = "Textures/Icons/error";
             }
             else if (Structure.hit.collider.name == "ground")
             {
                 this.help.transform.position = Structure.hit.point + new Vector3(0f, 0.3f, 0f);
                 this.good();
                 Interact.hint = string.Empty;
                 Interact.icon = string.Empty;
             }
             else if (!(Structure.hit.collider.tag == "Structure") || !StructureStats.isFoundation(int.Parse(Structure.hit.collider.transform.parent.name)))
             {
                 this.bad();
                 Interact.hint = "No Base";
                 Interact.icon = "Textures/Icons/error";
             }
             else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
             {
                 this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * 6f);
                 this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                 this.good();
                 Interact.hint = string.Empty;
                 Interact.icon = string.Empty;
             }
             else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
             {
                 this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.up * -6f);
                 this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                 this.good();
                 Interact.hint = string.Empty;
                 Interact.icon = string.Empty;
             }
             else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 3f)) - Structure.hit.point).magnitude < 1f && (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length == 0)
             {
                 this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * 6f);
                 this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                 this.good();
                 Interact.hint = string.Empty;
                 Interact.icon = string.Empty;
             }
             else if (((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -3f)) - Structure.hit.point).magnitude >= 1f || (int)Physics.OverlapSphere((Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f)) + new Vector3(0f, -0.5f, 0f), 0.1f, RayMasks.ERRORSTRUCT).Length != 0)
             {
                 this.bad();
                 Interact.hint = "No Edges";
                 Interact.icon = "Textures/Icons/error";
             }
             else
             {
                 this.help.transform.position = Structure.hit.collider.transform.position + (Structure.hit.collider.transform.right * -6f);
                 this.help.transform.rotation = Structure.hit.collider.transform.parent.rotation;
                 this.good();
                 Interact.hint = string.Empty;
                 Interact.icon = string.Empty;
             }
         }
         if (Input.GetMouseButtonDown(1))
         {
             Structure structure = this;
             structure.rotation = structure.rotation + 45;
         }
     }
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         if (!Network.isServer)
         {
             NetworkView networkView = base.networkView;
             object[]    state       = new object[] { Equipment.equipped.x, Equipment.equipped.y, this.help.transform.position, null, null };
             Quaternion  quaternion1 = this.help.transform.rotation;
             state[3] = (int)quaternion1.eulerAngles.y;
             state[4] = StructureStats.getState(Equipment.id);
             networkView.RPC("askBuild", RPCMode.Server, state);
         }
         else
         {
             int     num      = Equipment.equipped.x;
             int     num1     = Equipment.equipped.y;
             Vector3 vector31 = this.help.transform.position;
             Vector3 vector32 = this.help.transform.rotation.eulerAngles;
             // FIXME: cliend side?
             //this.askBuild(num, num1, vector31, (int)vector32.y, StructureStats.getState(Equipment.id));
         }
         NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
         Equipment.use();
     }
 }
Example #7
0
 public override void tick()
 {
     if (this.startedUse == Single.MaxValue)
     {
         Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out Plant.hit, 5f, RayMasks.PLACEABLE);
         if (Plant.hit.collider == null)
         {
             this.bad();
             Interact.hint = "Cannot Reach";
             Interact.icon = "Textures/Icons/error";
             this.help.transform.position = Vector3.zero;
         }
         else
         {
             this.help.transform.position = Plant.hit.point;
             Transform  transforms = this.help.transform;
             Quaternion quaternion = this.help.transform.rotation;
             Vector3    vector3    = base.transform.rotation.eulerAngles;
             transforms.rotation = Quaternion.Lerp(quaternion, Quaternion.Euler(0f, vector3.y + (float)this.rotation, 0f), 4f * Time.deltaTime);
             if ((double)Plant.hit.normal.y <= 0.5 && !BarricadeStats.getLinked(Equipment.id))
             {
                 this.bad();
                 Interact.hint = "Too Steep";
                 Interact.icon = "Textures/Icons/error";
             }
             else if (Plant.hit.point.y <= Ocean.level)
             {
                 this.bad();
                 Interact.hint = "Not Waterproof";
                 Interact.icon = "Textures/Icons/error";
             }
             else if ((int)Physics.OverlapSphere(this.help.transform.position + new Vector3(0f, 1.25f, 0f), 0.75f, RayMasks.ERROR).Length != 0 || (int)Physics.OverlapSphere(this.help.transform.position + new Vector3(0f, 0.1f, 0f), 0.05f, RayMasks.ERROR).Length != 0)
             {
                 this.bad();
                 Interact.hint = "No Space";
                 Interact.icon = "Textures/Icons/error";
             }
             else if ((!(Plant.hit.collider.name == "ground") || Ground.material(Plant.hit.point) != 0 && Ground.material(Plant.hit.point) != 7 && Ground.material(Plant.hit.point) != 8) && !(Plant.hit.collider.transform.parent.name == "17006") && !(Plant.hit.collider.transform.parent.name == "17007"))
             {
                 this.bad();
                 Interact.hint = "Infertile Soil";
                 Interact.icon = "Textures/Icons/error";
             }
             else
             {
                 this.good();
                 Interact.hint = string.Empty;
                 Interact.icon = string.Empty;
             }
         }
         if (Input.GetMouseButtonDown(1))
         {
             Plant plant = this;
             plant.rotation = plant.rotation + 45;
         }
     }
     if (Time.realtimeSinceStartup - this.startedUse > Viewmodel.model.animation["use"].length && !this.done)
     {
         this.done = true;
         if (!Network.isServer)
         {
             NetworkView networkView = base.networkView;
             object[]    state       = new object[] { Equipment.equipped.x, Equipment.equipped.y, this.help.transform.position, null, null };
             Quaternion  quaternion1 = this.help.transform.rotation;
             state[3] = quaternion1.eulerAngles;
             state[4] = BarricadeStats.getState(Equipment.id);
             networkView.RPC("askBuild", RPCMode.Server, state);
         }
         else
         {
             int        num         = Equipment.equipped.x;
             int        num1        = Equipment.equipped.y;
             Vector3    vector31    = this.help.transform.position;
             Quaternion quaternion2 = this.help.transform.rotation;
             this.askBuild(num, num1, vector31, quaternion2.eulerAngles, BarricadeStats.getState(Equipment.id));
         }
         NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f);
         Equipment.use();
     }
 }