// Token: 0x060021B8 RID: 8632 RVA: 0x000B3904 File Offset: 0x000B1D04 private void Start() { if (Level.isEditor) { this.updateWired(true); } else { ushort maxValue = ushort.MaxValue; if (base.isPlant) { byte b; byte b2; BarricadeRegion barricadeRegion; BarricadeManager.tryGetPlant(base.transform.parent, out b, out b2, out maxValue, out barricadeRegion); } List <InteractableGenerator> list = PowerTool.checkGenerators(base.transform.position, 64f, maxValue); for (int i = 0; i < list.Count; i++) { InteractableGenerator interactableGenerator = list[i]; if (interactableGenerator.isPowered && interactableGenerator.fuel > 0 && (interactableGenerator.transform.position - base.transform.position).sqrMagnitude < interactableGenerator.sqrWirerange) { this.updateWired(true); return; } } } }
private void updateWire() { if (this.engine != null) { this.engine.gameObject.SetActive(this.isPowered && this.fuel > 0); } ushort maxValue = ushort.MaxValue; if (base.isPlant) { byte b; byte b2; BarricadeRegion barricadeRegion; BarricadeManager.tryGetPlant(base.transform.parent, out b, out b2, out maxValue, out barricadeRegion); } List <InteractablePower> list = PowerTool.checkPower(base.transform.position, this.wirerange, maxValue); for (int i = 0; i < list.Count; i++) { InteractablePower interactablePower = list[i]; if (interactablePower.isWired) { if (!this.isPowered || this.fuel == 0) { bool flag = false; List <InteractableGenerator> list2 = PowerTool.checkGenerators(interactablePower.transform.position, 64f, maxValue); for (int j = 0; j < list2.Count; j++) { if (list2[j] != this && list2[j].isPowered && list2[j].fuel > 0 && (list2[j].transform.position - interactablePower.transform.position).sqrMagnitude < list2[j].sqrWirerange) { flag = true; break; } } if (!flag) { interactablePower.updateWired(false); } } } else if (this.isPowered && this.fuel > 0) { interactablePower.updateWired(true); } } }
// Token: 0x06003469 RID: 13417 RVA: 0x001572F0 File Offset: 0x001556F0 public static bool checkFires(Vector3 point, float radius) { PowerTool.firesInRadius.Clear(); PowerTool.checkInteractables <InteractableFire>(point, radius, ushort.MaxValue, PowerTool.firesInRadius); for (int i = 0; i < PowerTool.firesInRadius.Count; i++) { if (PowerTool.firesInRadius[i].isLit) { return(true); } } PowerTool.ovensInRadius.Clear(); PowerTool.checkInteractables <InteractableOven>(point, radius, ushort.MaxValue, PowerTool.ovensInRadius); for (int j = 0; j < PowerTool.ovensInRadius.Count; j++) { if (PowerTool.ovensInRadius[j].isWired && PowerTool.ovensInRadius[j].isLit) { return(true); } } return(false); }
public void askCraft(CSteamID steamID, ushort id, byte index, bool force) { if (base.channel.checkOwner(steamID)) { if (base.player.equipment.isBusy) { return; } if (!base.player.tryToPerformRateLimitedAction()) { return; } ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, id); if (itemAsset != null) { if ((int)index >= itemAsset.blueprints.Count) { return; } Blueprint blueprint = itemAsset.blueprints[(int)index]; if (blueprint.skill == EBlueprintSkill.REPAIR && (uint)blueprint.level > Provider.modeConfigData.Gameplay.Repair_Level_Max) { return; } if (!string.IsNullOrEmpty(blueprint.map) && !blueprint.map.Equals(Level.info.name, StringComparison.InvariantCultureIgnoreCase)) { return; } if (blueprint.tool != 0 && base.player.inventory.has(blueprint.tool) == null) { return; } if (blueprint.skill != EBlueprintSkill.NONE) { bool flag = PowerTool.checkFires(base.transform.position, 16f); if ((blueprint.skill == EBlueprintSkill.CRAFT && base.player.skills.skills[2][1].level < blueprint.level) || (blueprint.skill == EBlueprintSkill.COOK && (!flag || base.player.skills.skills[2][3].level < blueprint.level)) || (blueprint.skill == EBlueprintSkill.REPAIR && base.player.skills.skills[2][7].level < blueprint.level)) { return; } } bool flag2 = false; while (blueprint.areConditionsMet(base.player)) { List <InventorySearch>[] array = new List <InventorySearch> [blueprint.supplies.Length]; byte b = 0; while ((int)b < blueprint.supplies.Length) { BlueprintSupply blueprintSupply = blueprint.supplies[(int)b]; List <InventorySearch> list = base.player.inventory.search(blueprintSupply.id, false, true); if (list.Count == 0) { return; } ushort num = 0; byte b2 = 0; while ((int)b2 < list.Count) { num += (ushort)list[(int)b2].jar.item.amount; b2 += 1; } if (num < blueprintSupply.amount && blueprint.type != EBlueprintType.AMMO) { return; } if (blueprint.type == EBlueprintType.AMMO) { list.Sort(PlayerCrafting.amountAscendingComparator); } else { list.Sort(PlayerCrafting.qualityAscendingComparator); } array[(int)b] = list; b += 1; } if (blueprint.type == EBlueprintType.REPAIR) { List <InventorySearch> list2 = base.player.inventory.search(itemAsset.id, false, false); byte b3 = byte.MaxValue; byte b4 = byte.MaxValue; byte b5 = 0; while ((int)b5 < list2.Count) { if (list2[(int)b5].jar.item.quality < b3) { b3 = list2[(int)b5].jar.item.quality; b4 = b5; } b5 += 1; } if (b4 == 255) { return; } InventorySearch inventorySearch = list2[(int)b4]; if (base.player.equipment.checkSelection(inventorySearch.page, inventorySearch.jar.x, inventorySearch.jar.y)) { base.player.equipment.dequip(); } byte b6 = 0; while ((int)b6 < array.Length) { BlueprintSupply blueprintSupply2 = blueprint.supplies[(int)b6]; List <InventorySearch> list3 = array[(int)b6]; byte b7 = 0; while ((ushort)b7 < blueprintSupply2.amount) { InventorySearch inventorySearch2 = list3[(int)b7]; if (base.player.equipment.checkSelection(inventorySearch2.page, inventorySearch2.jar.x, inventorySearch2.jar.y)) { base.player.equipment.dequip(); } this.removeItem(inventorySearch2.page, inventorySearch2.jar); if (inventorySearch2.page < PlayerInventory.SLOTS) { base.player.equipment.sendSlot(inventorySearch2.page); } b7 += 1; } b6 += 1; } base.player.inventory.sendUpdateQuality(inventorySearch.page, inventorySearch.jar.x, inventorySearch.jar.y, 100); if (itemAsset.type == EItemType.REFILL && inventorySearch.jar.item.state[0] == 3) { inventorySearch.jar.item.state[0] = 1; base.player.inventory.sendUpdateInvState(inventorySearch.page, inventorySearch.jar.x, inventorySearch.jar.y, inventorySearch.jar.item.state); } base.channel.send("tellCraft", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[0]); } else if (blueprint.type == EBlueprintType.AMMO) { List <InventorySearch> list4 = base.player.inventory.search(itemAsset.id, true, true); int num2 = -1; byte b8 = byte.MaxValue; byte b9 = 0; while ((int)b9 < list4.Count) { if ((int)list4[(int)b9].jar.item.amount > num2 && list4[(int)b9].jar.item.amount < itemAsset.amount) { num2 = (int)list4[(int)b9].jar.item.amount; b8 = b9; } b9 += 1; } if (b8 == 255) { return; } InventorySearch inventorySearch3 = list4[(int)b8]; int num3 = (int)itemAsset.amount - num2; if (base.player.equipment.checkSelection(inventorySearch3.page, inventorySearch3.jar.x, inventorySearch3.jar.y)) { base.player.equipment.dequip(); } List <InventorySearch> list5 = array[0]; byte b10 = 0; while ((int)b10 < list5.Count) { InventorySearch inventorySearch4 = list5[(int)b10]; if (inventorySearch4.jar != inventorySearch3.jar) { if (base.player.equipment.checkSelection(inventorySearch4.page, inventorySearch4.jar.x, inventorySearch4.jar.y)) { base.player.equipment.dequip(); } if ((int)inventorySearch4.jar.item.amount > num3) { base.player.inventory.sendUpdateAmount(inventorySearch4.page, inventorySearch4.jar.x, inventorySearch4.jar.y, (byte)((int)inventorySearch4.jar.item.amount - num3)); num3 = 0; break; } num3 -= (int)inventorySearch4.jar.item.amount; base.player.inventory.sendUpdateAmount(inventorySearch4.page, inventorySearch4.jar.x, inventorySearch4.jar.y, 0); if ((index == 0 && itemAsset.blueprints.Count > 1) || itemAsset.blueprints.Count == 1) { this.removeItem(inventorySearch4.page, inventorySearch4.jar); if (inventorySearch4.page < PlayerInventory.SLOTS) { base.player.equipment.sendSlot(inventorySearch4.page); } } if (num3 == 0) { break; } } b10 += 1; } base.player.inventory.sendUpdateAmount(inventorySearch3.page, inventorySearch3.jar.x, inventorySearch3.jar.y, (byte)((int)itemAsset.amount - num3)); base.channel.send("tellCraft", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[0]); } else { byte b11 = 0; while ((int)b11 < array.Length) { BlueprintSupply blueprintSupply3 = blueprint.supplies[(int)b11]; List <InventorySearch> list6 = array[(int)b11]; byte b12 = 0; while ((ushort)b12 < blueprintSupply3.amount) { InventorySearch inventorySearch5 = list6[(int)b12]; if (base.player.equipment.checkSelection(inventorySearch5.page, inventorySearch5.jar.x, inventorySearch5.jar.y)) { base.player.equipment.dequip(); } this.removeItem(inventorySearch5.page, inventorySearch5.jar); if (inventorySearch5.page < PlayerInventory.SLOTS) { base.player.equipment.sendSlot(inventorySearch5.page); } b12 += 1; } b11 += 1; } byte b13 = 0; while ((int)b13 < blueprint.outputs.Length) { BlueprintOutput blueprintOutput = blueprint.outputs[(int)b13]; byte b14 = 0; while ((ushort)b14 < blueprintOutput.amount) { if (blueprint.transferState) { base.player.inventory.forceAddItem(new Item(blueprintOutput.id, array[0][0].jar.item.amount, array[0][0].jar.item.quality, array[0][0].jar.item.state), true); } else { base.player.inventory.forceAddItem(new Item(blueprintOutput.id, EItemOrigin.CRAFT), true); } b14 += 1; } b13 += 1; } blueprint.applyConditions(base.player, true); blueprint.grantRewards(base.player, true); base.channel.send("tellCraft", ESteamCall.OWNER, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[0]); } if (!flag2) { flag2 = true; base.player.sendStat(EPlayerStat.FOUND_CRAFTS); if (blueprint.build != 0) { EffectManager.sendEffect(blueprint.build, EffectManager.SMALL, base.transform.position); if (Provider.isServer) { AlertTool.alert(base.transform.position, 8f); } } } if (!force || blueprint.type == EBlueprintType.REPAIR || blueprint.type == EBlueprintType.AMMO) { return; } } return; } } }
private static void updateSelection(Blueprint[] view, byte typeIndex, bool uncraftable, string search) { bool flag = PowerTool.checkFires(Player.player.transform.position, 16f); List <Blueprint> list; if (view == null) { list = new List <Blueprint>(); foreach (ItemAsset itemAsset in Assets.find(EAssetType.ITEM)) { if (itemAsset != null) { for (int j = 0; j < itemAsset.blueprints.Count; j++) { Blueprint blueprint = itemAsset.blueprints[j]; if ((search.Length <= 0) ? (blueprint.type == (EBlueprintType)typeIndex) : PlayerDashboardCraftingUI.searchBlueprintText(blueprint, search)) { list.Add(blueprint); } } } } } else { list = new List <Blueprint>(view); } List <Blueprint> list2 = new List <Blueprint>(); for (int k = 0; k < list.Count; k++) { Blueprint blueprint2 = list[k]; if (blueprint2.skill != EBlueprintSkill.REPAIR || (uint)blueprint2.level <= Provider.modeConfigData.Gameplay.Repair_Level_Max) { if (string.IsNullOrEmpty(blueprint2.map) || blueprint2.map.Equals(Level.info.name, StringComparison.InvariantCultureIgnoreCase)) { ItemAsset itemAsset2 = (ItemAsset)Assets.find(EAssetType.ITEM, blueprint2.source); ushort num = 0; bool flag2 = true; blueprint2.hasSupplies = true; blueprint2.hasSkills = (blueprint2.skill == EBlueprintSkill.NONE || (blueprint2.skill == EBlueprintSkill.CRAFT && Player.player.skills.skills[2][1].level >= blueprint2.level) || (blueprint2.skill == EBlueprintSkill.COOK && flag && Player.player.skills.skills[2][3].level >= blueprint2.level) || (blueprint2.skill == EBlueprintSkill.REPAIR && Player.player.skills.skills[2][7].level >= blueprint2.level)); List <InventorySearch>[] array2 = new List <InventorySearch> [blueprint2.supplies.Length]; byte b = 0; while ((int)b < blueprint2.supplies.Length) { BlueprintSupply blueprintSupply = blueprint2.supplies[(int)b]; List <InventorySearch> list3 = Player.player.inventory.search(blueprintSupply.id, false, true); ushort num2 = 0; byte b2 = 0; while ((int)b2 < list3.Count) { num2 += (ushort)list3[(int)b2].jar.item.amount; b2 += 1; } num += num2; blueprintSupply.hasAmount = num2; if (blueprint2.type == EBlueprintType.AMMO) { if (blueprintSupply.hasAmount == 0) { blueprint2.hasSupplies = false; } } else if (blueprintSupply.hasAmount < blueprintSupply.amount) { blueprint2.hasSupplies = false; } if (blueprintSupply.hasAmount < blueprintSupply.amount && blueprintSupply.isCritical) { flag2 = false; } array2[(int)b] = list3; b += 1; } if (blueprint2.tool != 0) { InventorySearch inventorySearch = Player.player.inventory.has(blueprint2.tool); blueprint2.tools = ((inventorySearch == null) ? 0 : 1); blueprint2.hasTool = (inventorySearch != null); if (inventorySearch == null && blueprint2.toolCritical) { flag2 = false; } } else { blueprint2.tools = 1; blueprint2.hasTool = true; } if (!flag2) { num = 0; } if (blueprint2.type == EBlueprintType.REPAIR) { List <InventorySearch> list4 = Player.player.inventory.search(itemAsset2.id, false, false); byte b3 = byte.MaxValue; byte b4 = byte.MaxValue; byte b5 = 0; while ((int)b5 < list4.Count) { if (list4[(int)b5].jar.item.quality < b3) { b3 = list4[(int)b5].jar.item.quality; b4 = b5; } b5 += 1; } if (b4 != 255) { blueprint2.items = (ushort)list4[(int)b4].jar.item.quality; num += 1; } else { blueprint2.items = 0; } blueprint2.hasItem = (b4 != byte.MaxValue); } else if (blueprint2.type == EBlueprintType.AMMO) { List <InventorySearch> list5 = Player.player.inventory.search(itemAsset2.id, true, true); int num3 = -1; byte b6 = byte.MaxValue; byte b7 = 0; while ((int)b7 < list5.Count) { if ((int)list5[(int)b7].jar.item.amount > num3 && list5[(int)b7].jar.item.amount < itemAsset2.amount) { num3 = (int)list5[(int)b7].jar.item.amount; b6 = b7; } b7 += 1; } if (b6 != 255) { if (list5[(int)b6].jar.item.id == blueprint2.supplies[0].id) { BlueprintSupply blueprintSupply2 = blueprint2.supplies[0]; blueprintSupply2.hasAmount -= (ushort)num3; } blueprint2.supplies[0].amount = (ushort)((byte)((int)itemAsset2.amount - num3)); blueprint2.items = (ushort)list5[(int)b6].jar.item.amount; num += 1; } else { blueprint2.supplies[0].amount = 0; blueprint2.items = 0; } blueprint2.hasItem = (b6 != byte.MaxValue); if (b6 == 255) { blueprint2.products = 0; } else if (blueprint2.items + blueprint2.supplies[0].hasAmount > (ushort)itemAsset2.amount) { blueprint2.products = (ushort)itemAsset2.amount; } else { blueprint2.products = blueprint2.items + blueprint2.supplies[0].hasAmount; } } else { blueprint2.hasItem = true; } if (uncraftable) { if (blueprint2.hasSupplies && blueprint2.hasTool && blueprint2.hasItem && blueprint2.hasSkills) { list2.Add(blueprint2); } } else if (view != null) { if (blueprint2.hasSupplies && blueprint2.hasTool && blueprint2.hasItem && blueprint2.hasSkills) { list2.Insert(0, blueprint2); } else { list2.Add(blueprint2); } } else if (blueprint2.hasSupplies && blueprint2.hasTool && blueprint2.hasItem && blueprint2.hasSkills) { list2.Insert(0, blueprint2); } else if ((blueprint2.type == EBlueprintType.AMMO || blueprint2.type == EBlueprintType.REPAIR || num != 0) && blueprint2.hasItem) { list2.Add(blueprint2); } } } } PlayerDashboardCraftingUI.viewBlueprints = view; PlayerDashboardCraftingUI.selectedType = typeIndex; PlayerDashboardCraftingUI.hideUncraftable = uncraftable; PlayerDashboardCraftingUI.searchText = search; PlayerDashboardCraftingUI.blueprints = list2.ToArray(); PlayerDashboardCraftingUI.blueprintsScrollBox.remove(); PlayerDashboardCraftingUI.blueprintsScrollBox.area = new Rect(0f, 0f, 5f, (float)(PlayerDashboardCraftingUI.blueprints.Length * 205 - 10)); for (int l = 0; l < PlayerDashboardCraftingUI.blueprints.Length; l++) { Blueprint newBlueprint = PlayerDashboardCraftingUI.blueprints[l]; SleekBlueprint sleekBlueprint = new SleekBlueprint(newBlueprint); sleekBlueprint.positionOffset_Y = l * 205; sleekBlueprint.sizeOffset_X = -30; sleekBlueprint.sizeOffset_Y = 195; sleekBlueprint.sizeScale_X = 1f; SleekButton sleekButton = sleekBlueprint; if (PlayerDashboardCraftingUI.< > f__mg$cache0 == null) { PlayerDashboardCraftingUI.< > f__mg$cache0 = new ClickedButton(PlayerDashboardCraftingUI.onClickedBlueprintButton); } sleekButton.onClickedButton = PlayerDashboardCraftingUI.< > f__mg$cache0; PlayerDashboardCraftingUI.blueprintsScrollBox.add(sleekBlueprint); } PlayerDashboardCraftingUI.infoBox.isVisible = (PlayerDashboardCraftingUI.blueprints.Length == 0); }
// Token: 0x0600346B RID: 13419 RVA: 0x001573CB File Offset: 0x001557CB public static List <InteractablePower> checkPower(Vector3 point, float radius, ushort plant) { PowerTool.powerInRadius.Clear(); PowerTool.checkInteractables <InteractablePower>(point, radius, plant, PowerTool.powerInRadius); return(PowerTool.powerInRadius); }
public override void tick() { if (base.channel.isOwner) { if ((base.transform.position - this.chargePoint).sqrMagnitude > 1f) { this.chargePoint = base.transform.position; this.foundInRadius.Clear(); PowerTool.checkInteractables <InteractableCharge>(this.chargePoint, 64f, this.foundInRadius); for (int i = this.chargesInRadius.Count - 1; i >= 0; i--) { InteractableCharge interactableCharge = this.chargesInRadius[i]; if (interactableCharge == null) { this.chargesInRadius.RemoveAtFast(i); } else if (!this.foundInRadius.Contains(interactableCharge)) { interactableCharge.unhighlight(); this.chargesInRadius.RemoveAtFast(i); } } for (int j = 0; j < this.foundInRadius.Count; j++) { InteractableCharge interactableCharge2 = this.foundInRadius[j]; if (!(interactableCharge2 == null)) { if (interactableCharge2.hasOwnership) { if (!this.chargesInRadius.Contains(interactableCharge2)) { interactableCharge2.highlight(); this.chargesInRadius.Add(interactableCharge2); } } } } } InteractableCharge interactableCharge3 = null; float num = 0.98f; for (int k = 0; k < this.chargesInRadius.Count; k++) { InteractableCharge interactableCharge4 = this.chargesInRadius[k]; if (!(interactableCharge4 == null)) { float num2 = Vector3.Dot((interactableCharge4.transform.position - MainCamera.instance.transform.position).normalized, MainCamera.instance.transform.forward); if (num2 > num) { interactableCharge3 = interactableCharge4; num = num2; } } } if (interactableCharge3 != this.target) { if (this.target != null) { this.target.untarget(); } this.target = interactableCharge3; if (this.target != null) { this.target.target(); } } } }