//----------------------------------------------------------------------------- // Description //----------------------------------------------------------------------------- public void ResetDescription() { ISlotItem item = currentSlotGroup.CurrentSlot.SlotItem; description = FormatCodes.FormatString(item != null ? item.Name : ""); textPosition = 0; textTimer = 0; textStart = 0; if (!description.IsEmpty) { if (description.Length % 2 == 1) { description.Add(' '); } if (description.Length == 16) { description.Add(' '); textStart = 0; } else { for (int i = (8 - description.Length / 2); i > 0; i--) { description.Add(' '); } textStart = (16 - description.Length) * 8; } description.AddRange(FormatCodes.FormatString(item.Description)); } }
//----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- public Slot(SlotGroup group, Point2I position, int width) { this.group = group; this.position = position; this.width = width; this.connections = new ISlotConnection[4]; this.item = null; this.disabled = false; }
/// <summary> /// Ставим предмет в слот /// </summary> public bool TrySetItemToSlot(ISlotItem slotItem) { for (int i = 0; i < _slots.Length; i++) { if (_slots[i].TryPutItem(slotItem)) { return(true); } } return(false); }
//----------------------------------------------------------------------------- // Slots //----------------------------------------------------------------------------- public Slot GetSlotWithItem(ISlotItem item) { for (int i = 0; i < slotGroups.Count; i++) { for (int j = 0; j < slotGroups[i].NumSlots; j++) { if (slotGroups[i].GetSlotAt(j).SlotItem == item) { return(slotGroups[i].GetSlotAt(j)); } } } return(null); }
//----------------------------------------------------------------------------- // Items //----------------------------------------------------------------------------- // Sets the item for the slot. public void SetItem(ISlotItem item) { this.item = item; }
public virtual bool AllowedFor(ISlotItem context) => !AllowedCondition.Exists(c => !c.Matches(context));
public virtual bool AllowedFor(ISlotItem context) { Ensure.Any.IsNotNull(context, nameof(context)); return(_allowedFor == null || _allowedFor.Matches(context)); }
//----------------------------------------------------------------------------- // Slots //----------------------------------------------------------------------------- public Slot GetSlotWithItem(ISlotItem item) { for (int i = 0; i < slotGroups.Count; i++) { for (int j = 0; j < slotGroups[i].NumSlots; j++) { if (slotGroups[i].GetSlotAt(j).SlotItem == item) { return slotGroups[i].GetSlotAt(j); } } } return null; }