3 static const string PORT_MAGAZINE_WELL =
"MagazineWell";
5 [
Attribute(
"", UIWidgets.EditBox,
"Name of magazine well" )]
6 protected string m_sMagazineWellType;
8 private IEntity m_OwnerEntity;
9 private SCR_InventoryStorageManagerComponent m_Inventory;
10 private typename m_oMagazineWell;
12 protected static ref TStringArray s_aVarsIn = {
15 override TStringArray GetVariablesIn()
20 override void OnInit(AIAgent owner)
24 Debug.Error(
"Owner must be a character!");
25 m_Inventory = SCR_InventoryStorageManagerComponent.Cast(
m_OwnerEntity.FindComponent(SCR_InventoryStorageManagerComponent));
28 override ENodeResult EOnTaskSimulate(AIAgent owner,
float dt)
33 if (!GetVariableIn(PORT_MAGAZINE_WELL,m_oMagazineWell))
34 m_oMagazineWell = m_sMagazineWellType.ToType();
36 CharacterVicinityComponent vicinity = CharacterVicinityComponent.Cast(
m_OwnerEntity.FindComponent(CharacterVicinityComponent));
39 array<IEntity> items = {};
40 vicinity.GetAvailableItems(items);
42 foreach (IEntity item : items)
44 MagazineComponent magComp = MagazineComponent.Cast(item.FindComponent(MagazineComponent));
47 if (magComp.GetMagazineWell().Type() == m_oMagazineWell && !m_Inventory.TryInsertItem(item,
EStoragePurpose.PURPOSE_DEPOSIT))
49 CharacterControllerComponent charCtrlComp = CharacterControllerComponent.Cast(ChimeraCharacter.Cast(
m_OwnerEntity).GetCharacterController());
50 charCtrlComp.ReloadWeaponWith(item);
54 if (items.Count() == 0)
56 PrintFormat(
"No items found to pick up by %1!",
m_OwnerEntity);
57 return ENodeResult.FAIL;
60 return ENodeResult.SUCCESS;
62 return ENodeResult.FAIL;
65 protected override bool VisibleInPalette()
70 protected override string GetOnHoverDescription()
72 return "AI task that picks up all magazines of provided MagazineWell type in the vicinity of its inventory.";