public static void damage(Vector3 position, int amount, NetworkPlayer player) { NetworkUser user = NetworkUserList.getUserFromPlayer(player); int permission = UserList.getPermission(user.id); if (permission < 1) { Reference.Tell(player, "Building destroy not allowed!"); return; } int num = 0; while (num < SpawnStructures.structures.Count) { if (SpawnStructures.structures[num].position != position) { num++; } else { ServerStructure item = SpawnStructures.structures[num]; item.health = item.health - amount; if (SpawnStructures.structures[num].health <= 0) { NetworkEffects.askEffect("Effects/debrisWood", position, Quaternion.Euler(-90f, 0f, 0f), -1f); NetworkSounds.askSound("Sounds/Barricades/debrisWood", position, 1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); SpawnStructures.tool.networkView.RPC("destroyStructure", RPCMode.All, new object[] { num }); } break; } } }
public void OnTriggerEnter(Collider other) { if (base.transform.parent.GetComponent <Vehicle>().lastSpeed > 5 && base.transform.parent.GetComponent <Vehicle>().passengers[0] != null) { if ((other.tag == "Enemy" || other.tag == "Player") && ServerSettings.pvp) { GameObject gameObject = null; gameObject = (other.tag != "Enemy" ? other.gameObject : OwnerFinder.getOwner(other.gameObject)); NetworkUser userFromPlayer = NetworkUserList.getUserFromPlayer(base.transform.parent.GetComponent <Vehicle>().passengers[0].player); if (userFromPlayer != null && !gameObject.GetComponent <Life>().dead&& (userFromPlayer.friend == string.Empty || userFromPlayer.friend != gameObject.GetComponent <Player>().owner.friend)) { if (gameObject.GetComponent <Player>().owner.reputation >= 0) { NetworkHandler.offsetReputation(userFromPlayer.player, -1); } else { NetworkHandler.offsetReputation(userFromPlayer.player, 1); } gameObject.GetComponent <Life>().damage(1000, string.Concat("You were run over by ", userFromPlayer.name, "!"), -1, userFromPlayer.id); NetworkSounds.askSound("Sounds/Impacts/flesh", gameObject.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", gameObject.transform.position + Vector3.up, Quaternion.identity, -1f); } } else if (other.tag == "Animal") { GameObject owner = OwnerFinder.getOwner(other.gameObject); owner.GetComponent <AI>().damage(1000); NetworkSounds.askSound("Sounds/Impacts/flesh", owner.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", owner.transform.position + Vector3.up, Quaternion.identity, -1f); } } }
public void askItem(Vector3 position, NetworkPlayer player) { Point2 region = NetworkRegions.getRegion(position); int indexFromPositionServer = SpawnItems.getIndexFromPositionServer(region, position); if (indexFromPositionServer != -1) { GameObject modelFromPlayer = NetworkUserList.getModelFromPlayer(player); if (modelFromPlayer != null) { Inventory component = modelFromPlayer.GetComponent <Inventory>(); if (component.hasSpace(SpawnItems.regions[region.x, region.y].items[indexFromPositionServer]) == 0) { component.addItem(SpawnItems.regions[region.x, region.y].items[indexFromPositionServer]); base.networkView.RPC("destroyItem", RPCMode.All, new object[] { position }); NetworkSounds.askSound("Sounds/General/take", component.transform.position, 0.1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); NetworkManager.error(Texts.ALERT_ITEM_ADDED, string.Empty, player); if (!modelFromPlayer.networkView.isMine) { modelFromPlayer.networkView.RPC("tookItem", player, new object[0]); } else { modelFromPlayer.GetComponent <Player>().tookItem(); } } } } }
public void askMaul(NetworkPlayer player) { if (!this.dead && this.target != null && this.destroy == null) { GameObject modelFromPlayer = NetworkUserList.getModelFromPlayer(player); if (modelFromPlayer != null && modelFromPlayer == this.target) { float armor = 10f * (1f - modelFromPlayer.GetComponent <Skills>().warrior() * 0.4f); if (modelFromPlayer.GetComponent <Clothes>().vest != -1) { armor = armor * ArmorStats.getArmor(modelFromPlayer.GetComponent <Clothes>().vest); } modelFromPlayer.GetComponent <Life>().damage((int)armor, "You were mauled by a zombie!", -20, ""); if (ServerSettings.mode != 2) { modelFromPlayer.GetComponent <Life>().infect(4); } else { modelFromPlayer.GetComponent <Life>().infect(12); } base.networkView.RPC("swing", RPCMode.All, new object[0]); Transform transforms = base.transform; float single = modelFromPlayer.transform.position.z - base.transform.position.z; float single1 = modelFromPlayer.transform.position.x; Vector3 vector3 = base.transform.position; transforms.rotation = Quaternion.Euler(0f, 90f - Mathf.Atan2(single, single1 - vector3.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); NetworkEffects.askEffect("Effects/flesh", modelFromPlayer.transform.position + Vector3.up, Quaternion.identity, -1f); } } }
public override void startPrimary() { Equipment.busy = true; this.startedUse = Time.realtimeSinceStartup; 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); Viewmodel.play("use"); }
public void OnTriggerEnter(Collider other) { if (other.tag == "Player" && this.powered) { InteractionInterface.sendTrap(base.transform.parent.position); NetworkSounds.askSound("Sounds/Barricades/electrocute", other.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", other.transform.position + Vector3.up, Quaternion.identity, -1f); } }
public void changeShirt(int setShirt) { if (setShirt != -1 || this.shirt != -1) { base.networkView.RPC("tellShirt", RPCMode.All, new object[] { setShirt }); PlayerPrefs.SetInt(string.Concat("lastShirt_", PlayerSettings.id), Sneaky.sneak(setShirt)); NetworkSounds.askSound("Sounds/Clothes/sleeve", base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } }
public override void tick() { if (this.swinging && Time.realtimeSinceStartup - this.lastSwing > 0.1f) { this.lastSwing = Time.realtimeSinceStartup; NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Repair.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Repair.hit.collider != null) { NetworkEffects.askEffect("Effects/repair", Repair.hit.point + (Repair.hit.normal * 0.05f), Quaternion.LookRotation(Repair.hit.normal), -1f); if (Repair.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Repair.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Repair.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb); } } } else if (Repair.hit.collider.tag == "Animal") { int num = OwnerFinder.getLimb(Repair.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Repair.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, num }); } else { this.swingAnimal(gameObject.networkView.viewID, num); } } } else if (Repair.hit.collider.tag == "Vehicle" && Repair.hit.collider.GetComponent <Vehicle>().health < Repair.hit.collider.GetComponent <Vehicle>().maxHealth&& !Repair.hit.collider.GetComponent <Vehicle>().exploded) { if (!Network.isServer) { base.networkView.RPC("swingVehicle", RPCMode.Server, new object[] { Repair.hit.collider.networkView.viewID }); } else { this.swingVehicle(Repair.hit.collider.networkView.viewID); } } } } }
public void OnDestroy() { if (Network.isServer) { ExplosionTool.explode(base.transform.position, (float)ExplosiveStats.getRange(23007), ExplosiveStats.getDamage(23007)); NetworkEffects.askEffect("Effects/grenade", base.transform.position + Vector3.up, Quaternion.Euler(-90f, 0f, 0f), -1f); NetworkEffects.askEffect("Effects/rubble", base.transform.position, Quaternion.Euler(-90f, 0f, 0f), -1f); NetworkSounds.askSound("Sounds/Projectiles/grenade", base.transform.position, 1f, UnityEngine.Random.Range(0.95f, 1.05f), 2f); } }
private void scarePlayer(CommandArgs args) { string parametersAsString = args.ParametersAsString; BetterNetworkUser userFromName = UserList.getUserFromName(parametersAsString); Vector3 position = userFromName.position; for (int i = 0; i < 100; i++) { NetworkSounds.askSound("Sounds/Vehicles/horn", position, 50f, 1f, 20f); } }
public override void startSecondary() { if (!Network.isServer) { base.networkView.RPC("toggleFlashlight", RPCMode.Server, new object[] { Equipment.equipped.x, Equipment.equipped.y }); } else { this.toggleFlashlight(Equipment.equipped.x, Equipment.equipped.y); } NetworkSounds.askSound("Sounds/General/firemode", base.transform.position, 0.1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); }
public override void startPrimary() { Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Jack.hit, 5f, -29365511); if (Jack.hit.collider != null && Jack.hit.collider.tag == "Vehicle" && Jack.hit.collider.GetComponent <Vehicle>().lastSpeed == 0) { this.target = Jack.hit.collider.gameObject; 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.busy = true; this.startedUse = Time.realtimeSinceStartup; Viewmodel.play("use"); } }
public override void startPrimary() { Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Fertilizer.hit, 5f, -29365511); if (Fertilizer.hit.collider != null && Fertilizer.hit.collider.tag == "Barricade" && ItemType.getType(int.Parse(Fertilizer.hit.collider.transform.parent.name)) == 22) { this.target = Fertilizer.hit.collider.gameObject; 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.busy = true; this.startedUse = Time.realtimeSinceStartup; Viewmodel.play("use"); } }
public override void startPrimary() { Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Gas.hit, 5f, -29365511); if (Gas.hit.collider != null && (Player.inventory.items[Equipment.equipped.x, Equipment.equipped.y].state == "f" && Gas.hit.collider.tag == "Vehicle" && Gas.hit.collider.GetComponent <Vehicle>().fuel < Gas.hit.collider.GetComponent <Vehicle>().maxFuel || Player.inventory.items[Equipment.equipped.x, Equipment.equipped.y].state == "e" && Gas.hit.collider.tag == "Vehicle" && Gas.hit.collider.GetComponent <Vehicle>().fuel >= 50 || Player.inventory.items[Equipment.equipped.x, Equipment.equipped.y].state == "e" && (Gas.hit.collider.name == "gasTank" || Gas.hit.collider.name == "gasPump"))) { this.target = Gas.hit.collider.gameObject; 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.busy = true; this.startedUse = Time.realtimeSinceStartup; Viewmodel.play("use"); } }
public void OnTriggerEnter(Collider other) { if (other.tag == "Player") { InteractionInterface.sendTrap(base.transform.parent.position); if (ServerSettings.pvp) { Player.life.sendBones(); } NetworkSounds.askSound("Sounds/Barricades/snare", other.transform.position + Vector3.up, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", other.transform.position + Vector3.up, Quaternion.identity, -1f); } }
public void changeBackpack(int backpack) { if (backpack != -1 || this.backpack != -1) { if (Equipment.equipped.x != -1 && (Equipment.equipped.x >= BagSize.getWidth(backpack) || Equipment.equipped.y >= BagSize.getHeight(backpack)) && Equipment.id != backpack) { Equipment.dequip(); } base.networkView.RPC("tellBackpack", RPCMode.All, new object[] { backpack }); PlayerPrefs.SetInt(string.Concat("lastBackpack_", PlayerSettings.id), Sneaky.sneak(backpack)); NetworkSounds.askSound("Sounds/Clothes/zipper", base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } }
public void startBones() { if (!this.bones) { this.bones = true; this.startedBones = Time.realtimeSinceStartup; if (base.networkView.owner != Network.player) { base.networkView.RPC("tellBones", base.networkView.owner, new object[] { this.bones }); } else { this.tellBones(this.bones); } NetworkSounds.askSound("Sounds/Life/bones", base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } }
public void askEnter(NetworkPlayer player) { if (this.real && !this.wrecked && !this.exploded && Mathf.Abs(this.lastSpeed) < 5) { GameObject modelFromPlayer = NetworkUserList.getModelFromPlayer(player); if (modelFromPlayer != null && !modelFromPlayer.GetComponent <Life>().dead) { int num = 0; while (num < (int)this.passengers.Length) { if (this.passengers[num] != null) { num++; } else { if (num == 0) { base.rigidbody.isKinematic = true; base.rigidbody.useGravity = false; this.stop(); if (this.fuel > 0) { NetworkSounds.askSound("Sounds/Vehicles/ignition", base.transform.position + (base.transform.right * 2f), 1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } } this.passengers[num] = new Passenger(player); if (player != Network.player) { base.networkView.RPC("tellEnter", player, new object[] { num }); base.networkView.RPC("tellFuel", player, new object[] { this.fuel }); base.networkView.RPC("updateSpeed", player, new object[] { this.lastSpeed }); } else { this.tellEnter(num); this.tellFuel_Pizza(this.fuel); this.updateSpeed(this.lastSpeed); } base.networkView.RPC("tellSitting", RPCMode.All, new object[] { player, num }); break; } } } } }
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 askSwap(NetworkPlayer player, int seat) { if (this.real && seat < (int)this.passengers.Length && this.passengers[seat] == null) { for (int i = 0; i < (int)this.passengers.Length; i++) { if (this.passengers[i] != null && this.passengers[i].player == player) { if (i == 0) { base.rigidbody.isKinematic = false; base.rigidbody.useGravity = true; base.rigidbody.AddForce(base.transform.right * (float)this.lastSpeed); this.stop(); } this.passengers[i] = null; } } if (seat == 0) { if (this.fuel > 0) { NetworkSounds.askSound("Sounds/Vehicles/ignition", base.transform.position + (base.transform.right * 2f), 1f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } base.rigidbody.isKinematic = true; base.rigidbody.useGravity = false; this.stop(); } this.passengers[seat] = new Passenger(player); if (player != Network.player) { base.networkView.RPC("tellEnter", player, new object[] { seat }); base.networkView.RPC("tellFuel", player, new object[] { this.fuel }); base.networkView.RPC("updateSpeed", player, new object[] { this.lastSpeed }); } else { this.tellEnter(seat); this.tellFuel_Pizza(this.fuel); this.updateSpeed(this.lastSpeed); } base.networkView.RPC("tellSitting", RPCMode.All, new object[] { player, seat }); } }
public override void startPrimary() { if (Player.inventory.items[Equipment.equipped.x, Equipment.equipped.y].state != "f") { Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Refillable.hit, 5f, -29365511); if (Refillable.hit.collider != null && (Refillable.hit.point.y < Ocean.level || Refillable.hit.collider.name == "well_0")) { this.self = false; Equipment.busy = true; this.startedUse = Time.realtimeSinceStartup; Viewmodel.play("use"); } } else { this.self = 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); Equipment.busy = true; this.startedUse = Time.realtimeSinceStartup; Viewmodel.play("drink"); } }
public void askAgro(NetworkPlayer player) { if (!this.dead) { GameObject modelFromPlayer = NetworkUserList.getModelFromPlayer(player); if (modelFromPlayer != null && (this.target == null || modelFromPlayer != this.target && (modelFromPlayer.transform.position - base.transform.position).magnitude < (this.target.transform.position - base.transform.position).magnitude)) { this.target = modelFromPlayer; if (this.search) { this.moveTo = Vector3.zero; base.networkView.RPC("tellSearch", RPCMode.All, new object[] { false }); } if (!this.agro) { base.networkView.RPC("tellAgro", RPCMode.All, new object[] { true }); this.tick(); 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), 0.5f); } } } }
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(); } }
public void askDrop(int x, int y, bool all, NetworkPlayer player) { GameObject playerModel = NetworkUserList.getModelFromPlayer(player); if (playerModel != null) { Inventory inventory = playerModel.GetComponent <Inventory>(); if (x >= 0 && y >= 0 && x < inventory.width && y < inventory.height && inventory.items[x, y].amount > 0) { Vector3 position = inventory.transform.position; if (inventory.transform.GetComponent <Player>().vehicle != null) { position = inventory.transform.GetComponent <Player>().vehicle.getPosition(); } if (!ItemStackable.getStackable(inventory.items[x, y].id)) { SpawnItems.drop(inventory.items[x, y].id, inventory.items[x, y].amount, inventory.items[x, y].state, position); inventory.useItem(x, y); } else if (!all) { SpawnItems.drop(inventory.items[x, y].id, 1, inventory.items[x, y].state, position); inventory.useItem(x, y); } else { for (int i = 0; i < inventory.items[x, y].amount; i++) { SpawnItems.drop(inventory.items[x, y].id, 1, inventory.items[x, y].state, position); } inventory.deleteItem(x, y); } inventory.syncItem(x, y); NetworkSounds.askSound("Sounds/General/drop", position, 0.2f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } } }
public void askCraft(int x_0, int y_0, int x_1, int y_1, int xTool, int yTool, int mode, bool all) { if (!base.GetComponent <Life>().dead&& (x_0 == -1 || this.items[x_0, y_0].id != -1) && (x_1 == -1 || this.items[x_1, y_1].id != -1) && (xTool == -1 || this.items[xTool, yTool].id != -1)) { if (x_0 == -1 || x_1 == -1 || ItemType.getType(this.items[x_0, y_0].id) != 10 || ItemType.getType(this.items[x_1, y_1].id) != 10 || !AmmoStats.getCaliberCompatible(this.items[x_0, y_0].id, this.items[x_1, y_1].id) || this.items[x_0, y_0].amount <= 1 || this.items[x_1, y_1].amount <= 1) { bool flag = Cooking.fire(base.transform.position); bool flag1 = false; int num = 0; while (num < (int)Blueprints.prints.Length) { if (!flag1) { Blueprint blueprint = Blueprints.prints[num]; if ((mode == 0 && !blueprint.fire || mode == 1 && blueprint.fire && flag) && (blueprint.knowledge == 0f || base.GetComponent <Skills>().crafting() >= blueprint.knowledge) && ((blueprint.id_0 == -1 && x_0 == -1 || x_0 != -1 && blueprint.id_0 == this.items[x_0, y_0].id) && (blueprint.id_1 == -1 && x_1 == -1 || x_1 != -1 && blueprint.id_1 == this.items[x_1, y_1].id) || (blueprint.id_0 == -1 && x_1 == -1 || x_1 != -1 && blueprint.id_0 == this.items[x_1, y_1].id) && (blueprint.id_1 == -1 && x_0 == -1 || x_0 != -1 && blueprint.id_1 == this.items[x_0, y_0].id)) && (blueprint.idTool == -1 && xTool == -1 || xTool != -1 && blueprint.idTool == this.items[xTool, yTool].id)) { int num1 = 0; while (true) { if ((blueprint.id_0 == -1 && x_0 == -1 || x_0 != -1 && blueprint.id_0 == this.items[x_0, y_0].id && this.items[x_0, y_0].amount >= blueprint.amount_0) && (blueprint.id_1 == -1 && x_1 == -1 || x_1 != -1 && blueprint.id_1 == this.items[x_1, y_1].id && this.items[x_1, y_1].amount >= blueprint.amount_1) && (blueprint.idTool == -1 && xTool == -1 || xTool != -1 && blueprint.idTool == this.items[xTool, yTool].id)) { if (x_0 != -1) { this.useItem(x_0, y_0, blueprint.amount_0); } if (x_1 != -1) { this.useItem(x_1, y_1, blueprint.amount_1); } num1++; } else if ((blueprint.id_0 != -1 || x_1 != -1) && (x_1 == -1 || blueprint.id_0 != this.items[x_1, y_1].id || this.items[x_1, y_1].amount < blueprint.amount_0) || (blueprint.id_1 != -1 || x_0 != -1) && (x_0 == -1 || blueprint.id_1 != this.items[x_0, y_0].id || this.items[x_0, y_0].amount < blueprint.amount_1) || (blueprint.idTool != -1 || xTool != -1) && (xTool == -1 || blueprint.idTool != this.items[xTool, yTool].id)) { break; } else { if (x_1 != -1) { this.useItem(x_1, y_1, blueprint.amount_0); } if (x_0 != -1) { this.useItem(x_0, y_0, blueprint.amount_1); } num1++; } if (!all || ItemType.getType(blueprint.id_0) == 10 || ItemType.getType(blueprint.id_1) == 10) { break; } } for (int i = 0; i < num1; i++) { this.tryAddItem(blueprint.idReward, blueprint.amountReward); } flag1 = true; } num++; } else { if (x_0 != -1) { this.syncItem(x_0, y_0); } if (x_1 != -1) { this.syncItem(x_1, y_1); } NetworkSounds.askSound("Sounds/General/craft", base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); break; } } } else { int num2 = this.items[x_0, y_0].id; int num3 = this.items[x_1, y_1].id; int amount = this.items[x_0, y_0].amount; int amount1 = this.items[x_1, y_1].amount; amount1 = amount1 + (this.items[x_0, y_0].amount - 1); if (amount1 <= ItemAmount.getAmount(this.items[x_1, y_1].id)) { num2 = -1; } else { amount = amount1 - ItemAmount.getAmount(this.items[x_1, y_1].id) + 1; amount1 = ItemAmount.getAmount(this.items[x_1, y_1].id); } this.deleteItem(x_0, y_0); this.deleteItem(x_1, y_1); this.syncItem(x_0, y_0); this.syncItem(x_1, y_1); if (num2 != -1) { this.tryAddItem(num2, amount, string.Empty); } if (num3 != -1) { this.tryAddItem(num3, amount1, string.Empty); } NetworkSounds.askSound("Sounds/General/craft", base.transform.position, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); } } }
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(); } }
public override void tick() { if (this.swinging && Time.realtimeSinceStartup - this.lastSwing > 0.1f) { Viewmodel.offset_x = UnityEngine.Random.Range(-0.02f, 0.02f); Viewmodel.offset_y = UnityEngine.Random.Range(-0.02f, 0.02f); Viewmodel.offset_z = UnityEngine.Random.Range(-0.02f, 0.02f); this.lastSwing = Time.realtimeSinceStartup; NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Chainsaw.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Chainsaw.hit.collider != null) { if (Chainsaw.hit.point.y < Ocean.level) { NetworkSounds.askSound("Sounds/Impacts/rock", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/bubbles", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.gameObject.name == "ground" || Chainsaw.hit.collider.material.name.ToLower() == "rock (instance)" || Chainsaw.hit.collider.material.name.ToLower() == "ground (instance)") { NetworkSounds.askSound("Sounds/Impacts/rock", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/rock", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "cloth (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/cloth", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "wood (instance)") { NetworkSounds.askSound("Sounds/Impacts/wood", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/splinters", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "tile (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/tile", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "concrete (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/concrete", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "metal (instance)" || Chainsaw.hit.collider.material.name.ToLower() == "iron (instance)") { NetworkSounds.askSound("Sounds/Impacts/metal", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/sparks", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } else if (Chainsaw.hit.collider.material.name.ToLower() == "flesh (instance)") { NetworkSounds.askSound("Sounds/Impacts/flesh", Chainsaw.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", Chainsaw.hit.point + (Chainsaw.hit.normal * 0.05f), Quaternion.LookRotation(Chainsaw.hit.normal), -1f); } if (Chainsaw.hit.collider.tag == "Resource") { if (Chainsaw.hit.collider.name.Substring(0, 4) != "rock") { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; int num = int.Parse(Chainsaw.hit.collider.transform.parent.name.Substring(Chainsaw.hit.collider.transform.parent.name.IndexOf("_") + 1)); if (!Network.isServer) { base.networkView.RPC("swingResource", RPCMode.Server, new object[] { num }); } else { this.swingResource(num); } } } else if (Chainsaw.hit.collider.tag == "Barricade") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingBarricade", RPCMode.Server, new object[] { Chainsaw.hit.collider.transform.parent.position }); } else { this.swingBarricade(Chainsaw.hit.collider.transform.parent.position); } } else if (Chainsaw.hit.collider.tag == "Structure") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingStructure", RPCMode.Server, new object[] { Chainsaw.hit.collider.transform.parent.position }); } else { // FIXME: client side? //this.swingStructure(Chainsaw.hit.collider.transform.parent.position); } } else if (Chainsaw.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Chainsaw.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Chainsaw.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb); } } } else if (Chainsaw.hit.collider.tag == "Animal") { int limb1 = OwnerFinder.getLimb(Chainsaw.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Chainsaw.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, limb1 }); } else { this.swingAnimal(gameObject.networkView.viewID, limb1); } } } else if (Chainsaw.hit.collider.tag == "Vehicle" && Chainsaw.hit.collider.GetComponent <Vehicle>().health > 0 && ServerSettings.pvp) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingVehicle", RPCMode.Server, new object[] { Chainsaw.hit.collider.networkView.viewID }); } else { this.swingVehicle(Chainsaw.hit.collider.networkView.viewID); } } } } }
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) { 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.swung) { if (Time.realtimeSinceStartup - this.lastSwing > (!this.lastStrong ? Viewmodel.model.animation["swingWeak"].length / 2f : Viewmodel.model.animation["swingStrong"].length / 2f)) { NetworkSounds.askSound(string.Concat("Sounds/Items/", ItemSounds.getSource(Equipment.id), "/use"), Camera.main.transform.position + (Camera.main.transform.forward * 0.5f), 0.25f, UnityEngine.Random.Range(0.9f, 1.1f), 1f); this.swung = false; Physics.Raycast(Camera.main.transform.position + (Camera.main.transform.forward * -0.5f), Camera.main.transform.forward, out Melee.hit, MeleeStats.getRange(Equipment.id) + 0.5f, RayMasks.DAMAGE); if (Melee.hit.collider != null) { if (Melee.hit.point.y < Ocean.level) { NetworkSounds.askSound("Sounds/Impacts/rock", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/bubbles", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.gameObject.name == "ground" || Melee.hit.collider.material.name.ToLower() == "rock (instance)" || Melee.hit.collider.material.name.ToLower() == "ground (instance)") { NetworkSounds.askSound("Sounds/Impacts/rock", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/rock", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "cloth (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/cloth", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "wood (instance)") { NetworkSounds.askSound("Sounds/Impacts/wood", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/splinters", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "tile (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/tile", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "concrete (instance)") { NetworkSounds.askSound("Sounds/Impacts/concrete", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/concrete", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "metal (instance)" || Melee.hit.collider.material.name.ToLower() == "iron (instance)") { NetworkSounds.askSound("Sounds/Impacts/metal", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/sparks", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } else if (Melee.hit.collider.material.name.ToLower() == "flesh (instance)") { NetworkSounds.askSound("Sounds/Impacts/flesh", Melee.hit.point, 0.5f, UnityEngine.Random.Range(0.9f, 1.1f), 0.25f); NetworkEffects.askEffect("Effects/flesh", Melee.hit.point + (Melee.hit.normal * 0.05f), Quaternion.LookRotation(Melee.hit.normal), -1f); } if (Melee.hit.collider.name == "ground" || Melee.hit.collider.tag == "Prop" || Melee.hit.collider.tag == "World" || Melee.hit.collider.tag == "Environment" || Melee.hit.collider.tag == "Global") { NetworkEffects.askEffect("Effects/hole", Melee.hit.point + (Melee.hit.normal * UnityEngine.Random.Range(0.04f, 0.06f)), Quaternion.LookRotation(Melee.hit.normal) * Quaternion.Euler(0f, 0f, (float)UnityEngine.Random.Range(0, 360)), 20f); } if (Melee.hit.collider.tag == "Barricade") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingBarricade", RPCMode.Server, new object[] { Melee.hit.collider.transform.parent.position, this.lastStrong }); } else { this.swingBarricade(Melee.hit.collider.transform.parent.position, this.lastStrong); } } else if (Melee.hit.collider.tag == "Structure") { //HUDGame.lastStructmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingStructure", RPCMode.Server, new object[] { Melee.hit.collider.transform.parent.position, this.lastStrong }); } else { // FIXME: client stuff? //this.swingStructure(Melee.hit.collider.transform.parent.position, this.lastStrong); } } else if (Melee.hit.collider.tag == "Enemy" && ServerSettings.pvp) { int limb = OwnerFinder.getLimb(Melee.hit.collider.gameObject); GameObject owner = OwnerFinder.getOwner(Melee.hit.collider.gameObject); if (owner != null && owner.GetComponent <Player>().action != 4 && (PlayerSettings.friend == string.Empty || PlayerSettings.friendHash != owner.GetComponent <Player>().owner.friend)) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingPlayer", RPCMode.Server, new object[] { owner.GetComponent <Player>().owner.id, limb, this.lastStrong }); } else { this.swingPlayer(owner.GetComponent <Player>().owner.id, limb, this.lastStrong); } } } else if (Melee.hit.collider.tag == "Animal") { int num = OwnerFinder.getLimb(Melee.hit.collider.gameObject); GameObject gameObject = OwnerFinder.getOwner(Melee.hit.collider.gameObject); if (gameObject != null && !gameObject.GetComponent <AI>().dead) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingAnimal", RPCMode.Server, new object[] { gameObject.networkView.viewID, num, this.lastStrong }); } else { this.swingAnimal(gameObject.networkView.viewID, num, this.lastStrong); } } } else if (Melee.hit.collider.tag == "Vehicle" && Melee.hit.collider.GetComponent <Vehicle>().health > 0 && ServerSettings.pvp) { //HUDGame.lastHitmarker = Time.realtimeSinceStartup; if (!Network.isServer) { base.networkView.RPC("swingVehicle", RPCMode.Server, new object[] { Melee.hit.collider.networkView.viewID, this.lastStrong }); } else { this.swingVehicle(Melee.hit.collider.networkView.viewID, this.lastStrong); } } } } } if (this.swinging && Movement.vehicle == null && (!this.strong || Player.life.stamina >= 10 - (int)(Player.skills.endurance() * 10f))) { if (Time.realtimeSinceStartup - this.lastSwing <= (!this.lastStrong ? Viewmodel.model.animation["swingWeak"].length : Viewmodel.model.animation["swingStrong"].length)) { this.swinging = false; return; } if (this.strong) { Player.life.exhaust(10 - (int)(Player.skills.endurance() * 10f)); } this.lastStrong = this.strong; this.swinging = false; this.lastSwing = Time.realtimeSinceStartup; this.swung = true; if (!this.strong) { Viewmodel.play("swingWeak"); } else { Viewmodel.play("swingStrong"); } if (Stance.state == 0) { Player.play("standMelee"); } else if (Stance.state == 1) { Player.play("crouchMelee"); } else if (Stance.state == 2) { Player.play("proneMelee"); } return; } this.swinging = false; }