5 protected vector m_vFlagOffset;
8 IEntity FindFlagInInventory(IEntity user)
14 array<typename> components = {};
15 components.Insert(SCR_MineFlagComponent);
16 return storageManager.FindItemWithComponents(components,
EStoragePurpose.PURPOSE_ANY);
20 void PlaceFlag(IEntity user, IEntity owner)
22 RplComponent userRplComponent = RplComponent.Cast(user.FindComponent(RplComponent));
23 if (!userRplComponent)
30 SCR_CharacterInventoryStorageComponent storage = SCR_CharacterInventoryStorageComponent.Cast(user.FindComponent(SCR_CharacterInventoryStorageComponent));
34 IEntity flag = FindFlagInInventory(user);
39 SCR_PlaceableInventoryItemComponent itemComponent = SCR_PlaceableInventoryItemComponent.Cast(flag.FindComponent(SCR_PlaceableInventoryItemComponent));
41 RplComponent rplComponent = RplComponent.Cast(flag.FindComponent(RplComponent));
42 if (rplComponent && !rplComponent.IsProxy())
45 owner.GetTransform(mat);
46 itemComponent.PlaceItem(mat[0], mat[1], mat[2], mat[3] + m_vFlagOffset);
50 if (soundManagerEntity)
51 soundManagerEntity.CreateAndPlayAudioSource(flag,
"SOUND_MINEFLAG_PLACE");
53 if (userRplComponent.IsOwner())
54 storageManager.TryRemoveItemFromStorage(flag, itemComponent.GetParentSlot().GetStorage());
56 SCR_MineWeaponComponent mine = SCR_MineWeaponComponent.Cast(owner.FindComponent(SCR_MineWeaponComponent));
62 override event void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
64 PlaceFlag(pUserEntity, pOwnerEntity);
68 override bool CanBeShownScript(IEntity user)
70 SCR_MineWeaponComponent mine = SCR_MineWeaponComponent.Cast(
GetOwner().FindComponent(SCR_MineWeaponComponent));
71 if (!mine || mine.IsFlagged())
74 SCR_PressureTriggerComponent mineTriggerComponent = SCR_PressureTriggerComponent.Cast(
GetOwner().FindComponent(SCR_PressureTriggerComponent));
75 if (!mineTriggerComponent || !mineTriggerComponent.IsActivated())
79 if (!mineAwarenessComponent)
80 return super.CanBeShownScript(user);
82 if (!mineAwarenessComponent.IsDetected(
GetOwner()) || !FindFlagInInventory(user))
85 return super.CanBeShownScript(user);