public static void StoreItem(Player player, QuantumStorageControllerMachine quantumStorageController, ItemBase itemToStore) { var itemToStoreCopy = itemToStore.NewInstance(); if (player == WorldScript.mLocalPlayer && !WorldScript.mLocalPlayer.mInventory.RemoveItemByExample(itemToStore, true)) { return; } quantumStorageController.AddItem(ref itemToStore); quantumStorageController.Dirty = true; if (itemToStore != null && itemToStore.GetAmount() > 0) { if (player == WorldScript.mLocalPlayer) { WorldScript.mLocalPlayer.mInventory.AddItem(itemToStore); } } if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumIoPortWindowKey, "StoreItem", null, itemToStoreCopy, quantumStorageController, 0.0f); } }
public static bool TakeItem(Player player, QuantumStorageControllerMachine quantumStorageController, ItemBase itemBase) { var itemBaseCopy = itemBase.NewInstance(); var amount = itemBase.GetAmount(); quantumStorageController.TakeItem(ref itemBase); itemBase.SetAmount(amount - itemBase.GetAmount()); if (!player.mInventory.AddItem(itemBase)) { quantumStorageController.AddItem(ref itemBase); if (itemBase.GetAmount() > 0) { ItemManager.instance.DropItem(itemBase, WorldScript.mLocalPlayer.mnWorldX, WorldScript.mLocalPlayer.mnWorldY, WorldScript.mLocalPlayer.mnWorldZ, Vector3.zero); } return(false); } quantumStorageController.Dirty = true; if (!WorldScript.mbIsServer) { NetworkManager.instance.SendInterfaceCommand(QuantumStorageMod.QuantumIoPortWindowKey, "TakeItem", null, itemBaseCopy, quantumStorageController, 0.0f); } return(true); }
private void WindowUpdate(QuantumStorageControllerMachine controller) { if (controller.HasPower()) { manager.UpdateLabel(StorageSizeLabel, controller.GetItems().GetItemCount() + "/" + controller.GetMaxCapacity(), Color.white); manager.UpdateLabel(InputStatusLabel, controller.IsInputEnabled() ? "Input enabled" : "Input disabled", Color.white); manager.UpdateLabel(OutputStatusLabel, controller.IsOutputEnabled() ? "Output enabled" : "Output disabled", Color.white); manager.UpdateLabel(StatusLabel, "POWER OK", Color.white); } if (!controller.HasPower()) { manager.UpdateLabel(StorageSizeLabel, string.Empty, Color.white); manager.UpdateLabel(InputStatusLabel, string.Empty, Color.white); manager.UpdateLabel(OutputStatusLabel, string.Empty, Color.white); manager.UpdateIcon(InputRuleItemIcon, "empty", Color.white); manager.UpdateLabel(StatusLabel, "LOW POWER", Color.red); } if (controller.HasPower() && !controller.IsOperating()) { manager.UpdateLabel(StorageSizeLabel, string.Empty, Color.white); manager.UpdateLabel(InputStatusLabel, string.Empty, Color.white); manager.UpdateLabel(OutputStatusLabel, string.Empty, Color.white); manager.UpdateIcon(InputRuleItemIcon, "empty", Color.white); manager.UpdateLabel(StatusLabel, "ERROR - ANOTHER CONTROLLER DETECTED", Color.red); } for (int i = 0; i < controller.GetItemInputRules().Count; i++) { if (!controller.IsOperating()) { manager.UpdateIcon(InputRuleItemIcon + i, "empty", Color.white); manager.UpdateLabel(InputRuleItemLabel + i, string.Empty, Color.white); } else { var itemIcon = ItemManager.GetItemIcon(controller.GetItemInputRules()[i].Item); var limit = controller.GetItemInputRules()[i].MaxInput; manager.UpdateIcon(InputRuleItemIcon + i, itemIcon, Color.white); manager.UpdateLabel(InputRuleItemLabel + i, "" + limit, Color.white); } } Dirty = false; }
private void WindowUpdate(QuantumStorageControllerMachine quantumStorageController) { if (UpdateWindowCooldown > 0) { --UpdateWindowCooldown; return; } else { UpdateWindowCooldown = UpdateTreshold; } var items = quantumStorageController.GetItems(); if (quantumStorageController.HasPower()) { manager.UpdateLabel(StorageSizeLabel, quantumStorageController.GetItems().GetItemCount() + "/" + quantumStorageController.GetMaxCapacity(), Color.white); manager.UpdateLabel(StatusLabel, "POWER OK", Color.white); } if (!quantumStorageController.HasPower()) { manager.UpdateLabel(StorageSizeLabel, string.Empty, Color.white); manager.UpdateLabel(StatusLabel, "LOW POWER", Color.red); } if (!quantumStorageController.IsOperating()) { manager.UpdateLabel(StorageSizeLabel, string.Empty, Color.white); manager.UpdateLabel(StatusLabel, "ERROR - ANOTHER CONTROLLER DETECTED", Color.red); } for (var index = 0; index < items.Count; index++) { if (!quantumStorageController.IsOperating()) { manager.UpdateIcon("iconItem" + index, "empty", Color.white); manager.UpdateLabel("labelItem" + index, string.Empty, Color.white); manager.UpdateIcon("iconItem" + items.Count, "empty", Color.white); manager.UpdateLabel("labelItem" + items.Count, string.Empty, Color.white); continue; } manager.UpdateIcon("iconItem" + items.Count, "empty", Color.white); var itemBase = items[index]; if (itemBase != null) { var itemIcon = ItemManager.GetItemIcon(itemBase); var currentStackSize = ItemManager.GetCurrentStackSize(itemBase); var label = currentStackSize != 100 ? (currentStackSize >= 10 ? " " + currentStackSize : " " + currentStackSize) : currentStackSize.ToString(); manager.UpdateIcon("iconItem" + index, itemIcon, Color.white); manager.UpdateLabel("labelItem" + index, label, Color.white); } } }