private void OnButtonClick(int cellPos) { var skillContext = new SkillContext(_player, 0, null); if (!_useThingSkill.ReadyToUse(skillContext)) { return; } var bagCell = _bag.Cells.Skip(cellPos).FirstOrDefault(); if (bagCell != null) { var thing = bagCell.Item; if (thing is IStack stack) { thing = stack.Prototype.CreateInstance(); } _lastClickedCell = bagCell; _useThingSkill.OnEndCast += OnUseThingEndCast; _useThingSkill.Thing = thing; _player.Use(_useThingSkill, skillContext); } }
private void CellOnStackCountChange(IBagCell cell) { if (cell.Item is IStack stack) { if (stack.Count == 0) { _cells.Remove(cell); cell.OnStackCountChange -= CellOnStackCountChange; OnCellRemoved?.Invoke(this, cell); } } }
private void TuneButton(Button button, IBagCell bagCell) { var text = button.GetComponentInChildren <Text>(); text.text = bagCell != null ? bagCell.Name : string.Empty; }
private void Bag_OnCellAddOrRemove(IBag bag, IBagCell cell) { Init(); }