/// <summary> /// Called when we want to store a device in the hacking panel. /// </summary> /// <param name="hackDevice"></param> public virtual void ServerStoreHackingDevice(HackingDevice hackDevice) { Pickupable item = hackDevice.GetComponent <Pickupable>(); if (item.ItemSlot != null) { Inventory.ServerPerform(InventoryMove.Transfer(item.ItemSlot, itemStorage.GetBestSlotFor(item))); } else { Inventory.ServerPerform(InventoryMove.Add(item, itemStorage.GetBestSlotFor(item))); } }
private void AfterMovement(Vector3Int newLocalPosition) { var tileObjects = MatrixManager.GetAt <ObjectBehaviour>(registerTile.WorldPosition, true); foreach (var objectBehaviour in tileObjects) { var item = objectBehaviour.gameObject; if (Validations.HasItemTrait(item, CommonTraits.Instance.OreGeneral)) { var oreBoxSlot = oreBoxItemStorage.GetBestSlotFor(item); Inventory.ServerAdd(item, oreBoxSlot); } } }
public void ServerPerformInteraction(HandApply interaction) { var grownFood = interaction.HandObject?.GetComponent <GrownFood>(); if (grownFood != null) { var foodAtributes = grownFood.GetComponentInParent <ItemAttributesV2>(); if (!Inventory.ServerTransfer(interaction.HandSlot, storage.GetBestSlotFor(interaction.HandObject))) { Chat.AddActionMsgToChat(interaction.Performer, $"You try and place the {foodAtributes.ArticleName} into the seed extractor but it is full!", $"{interaction.Performer.name} tries to place the {foodAtributes.ArticleName} into the seed extractor but it is full!"); return; } Chat.AddActionMsgToChat(interaction.Performer, $"You place the {foodAtributes.ArticleName} into the seed extractor", $"{interaction.Performer.name} places the {foodAtributes.name} into the seed extractor"); if (foodToBeProcessed.Count == 0 && currentState != PowerStates.Off) { Chat.AddLocalMsgToChat("The seed extractor begins processing", (Vector2Int)registerObject.WorldPosition, this.gameObject); } foodToBeProcessed.Enqueue(grownFood); return; } //If no interaction happens networkTab.ServerPerformInteraction(interaction); }
private void TileReachedServer(Vector3Int worldPos) { var crossedItems = MatrixManager.GetAt <Pickupable>(worldPos, true); foreach (var item in crossedItems) { Inventory.ServerAdd(item, storage.GetBestSlotFor(item)); } }
/// <summary> /// Checks if the player can currently put the indicated item into a free slot in this storage. Correctly handles logic for client / server side, so is /// recommended to use in WillInteract rather than other ways of checking fit. /// </summary> /// <param name="player">player to check</param> /// <param name="storage">storage to check</param> /// <param name="toCheck">item to check for fit</param> /// <param name="side">network side check is happening on</param> /// <param name="ignoreOccupied">if true, does not check if an item is already in the slot</param> /// <param name="examineRecipient">if not null, when validation fails, will output an appropriate examine message to this recipient</param> /// <returns></returns> public static bool CanPutItemToStorage(PlayerScript playerScript, ItemStorage storage, Pickupable toCheck, NetworkSide side, bool ignoreOccupied = false, GameObject examineRecipient = null) { var freeSlot = storage.GetBestSlotFor(toCheck); if (freeSlot == null) { return(false); } return(CanPutItemToSlot(playerScript, freeSlot, toCheck, side, ignoreOccupied, examineRecipient)); }
private void AttemptToStore(GameObject thing) { Pickupable pickup = thing.GetComponent <Pickupable>(); if (pickup != null) { if (storage.GetBestSlotFor(pickup) != null) { if (storage.ItemStorageCapacity.CanFit(pickup, storage.GetBestSlotFor(pickup).SlotIdentifier)) { Inventory.ServerAdd(pickup, storage.GetBestSlotFor(pickup), ReplacementStrategy.DropOther); } } var stack = pickup.GetComponent <Stackable>(); if (stack != null && stack.Amount > 0) { if (storage.GetBestSlotFor(pickup) != null) { if (storage.ItemStorageCapacity.CanFit(pickup, storage.GetBestSlotFor(pickup).SlotIdentifier)) { Inventory.ServerAdd(pickup, storage.GetBestSlotFor(pickup), ReplacementStrategy.DropOther); } } } } }
public void ServerPerformInteraction(InventoryApply interaction) { if (allowedToInteract == false) { return; } Inventory.ServerTransfer(interaction.FromSlot, itemStorage.GetBestSlotFor((interaction).UsedObject)); }
public void ServerPerformInteraction(InventoryApply interaction) { if (allowedToInteract == false) { return; } Inventory.ServerTransfer(interaction.FromSlot, itemStorage.GetBestSlotFor((interaction).UsedObject)); if (interaction.UsedObject.Item().InventoryMoveSound != null) { _ = SoundManager.PlayNetworkedAtPosAsync(interaction.UsedObject.Item().InventoryMoveSound, interaction.Performer.AssumedWorldPosServer()); } }
public void ServerPerformInteraction(InventoryApply interaction) { Inventory.ServerTransfer(interaction.FromSlot, itemStorage.GetBestSlotFor(((Interaction)interaction).UsedObject)); }