/// <summary> Try to switch to the given inventory item. </summary> /// <param name="inventoryId"> The inventory item to switch to. </param> public void TrySwitchTo(int inventoryId) { if (!weaponSwapRate.CanTrigger) { return; } _display.SelectedSlot = inventoryId; if (!_inventoryList.SetSelectedIndex(inventoryId)) { return; } _currentItem.MarkDone(); _currentItem = _inventoryList.Selected.CreateInstance(_world, this); weaponSwapRate.Restart(); }
public void Start() { // TODO get the world through some other means (do we really need to?) _world = WorldScript.World; _inventory = new PlayerInventory(); _bank = new MoneyBank { AmountChanged = new Notifee(this, NotificationIds.Money) }; _cursor = GetComponentInChildren <CursorBehavior>().PlayerCursor; AttachmentPoints = AttachmentPointsBehavior.RetrieveFor(Owner); _inventoryList = new DataCollection <IInventoryItemBlueprint>( Enumerable.Concat <IInventoryItemBlueprint>(weaponList, inventoryList).ToArray() ); _currentItem = _inventoryList.Selected.CreateInstance(WorldScript.World, this); SetupDisplay(); }