private void RegisterInventoryStructureInDatabase(DataInventoryStructure inventoryStructure) { foreach (var dataSlot in inventoryStructure.Slots) { _databaseCommands.RegisterSlot(dataSlot); } }
public void RegisterInventoryInDatabase(DataInventoryStructure inventoryStructure, InventoryComponent inventoryComponent) { RegisterInventoryStructureInDatabase(inventoryStructure); inventoryComponent.SetInventoryStructure(inventoryStructure); BindSlotsComponentsToData(inventoryComponent); }
private bool IsValidStructureForThisInventory(DataInventoryStructure inventoryStructure) { var inventoryStructureSource = GetInventoryStructure(); if (!inventoryStructureSource.DataInventory.Equals(inventoryStructure.DataInventory) || inventoryStructureSource.Slots.Count != inventoryStructure.Slots.Count) { return(false); } var sourceCoords = GetCoords(inventoryStructureSource); var targetCoords = GetCoords(inventoryStructure); return(SameSlotsType(inventoryStructureSource, inventoryStructure) && new HashSet <Vector2Int>(sourceCoords).SetEquals(targetCoords)); IEnumerable <Vector2Int> GetCoords(DataInventoryStructure structure) => structure.Slots.Select(slot => slot.Vector2Int); bool SameSlotsType(DataInventoryStructure first, DataInventoryStructure second) => first.Slots.First().GetType() == second.Slots.First().GetType(); }
public NoInitState(InventoryBinding inventoryDataBind, DataInventoryStructure inventoryStructure, IEnumerable <DataEntity> dataEntitiesForLoad = null) : base(inventoryDataBind) { _inventoryStructure = inventoryStructure; _dataEntitiesForLoad = dataEntitiesForLoad; }
private void CheckValidStructure(DataInventoryStructure inventoryStructure) => Contract.Assert(IsValidStructureForThisInventory(inventoryStructure));
public void SetInventoryStructure(DataInventoryStructure inventoryStructure) { CheckValidStructure(inventoryStructure); SetDataSlots(inventoryStructure.Slots); SetDataInventory(inventoryStructure.DataInventory); }