3 static const string PORT_MAGAZINE_WELL =
"MagazineWell";
5 [
Attribute(
"0.5", UIWidgets.Slider,
"Fraction of magazines to drop",
"0 1 1" )]
6 protected float m_FractionOfMagazines;
7 [
Attribute(
"", UIWidgets.EditBox,
"Name of magazine well" )]
8 protected string m_sMagazineWellType;
10 private SCR_InventoryStorageManagerComponent m_Inventory;
11 private typename m_oMagazineWell;
14 protected static ref TStringArray s_aVarsIn = {
17 override TStringArray GetVariablesIn()
23 override void OnInit(AIAgent owner)
25 IEntity ent = owner.GetControlledEntity();
28 m_Inventory = SCR_InventoryStorageManagerComponent.Cast(ent.FindComponent(SCR_InventoryStorageManagerComponent));
33 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
36 return ENodeResult.FAIL;
38 if(!GetVariableIn(PORT_MAGAZINE_WELL,m_oMagazineWell))
39 m_oMagazineWell = m_sMagazineWellType.ToType();
41 array<typename> components = {};
42 array<IEntity> foundItems = {};
43 components.Insert(MagazineComponent);
45 for (
int i = m_Inventory.FindItemsWithComponents(foundItems,components,
EStoragePurpose.PURPOSE_DEPOSIT)-1; i> -1; i--)
47 MagazineComponent magComp = MagazineComponent.Cast(foundItems[i].FindComponent(MagazineComponent));
48 if (magComp && magComp.GetMagazineWell().Type() != m_oMagazineWell)
55 for (
int i = 0, length = Math.Floor((foundItems.Count()-1) * m_FractionOfMagazines); i <= length; i++)
59 bool removed = m_Inventory.TryRemoveItemFromStorage(foundItems[i],parentSlot.GetStorage());
61 return ENodeResult.SUCCESS;
65 protected override bool VisibleInPalette()
71 override protected string GetNodeMiddleText()
73 return "Drop " + (m_FractionOfMagazines*100).ToString() +
"% of magazines to ground.";
77 protected override string GetOnHoverDescription()
79 return "AI task that drops all magazines of specified MagazineWell type.";