public void SetCombinationSlotState(CombinationSlotState state) { state = LocalLayer.Instance.Modify(state); CombinationSlotStates[state.address] = state; CombinationSlotStateSubject.OnNext(state); }
private static void UnlockCombinationSlot(Address slotAddress, long blockIndex) { var slotState = States.Instance.CombinationSlotStates[slotAddress]; var modifier = new CombinationSlotBlockIndexModifier(blockIndex); LocalLayer.Instance.Set(slotState.address, modifier); States.Instance.CombinationSlotStates[slotAddress] = modifier.Modify(slotState); CombinationSlotStateSubject.OnNext(slotState); }
public static void ModifyCombinationSlotItemEnhancement( Guid baseMaterialGuid, Guid otherMaterialGuid, Address slotAddress ) { // When the layer is covered, additionally set the block height to prevent state updates until the actual state comes in. var blockIndex = Game.Game.instance.Agent.BlockIndex + 100; var requiredBlockIndex = blockIndex + 1; var avatarAddress = States.Instance.CurrentAvatarState.address; var avatarState = new AvatarState( (Bencodex.Types.Dictionary)Game.Game.instance.Agent.GetState(avatarAddress)); if (!avatarState.inventory.TryGetNonFungibleItem(baseMaterialGuid, out ItemUsable item)) { return; } if (!(item is Equipment equipment)) { return; } equipment.LevelUp(); equipment.Update(requiredBlockIndex); var enhancementRow = Game.Game.instance.TableSheets .EnhancementCostSheet.Values .FirstOrDefault(x => x.Grade == equipment.Grade && x.Level == equipment.level); var result = new ItemEnhancement.ResultModel { // id: When applying the local layer for the first time, if the id is the default, the notification is not applied. id = Guid.NewGuid(), actionPoint = 0, gold = enhancementRow.Cost, materialItemIdList = new[] { otherMaterialGuid }, itemUsable = equipment, }; var modifier = new CombinationSlotBlockIndexAndResultModifier(result, blockIndex, requiredBlockIndex); var slotState = States.Instance.CombinationSlotStates[slotAddress]; LocalLayer.Instance.Set(slotState.address, modifier); States.Instance.CombinationSlotStates[slotAddress] = modifier.Modify(slotState); CombinationSlotStateSubject.OnNext(slotState); }
public static void ModifyCombinationSlotEquipment( TableSheets tableSheets, EquipmentItemRecipeSheet.Row row, CombinationPanel panel, Address slotAddress, int?subRecipeId ) { // When the layer is covered, additionally set the block height to prevent state updates until the actual state comes in. var blockIndex = Game.Game.instance.Agent.BlockIndex + 100; var requiredBlockIndex = row.RequiredBlockIndex + blockIndex; if (subRecipeId.HasValue) { var subRow = tableSheets.EquipmentItemSubRecipeSheet.Values.First(r => r.Id == subRecipeId); requiredBlockIndex += subRow.RequiredBlockIndex; } var equipRow = tableSheets.EquipmentItemSheet.Values.First(i => i.Id == row.ResultEquipmentId); var equipment = ItemFactory.CreateItemUsable(equipRow, Guid.Empty, requiredBlockIndex); var materials = new Dictionary <Material, int>(); foreach (var(material, count) in panel.materialPanel.MaterialList) { materials[material] = count; } var result = new CombinationConsumable.ResultModel { // id: When applying the local layer for the first time, if the id is the default, the notification is not applied. id = Guid.NewGuid(), actionPoint = panel.CostAP, gold = panel.CostNCG, materials = materials, itemUsable = equipment, recipeId = row.Id, subRecipeId = subRecipeId, itemType = ItemType.Equipment, }; var modifier = new CombinationSlotBlockIndexAndResultModifier(result, blockIndex, requiredBlockIndex); var slotState = States.Instance.CombinationSlotStates[slotAddress]; LocalLayer.Instance.Set(slotState.address, modifier); States.Instance.CombinationSlotStates[slotAddress] = modifier.Modify(slotState); CombinationSlotStateSubject.OnNext(slotState); }
public static void ModifyCombinationSlotConsumable( TableSheets tableSheets, ICombinationPanel panel, ConsumableItemRecipeSheet.Row recipeRow, Address slotAddress ) { // When the layer is covered, additionally set the block height to prevent state updates until the actual state comes in. var blockIndex = Game.Game.instance.Agent.BlockIndex + 100; var requiredBlockIndex = blockIndex + recipeRow.RequiredBlockIndex; var consumableRow = tableSheets.ConsumableItemSheet.Values.First(i => i.Id == recipeRow.ResultConsumableItemId); var consumable = ItemFactory.CreateItemUsable( consumableRow, Guid.Empty, requiredBlockIndex); var materials = new Dictionary <Material, int>(); foreach (var materialInfo in recipeRow.Materials) { var materialRow = tableSheets.MaterialItemSheet.Values.First(r => r.Id == materialInfo.Id); var material = ItemFactory.CreateMaterial(materialRow); materials[material] = materialInfo.Count; } var result = new CombinationConsumable.ResultModel { actionPoint = panel.CostAP, gold = panel.CostNCG, materials = materials, itemUsable = consumable, recipeId = recipeRow.Id, itemType = ItemType.Consumable, }; var modifier = new CombinationSlotBlockIndexAndResultModifier(result, blockIndex, requiredBlockIndex); var slotState = States.Instance.CombinationSlotStates[slotAddress]; LocalLayer.Instance.Set(slotState.address, modifier); States.Instance.CombinationSlotStates[slotAddress] = modifier.Modify(slotState); CombinationSlotStateSubject.OnNext(slotState); }