void OnInventoryUpdated(InventoryUpdateEvent update) { if (update.Type != InventoryUpdateEvent.UpdateType.Added) { return; } if (inventory == null) { return; } if (actor == null) { return; } if (AreAllRequiredItemsAvailable()) { GameObject newObj = Instantiate(blueprintPrefab) as GameObject; GridActor newActor = newObj.GetComponent <GridActor>(); if (actor) { newActor.Move(actor.Position); } GameObject.Destroy(gameObject); } }
void OnInventoryUpdate(InventoryUpdateEvent update) { if (update.Type != InventoryUpdateEvent.UpdateType.Added) { return; } // Need to add a more thorough check on what we added here if (actor) { GridMap.Instance.SetBlock(actor.Position, GetBlock()); } data.requestFinished = true; GameObject.Destroy(gameObject); }
public async Task RemoveSuccess() { using var mocker = AutoMock.GetStrict(); await using var handler = mocker.Create <InventoryUpdateEventHandler>(); var stateData = new SkuState { Inventory = 789 }; var inventoryUpdateEvent = new InventoryUpdateEvent { NewInventory = 666, Diff = -66 }; await handler.HandleEvent(stateData, inventoryUpdateEvent, default); stateData.Inventory.Should().Be(inventoryUpdateEvent.NewInventory); }