public override void equip() { Viewmodel.play("equip"); this.help = (GameObject)UnityEngine.Object.Instantiate(Resources.Load(string.Concat("Prefabs/Barricades/", Equipment.id)), Vector3.zero, base.transform.rotation); this.help.name = "help"; UnityEngine.Object.Destroy(this.help.transform.FindChild("model").collider); this.help.transform.FindChild("model").renderer.castShadows = false; this.help.transform.FindChild("model").renderer.receiveShadows = false; this.help.tag = "Untagged"; this.help.layer = 2; this.help.transform.FindChild("model").tag = "Untagged"; this.help.transform.FindChild("model").gameObject.layer = 2; if (this.help.transform.FindChild("model").GetComponent <Interactable>() != null) { UnityEngine.Object.Destroy(this.help.transform.FindChild("model").GetComponent <Interactable>()); } if (this.help.transform.FindChild("nav")) { UnityEngine.Object.Destroy(this.help.transform.FindChild("nav").gameObject); } this.rotation = BarricadeStats.getRotation(Equipment.id); Transform transforms = this.help.transform; transforms.rotation = transforms.rotation * Quaternion.Euler(0f, (float)this.rotation, 0f); }
public static void damage(Vector3 position, int amount) { Point2 region = NetworkRegions.getRegion(position); int indexFromPositionServer = SpawnBarricades.getIndexFromPositionServer(region, position); if (indexFromPositionServer != -1) { ServerBarricade item = SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer]; item.health = item.health - amount; if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].health <= 0) { NetworkEffects.askEffect(BarricadeStats.getEffect(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id), position, Quaternion.Euler(-90f, 0f, 0f), -1f); NetworkSounds.askSound(BarricadeStats.getSound(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id), position, 1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); SpawnBarricades.tool.networkView.RPC("destroyBarricade", RPCMode.All, new object[] { position }); } } }
public void destroyBarricade(Vector3 position) { int indexFromPositionServer; ClientItem[,] crateItems; Point2 region = NetworkRegions.getRegion(position); bool flag = false; int item = -1; Vector3 vector3 = Vector3.zero; if (Network.isServer) { indexFromPositionServer = SpawnBarricades.getIndexFromPositionServer(region, position); if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16019 || SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16025 || SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id == 16023) { if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id != 16019) { string[] strArrays = Packer.unpack(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].state, '\u005F'); crateItems = InteractionInterface.getCrateItems(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id, Sneaky.expose(strArrays[2])); } else { crateItems = InteractionInterface.getCrateItems(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id, Sneaky.expose(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].state)); } for (int i = 0; i < 2; i++) { for (int j = 0; j < BarricadeStats.getCapacity(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id); j++) { if (!ItemStackable.getStackable(crateItems[i, j].id)) { SpawnItems.drop(crateItems[i, j].id, crateItems[i, j].amount, crateItems[i, j].state, position); } else { for (int k = 0; k < crateItems[i, j].amount; k++) { SpawnItems.drop(crateItems[i, j].id, 1, crateItems[i, j].state, position); } } } } } else if (ExplosiveStats.getDamage(SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id) != 0) { flag = true; item = SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id; if (SpawnBarricades.regions[region.x, region.y].barricades[indexFromPositionServer].id != 16015) { vector3 = position + Vector3.up; NetworkEffects.askEffect("Effects/grenade", position, Quaternion.Euler(-90f, 0f, 0f), -1f); NetworkSounds.askSoundMax("Sounds/Projectiles/grenade", position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f); } else { vector3 = position + SpawnBarricades.regions[region.x, region.y].models[indexFromPositionServer].transform.up; NetworkEffects.askEffect("Effects/bomb", position, Quaternion.Euler(-90f, 0f, 0f), -1f); NetworkSounds.askSoundMax("Sounds/Projectiles/bomb", position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 4f, 64f); } } if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnBarricades.regions[region.x, region.y].barricades.Count) { SpawnBarricades.regions[region.x, region.y].barricades.RemoveAt(indexFromPositionServer); } } indexFromPositionServer = SpawnBarricades.getIndexFromPositionClient(region, position); if (indexFromPositionServer != -1 && indexFromPositionServer < SpawnBarricades.regions[region.x, region.y].models.Count) { UnityEngine.Object.Destroy(SpawnBarricades.regions[region.x, region.y].models[indexFromPositionServer]); SpawnBarricades.regions[region.x, region.y].models.RemoveAt(indexFromPositionServer); } if (flag) { ExplosionTool.explode(vector3, (float)ExplosiveStats.getRange(item), ExplosiveStats.getDamage(item)); } }
public static void placeBarricade(int id, Vector3 position, Vector3 rotation, string state) { Point2 region = NetworkRegions.getRegion(position); SpawnBarricades.regions[region.x, region.y].barricades.Add(new ServerBarricade(id, BarricadeStats.getHealth(id), state, position, rotation)); SpawnBarricades.tool.networkView.RPC("testBarricade", RPCMode.All, new object[] { id, region.x, region.y, position, rotation }); }
public void tick() { if (!this.dead) { if (Player.model != null && Player.life != null && !Player.life.dead) { if (Mathf.Abs(base.transform.position.x - Player.model.transform.position.x) >= (float)Stance.range || Mathf.Abs(base.transform.position.z - Player.model.transform.position.z) >= (float)Stance.range || Mathf.Abs(base.transform.position.y - Player.model.transform.position.y) >= (float)(Stance.range / 2)) { this.lastClientAttack = Time.realtimeSinceStartup; } else { if ((!this.agro && !this.search || (double)UnityEngine.Random.@value > 0.8) && RayMasks.isVisible(base.transform.position + Vector3.up, Player.model.transform.position + Vector3.up)) { if (!Network.isServer) { base.networkView.RPC("askAgro", RPCMode.Server, new object[] { Network.player }); } else { this.askAgro(Network.player); } } if (!(Movement.vehicle == null) || Mathf.Abs(base.transform.position.x - Player.model.transform.position.x) >= 1.25f || Mathf.Abs(base.transform.position.z - Player.model.transform.position.z) >= 1.25f || Mathf.Abs(base.transform.position.y - Player.model.transform.position.y) >= 2f) { this.lastClientAttack = Time.realtimeSinceStartup; } else if (Time.realtimeSinceStartup - this.lastClientAttack > 0.5f) { this.lastClientAttack = Time.realtimeSinceStartup; if (RayMasks.isVisible(base.transform.position + Vector3.up, Player.model.transform.position + Vector3.up)) { if (!Network.isServer) { base.networkView.RPC("askMaul", RPCMode.Server, new object[] { Network.player }); } else { this.askMaul(Network.player); } } } } } if (Network.isServer) { if (!this.agent.isOnOffMeshLink) { if (!this.agro && !this.search) { if ((double)UnityEngine.Random.@value > 0.975) { NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/idle_", UnityEngine.Random.Range(0, Zombie.IDLES)), base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.5f); } } else if ((double)UnityEngine.Random.@value > 0.975) { NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/agro_", UnityEngine.Random.Range(0, Zombie.AGROS)), base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.5f); } if (this.agro && this.target != null) { if (Mathf.Abs(base.transform.position.x - this.target.transform.position.x) > 64f || Mathf.Abs(base.transform.position.z - this.target.transform.position.z) > 64f || this.target.GetComponent <Life>().dead) { if (this.agent.enabled) { this.agent.Stop(); this.agent.enabled = false; } this.target = null; this.destroy = null; if (this.agro) { base.networkView.RPC("tellAgro", RPCMode.All, new object[] { false }); } } else if (this.destroy == null) { if (!this.agent.enabled) { this.agent.enabled = true; } this.agent.destination = this.target.transform.position + this.target.GetComponent <Player>().prediction; if (Mathf.Abs(this.agent.destination.x - base.transform.position.x) >= 0.75f || Mathf.Abs(this.agent.destination.z - base.transform.position.z) >= 0.75f) { if (!this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { true }); } if (this.target.GetComponent <Player>().vehicle == null) { Collider[] colliderArray = Physics.OverlapSphere(base.transform.position, 2f, RayMasks.BUILT); if ((int)colliderArray.Length > 0) { for (int i = 0; i < (int)colliderArray.Length; i++) { if (!BarricadeStats.getMaulable(int.Parse(colliderArray[i].transform.parent.name))) { if (BarricadeStats.getBarrier(int.Parse(colliderArray[i].transform.parent.name))) { this.destroy = colliderArray[i].gameObject; } if (BarricadeStats.getDamage(int.Parse(colliderArray[i].transform.parent.name)) != 0 && (colliderArray[i].transform.parent.name != "16009" && colliderArray[i].transform.parent.name != "16021" || colliderArray[i].GetComponent <ElectricTrap>().powered)) { base.damage(BarricadeStats.getDamage(int.Parse(colliderArray[i].transform.parent.name))); SpawnBarricades.damage(colliderArray[i].transform.parent.position, 10); NetworkSounds.askSound("Sounds/Impacts/flesh", base.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", base.transform.position + Vector3.up, Quaternion.identity, -1f); } else if (ExplosiveStats.getDamage(int.Parse(colliderArray[i].transform.parent.name)) != 0) { InteractionInterface.sendExplosiveTrap(colliderArray[i].transform.parent.position); } } else { this.destroy = colliderArray[i].gameObject; } } } } else { this.destroy = this.target.GetComponent <Player>().vehicle.gameObject; } } else { if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } if (this.search) { base.networkView.RPC("tellSearch", RPCMode.All, new object[] { false }); } } } else { if (!this.agent.enabled) { this.agent.enabled = true; } this.agent.destination = this.destroy.transform.position; if (this.destroy.tag == "Barricade") { if (Time.realtimeSinceStartup - this.lastServerAttack > 0.5f) { this.lastServerAttack = Time.realtimeSinceStartup; if (RayMasks.isVisible(base.transform.position + Vector3.up, this.destroy.transform.position + Vector3.up)) { SpawnBarricades.damage(this.destroy.transform.parent.position, 10); base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms = base.transform; Vector3 vector3 = this.destroy.transform.position; float single = vector3.z - base.transform.position.z; float single1 = this.destroy.transform.position.x; Vector3 vector31 = base.transform.position; transforms.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single, single1 - vector31.x) * 57.29578f, 0f); NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/attack_", UnityEngine.Random.Range(0, Zombie.ATTACKS)), base.transform.position, 0.75f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } } else if (this.destroy.tag == "Structure") { if (Time.realtimeSinceStartup - this.lastServerAttack > 0.5f) { this.lastServerAttack = Time.realtimeSinceStartup; // FIXME: zombie can't destroy //SpawnStructures.damage(this.destroy.transform.parent.position, 10); base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms1 = base.transform; Vector3 vector32 = this.destroy.transform.position; float single2 = vector32.z - base.transform.position.z; float single3 = this.destroy.transform.position.x; Vector3 vector33 = base.transform.position; transforms1.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single2, single3 - vector33.x) * 57.29578f, 0f); NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/attack_", UnityEngine.Random.Range(0, Zombie.ATTACKS)), base.transform.position, 0.75f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } } else if (this.destroy.tag == "Vehicle") { if (Mathf.Abs(base.transform.position.x - this.destroy.transform.position.x) > 6f || Mathf.Abs(base.transform.position.y - this.destroy.transform.position.y) > 6f || Mathf.Abs(base.transform.position.z - this.destroy.transform.position.z) > 6f || this.target == null || this.target.GetComponent <Player>().vehicle == null) { this.destroy = null; } else { if (Time.realtimeSinceStartup - this.lastServerAttack > 0.5f) { this.lastServerAttack = Time.realtimeSinceStartup; this.destroy.GetComponent <Vehicle>().damage(2); base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms2 = base.transform; Vector3 vector34 = this.destroy.transform.position; float single4 = vector34.z - base.transform.position.z; float single5 = this.destroy.transform.position.x; Vector3 vector35 = base.transform.position; transforms2.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single4, single5 - vector35.x) * 57.29578f, 0f); if (this.destroy.GetComponent <Vehicle>().health == 0) { this.destroy = null; } NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/attack_", UnityEngine.Random.Range(0, Zombie.ATTACKS)), base.transform.position, 0.75f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } } } } base.Invoke("tick", UnityEngine.Random.Range(0.25f, 0.35f)); } else if (!this.search || !(this.moveTo != Vector3.zero)) { if (this.agent.enabled) { this.agent.Stop(); this.agent.enabled = false; } if (this.target != null) { this.target = null; if (this.agro) { base.networkView.RPC("tellAgro", RPCMode.All, new object[] { false }); } } if (this.moveTo != Vector3.zero) { this.moveTo = Vector3.zero; if (this.search) { base.networkView.RPC("tellSearch", RPCMode.All, new object[] { false }); } } this.destroy = null; if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } base.Invoke("tick", UnityEngine.Random.Range(2.2f, 2.6f)); } else { if (this.destroy == null) { if (!this.agent.enabled) { this.agent.enabled = true; } this.agent.destination = this.moveTo; if (Mathf.Abs(this.agent.destination.x - base.transform.position.x) >= 0.75f || Mathf.Abs(this.agent.destination.z - base.transform.position.z) >= 0.75f) { if (!this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { true }); } Collider[] colliderArray1 = Physics.OverlapSphere(base.transform.position, 2f, RayMasks.BUILT); if ((int)colliderArray1.Length > 0) { for (int j = 0; j < (int)colliderArray1.Length; j++) { if (!BarricadeStats.getMaulable(int.Parse(colliderArray1[j].transform.parent.name))) { if (BarricadeStats.getBarrier(int.Parse(colliderArray1[j].transform.parent.name))) { this.destroy = colliderArray1[j].gameObject; } if (BarricadeStats.getDamage(int.Parse(colliderArray1[j].transform.parent.name)) != 0 && (colliderArray1[j].transform.parent.name != "16009" && colliderArray1[j].transform.parent.name != "16021" || colliderArray1[j].GetComponent <ElectricTrap>().powered)) { base.damage(BarricadeStats.getDamage(int.Parse(colliderArray1[j].transform.parent.name))); SpawnBarricades.damage(colliderArray1[j].transform.parent.position, 10); NetworkSounds.askSound("Sounds/Impacts/flesh", base.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", base.transform.position + Vector3.up, Quaternion.identity, -1f); } else if (ExplosiveStats.getDamage(int.Parse(colliderArray1[j].transform.parent.name)) != 0) { InteractionInterface.sendExplosiveTrap(colliderArray1[j].transform.parent.position); } } else { this.destroy = colliderArray1[j].gameObject; } } } } else { this.moveTo = Vector3.zero; if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } if (this.search) { base.networkView.RPC("tellSearch", RPCMode.All, new object[] { false }); } } } else { if (!this.agent.enabled) { this.agent.enabled = true; } this.agent.destination = this.destroy.transform.position; if (this.destroy.tag == "Barricade") { if (Time.realtimeSinceStartup - this.lastServerAttack > 0.5f) { this.lastServerAttack = Time.realtimeSinceStartup; if (RayMasks.isVisible(base.transform.position + Vector3.up, this.destroy.transform.position + Vector3.up)) { SpawnBarricades.damage(this.destroy.transform.parent.position, 10); base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms3 = base.transform; Vector3 vector36 = this.destroy.transform.position; float single6 = vector36.z - base.transform.position.z; float single7 = this.destroy.transform.position.x; Vector3 vector37 = base.transform.position; transforms3.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single6, single7 - vector37.x) * 57.29578f, 0f); NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/attack_", UnityEngine.Random.Range(0, Zombie.ATTACKS)), base.transform.position, 0.75f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } } else if (this.destroy.tag == "Structure") { if (Time.realtimeSinceStartup - this.lastServerAttack > 0.5f) { this.lastServerAttack = Time.realtimeSinceStartup; // FIXME: zombie can't destroy //SpawnStructures.damage(this.destroy.transform.parent.position, 10); base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms4 = base.transform; Vector3 vector38 = this.destroy.transform.position; float single8 = vector38.z - base.transform.position.z; float single9 = this.destroy.transform.position.x; Vector3 vector39 = base.transform.position; transforms4.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single8, single9 - vector39.x) * 57.29578f, 0f); NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/attack_", UnityEngine.Random.Range(0, Zombie.ATTACKS)), base.transform.position, 0.75f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } } else if (this.destroy.tag == "Vehicle") { if (Mathf.Abs(base.transform.position.x - this.destroy.transform.position.x) > 6f || Mathf.Abs(base.transform.position.y - this.destroy.transform.position.y) > 6f || Mathf.Abs(base.transform.position.z - this.destroy.transform.position.z) > 6f || this.target == null || this.target.GetComponent <Player>().vehicle == null) { this.destroy = null; } else { if (Time.realtimeSinceStartup - this.lastServerAttack > 0.5f) { this.lastServerAttack = Time.realtimeSinceStartup; this.destroy.GetComponent <Vehicle>().damage(2); base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms5 = base.transform; Vector3 vector310 = this.destroy.transform.position; float single10 = vector310.z - base.transform.position.z; float single11 = this.destroy.transform.position.x; Vector3 vector311 = base.transform.position; transforms5.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single10, single11 - vector311.x) * 57.29578f, 0f); if (this.destroy.GetComponent <Vehicle>().health == 0) { this.destroy = null; } NetworkSounds.askSound(string.Concat("Sounds/Animals/Zombie/attack_", UnityEngine.Random.Range(0, Zombie.ATTACKS)), base.transform.position, 0.75f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } } } } base.Invoke("tick", UnityEngine.Random.Range(0.25f, 0.35f)); } } else { base.traverse(); base.Invoke("tick", 0.03f); } } else if (this.agro || this.search) { base.Invoke("tick", UnityEngine.Random.Range(0.25f, 0.35f)); } else { base.Invoke("tick", UnityEngine.Random.Range(2.5f, 2.6f)); } } if (this.dead) { this.anim.play("dead"); this.anim.stance(string.Empty); } else if (!this.moving) { this.anim.stance(string.Concat("idle_", this.animset)); } else { this.anim.stance(string.Concat("move_", this.animset)); } }
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(); } }
public void tick() { if (!this.dead) { if (Player.model != null && Player.life != null && !Player.life.dead && (!this.scared || (double)UnityEngine.Random.@value > 0.8) && Mathf.Abs(base.transform.position.x - Player.model.transform.position.x) < (float)Stance.range && Mathf.Abs(base.transform.position.z - Player.model.transform.position.z) < (float)Stance.range) { if (!Network.isServer) { base.networkView.RPC("askScare", RPCMode.Server, new object[] { Network.player }); } else { this.askScare(Network.player); } } if (!Network.isServer) { base.Invoke("tick", UnityEngine.Random.Range(1.2f, 1.4f)); } else if (this.agent.isOnOffMeshLink) { base.traverse(); base.Invoke("tick", 0.03f); } else if (!this.scared) { if (this.agent.enabled) { this.agent.Stop(); this.agent.enabled = false; } if (this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { false }); } base.Invoke("tick", UnityEngine.Random.Range(1.2f, 1.4f)); } else { if (!this.agent.enabled) { this.agent.enabled = true; } if (!this.moving) { base.networkView.RPC("tellMoving", RPCMode.All, new object[] { true }); } this.agent.destination = this.escape; if (Mathf.Abs(this.agent.destination.x - base.transform.position.x) >= 0.75f || Mathf.Abs(this.agent.destination.z - base.transform.position.z) >= 0.75f) { Collider[] colliderArray = Physics.OverlapSphere(base.transform.position, 2f, RayMasks.BUILT); if ((int)colliderArray.Length > 0) { for (int i = 0; i < (int)colliderArray.Length; i++) { if (BarricadeStats.getDamage(int.Parse(colliderArray[i].transform.parent.name)) != 0 && (colliderArray[i].transform.parent.name != "16009" && colliderArray[i].transform.parent.name != "16021" || colliderArray[i].GetComponent <ElectricTrap>().powered)) { base.damage(BarricadeStats.getDamage(int.Parse(colliderArray[i].transform.parent.name))); SpawnBarricades.damage(colliderArray[i].transform.parent.position, 10); NetworkSounds.askSound("Sounds/Impacts/flesh", base.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", base.transform.position + Vector3.up, Quaternion.identity, -1f); } else if (ExplosiveStats.getDamage(int.Parse(colliderArray[i].transform.parent.name)) != 0) { InteractionInterface.sendExplosiveTrap(colliderArray[i].transform.parent.position); } } } } else { base.networkView.RPC("tellScared", RPCMode.All, new object[] { false }); } base.Invoke("tick", UnityEngine.Random.Range(0.25f, 0.35f)); } } if (this.dead) { this.anim.stance("dead"); } else if (!this.moving) { this.anim.stance("idle"); } else { this.anim.stance("move"); } }