private void InitEquipment(IPerson person) { var equipmentModule = person.GetModuleSafe <IEquipmentModule>(); if (equipmentModule is null) { throw new InvalidOperationException( "Active person must be able to use equipment to shown in this dialog."); } var currentEquipmentItemList = new List <EquipmentUiItem>(); foreach (var equipment in equipmentModule) { if (equipment is null) { continue; } var lastIndex = currentEquipmentItemList.Count; var relativeX = lastIndex * (EQUIPMENT_ITEM_SIZE + EQUIPMENT_ITEM_SPACING); var buttonRect = new Rectangle( relativeX + ContentRect.Left, ContentRect.Top, EQUIPMENT_ITEM_SIZE, EQUIPMENT_ITEM_SIZE); var sid = equipment.Scheme.Sid; if (string.IsNullOrEmpty(sid)) { Debug.Fail("All equipment must have symbolic identifier (SID)."); sid = "EmptyPropIcon"; } var equipmentButton = new EquipmentButton( _uiContentStorage.GetButtonTexture(), _uiContentStorage.GetPropIconLayers(sid), buttonRect, new Rectangle(0, 0, EQUIPMENT_ITEM_SIZE, EQUIPMENT_ITEM_SIZE)); var uiItem = new EquipmentUiItem(equipmentButton, equipment, lastIndex, buttonRect); currentEquipmentItemList.Add(uiItem); } _currentEquipmentItems = currentEquipmentItemList.ToArray(); }
private void InitEquipment(IPerson person, Rectangle rect) { var equipmentModule = person.GetModuleSafe <IEquipmentModule>(); if (equipmentModule is null) { throw new InvalidOperationException( "Active person must be able to use equipment to shown in this dialog."); } var currentEquipmentItemList = new List <EquipmentUiItem>(); var equipmentSlotList = equipmentModule.Slots.ToArray(); for (var itemIndex = 0; itemIndex < equipmentSlotList.Length; itemIndex++) { var slot = equipmentSlotList[itemIndex]; var sid = string.Empty; Equipment equipment = null; if (equipmentModule[itemIndex] is not null) { equipment = equipmentModule[itemIndex]; sid = equipment.Scheme.Sid; if (string.IsNullOrEmpty(sid)) { Debug.Fail("All equipment must have symbolic identifier (SID)."); sid = "EmptyPropIcon"; } } else { switch (slot.Types) { case EquipmentSlotTypes.Head: sid = "HeadSlot"; break; case EquipmentSlotTypes.Body: sid = "BodySlot"; break; case EquipmentSlotTypes.Hand: if (slot.IsMain) { sid = "RightHandSlot"; } else { sid = "LeftHandSlot"; } break; case EquipmentSlotTypes.Aux: sid = "AuxSlot"; break; } } var relativeY = itemIndex * (EQUIPMENT_ITEM_SIZE + EQUIPMENT_ITEM_SPACING); var buttonRect = new Rectangle( rect.Left, rect.Top + relativeY, EQUIPMENT_ITEM_SIZE, EQUIPMENT_ITEM_SIZE); var equipmentButton = new EquipmentButton( _uiContentStorage.GetButtonTexture(), _uiContentStorage.GetPropIconLayers(sid), buttonRect, new Rectangle(0, 0, EQUIPMENT_ITEM_SIZE, EQUIPMENT_ITEM_SIZE)); var uiItem = new EquipmentUiItem(equipmentButton, equipment, itemIndex, buttonRect); currentEquipmentItemList.Add(uiItem); } _currentEquipmentItems = currentEquipmentItemList.ToArray(); }