protected virtual int?GetIndex(IVariableInventoryCell stareCell, IVariableInventoryCellData effectCellData, CellCorner cellCorner) { var index = GetIndex(stareCell); // offset index var(width, height) = GetRotateSize(effectCellData); if (width % 2 == 0) { if ((cellCorner & CellCorner.Left) != CellCorner.None) { index--; } } if (height % 2 == 0) { if ((cellCorner & CellCorner.Top) != CellCorner.None) { index -= StashData.CapacityWidth; } } index -= (width - 1) / 2; index -= (height - 1) / 2 * StashData.CapacityWidth; return(index); }
protected (int, int) GetRotateSize(IVariableInventoryCellData cell) { if (cell == null) { return(1, 1); } return(cell.IsRotate ? cell.Height : cell.Width, cell.IsRotate ? cell.Width : cell.Height); }
public override int?GetInsertableId(IVariableInventoryCellData cellData) { if (cellData is IStandardCaseCellData caseData) { if (caseData.CaseData == this) { return(null); } } return(base.GetInsertableId(cellData)); }
public virtual int?GetInsertableId(IVariableInventoryCellData cellData) { for (var i = 0; i < mask.Length; i++) { if (!mask[i] && CheckInsert(i, cellData)) { return(i); } } return(null); }
public virtual int?GetId(IVariableInventoryCellData cellData) { for (var i = 0; i < CellData.Length; i++) { if (CellData[i] == cellData) { return(i); } } return(null); }
public virtual void OnDroped(bool isDroped) { conditionTransform.gameObject.SetActive(false); condition.color = defaultColor; if (!isDroped && originalId.HasValue) { // revert itemViews[originalId.Value].Apply(originalCellData); StashData.InsertInventoryItem(originalId.Value, originalCellData); } originalId = null; originalCellData = null; }
public virtual bool OnDrop(IVariableInventoryCell stareCell, IVariableInventoryCell effectCell) { if (!itemViews.Any(item => item == stareCell)) { return(false); } // check target; var index = GetIndex(stareCell, effectCell.CellData, cellCorner); if (!index.HasValue) { return(false); } if (!StashData.CheckInsert(index.Value, effectCell.CellData)) { // check free space in case if (stareCell.CellData != null && stareCell.CellData is VariableInventorySystem.IStandardCaseCellData caseData) { var id = caseData.CaseData.GetInsertableId(effectCell.CellData); if (id.HasValue) { caseData.CaseData.InsertInventoryItem(id.Value, effectCell.CellData); originalId = null; originalCellData = null; return(true); } } return(false); } // place StashData.InsertInventoryItem(index.Value, effectCell.CellData); itemViews[index.Value].Apply(effectCell.CellData); originalId = null; originalCellData = null; return(true); }
public virtual bool OnPick(IVariableInventoryCell stareCell) { if (stareCell?.CellData == null) { return(false); } var id = StashData.GetId(stareCell.CellData); if (id.HasValue) { originalId = id; originalCellData = stareCell.CellData; itemViews[id.Value].Apply(null); StashData.InsertInventoryItem(id.Value, null); return(true); } return(false); }
public void Apply(IVariableInventoryCellData cellData) { CellData = cellData; OnApply(); }