NodeCanvas Forums › Support › CoreGamekit Integration Namespace Errors › Reply To: CoreGamekit Integration Namespace Errors
Great!
I actually was rewriting a different 3rd party integration for InventoryPro over to NodeCanvas the day before you posted this, but all of your scripts replaced mine anyhow!
There was one that I didn’t see in your actions, which was for looting a treasure chest, to transfer all items to an inventory. The quick code changes I did to put it in NodeCanvas are as follows (near direct port from their integration):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[Category("InventoryPro")] [Description("Adds all of the items from a treasure chest.")] [Icon("InventoryPro", true)] public class AddItemsFromTreasureChest : ActionTask<TreasureChest> { protected override string info { get { return "Add items from a treasure chest to inventory"; } } protected override void OnExecute() { for (int i = agent.items.Length - 1; i > -1; --i) { InventoryManager.AddItem(agent.items<em class="d4pbbc-italic"></em>); agent.items<em class="d4pbbc-italic"></em> = null; } EndAction(); } } |
But I think the following is more along the lines of how you wrote the other tasks:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
[Category("InventoryPro")] [Description("Adds all of the items from a treasure chest to a collection. Uses the default collection if none set.")] [Icon("InventoryPro", true)] public class MoveTreasureChestItemsToCollection : ActionTask { [RequiredField] public BBParameter<TreasureChest> chest; public BBParameter<ItemCollectionBase> collection; protected override string info { get { var str = string.Format("Add items from {0} to ", chest); if (collection.value != null) str += collection; else str += "default collection"; return str; } } protected override void OnExecute() { for (int i = chest.value.items.Length - 1; i > -1; --i) { if (collection.value != null) collection.value.AddItem(chest.value.items<em class="d4pbbc-italic"></em>); else InventoryManager.AddItem(chest.value.items<em class="d4pbbc-italic"></em>); chest.value.items<em class="d4pbbc-italic"></em> = null; } EndAction(); } } |
(The integration I looked at simply pointed at InventoryManager.AddItem, but I think having the option for a specific inventory built in is useful too)
P.S. Your tasks are generally better written than mine, so rewrite it how you see fit, if you want to add this task!