2class SCR_GadgetInvokersInitState
7 bool m_bIsControlledInit =
false;
8 bool m_bIsDefaultInit =
false;
9 bool m_bIsControlledEnt =
false;
15 if (m_bIsControlledEnt)
16 return m_bIsDefaultInit && m_bIsControlledInit;
18 return m_bIsDefaultInit;
30 m_Controller = controller;
32 SCR_InventoryStorageManagerComponent invManager = SCR_InventoryStorageManagerComponent.Cast(m_Controller.GetInventoryStorageManager());
35 m_Controller.m_OnGadgetStateChangedInvoker.Insert(m_GadgetManager.OnGadgetStateChanged);
36 m_Controller.m_OnControlledByPlayer.Insert(m_GadgetManager.OnControlledByPlayer);
37 invManager.m_OnItemAddedInvoker.Insert(m_GadgetManager.OnItemAdded);
38 invManager.m_OnItemRemovedInvoker.Insert(m_GadgetManager.OnItemRemoved);
40 m_bIsDefaultInit =
true;
50 if (m_bIsControlledInit)
53 m_Controller = controller;
55 m_Controller.m_OnGadgetFocusStateChangedInvoker.Insert(m_GadgetManager.OnGadgetFocusStateChanged);
59 editorManager.GetOnOpened().Insert(m_GadgetManager.OnEditorOpened);
61 m_bIsControlledEnt =
true;
62 m_bIsControlledInit =
true;
72 m_Controller.m_OnGadgetStateChangedInvoker.Remove(m_GadgetManager.OnGadgetStateChanged);
73 m_Controller.m_OnControlledByPlayer.Remove(m_GadgetManager.OnControlledByPlayer);
76 SCR_InventoryStorageManagerComponent invManager = SCR_InventoryStorageManagerComponent.Cast(character.
FindComponent(SCR_InventoryStorageManagerComponent));
79 invManager.m_OnItemAddedInvoker.Remove(m_GadgetManager.OnItemAdded);
80 invManager.m_OnItemRemovedInvoker.Remove(m_GadgetManager.OnItemRemoved);
83 m_bIsDefaultInit =
false;
93 m_Controller.GetOnPlayerDeathWithParam().Remove(m_GadgetManager.OnPlayerDeath);
94 m_Controller.m_OnGadgetFocusStateChangedInvoker.Remove(m_GadgetManager.OnGadgetFocusStateChanged);
99 editorManager.GetOnOpened().Remove(m_GadgetManager.OnEditorOpened);
101 m_bIsControlledInit =
false;
102 m_bIsControlledEnt =
false;
113 CleanupLocalInvokers(entity);
114 CleanupInvokers(entity);
122 m_GadgetManager = gadgetManager;
130 static override bool DependsOn(
string className)
132 if (className ==
"SCR_CharacterInventoryStorageComponent")
141 int m_iRadiosFlags = EGadgetType.RADIO | EGadgetType.RADIO_BACKPACK;
185 return gadgetManager;
240 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(gadget.
FindComponent(SCR_GadgetComponent));
244 if (targetMode == EGadgetMode.IN_HAND && !gadgetComp.CanBeHeld())
251 if (targetMode == EGadgetMode.IN_HAND || gadgetComp.GetMode() == EGadgetMode.IN_HAND || gadgetComp ==
m_HiddenGadgetComponent)
256 if (targetMode == EGadgetMode.IN_HAND)
260 if (gadgetComp.CanBeRaised())
261 m_Controller.TakeGadgetInLeftHand(gadget, gadgetComp.GetAnimVariable(), doFocus);
263 m_Controller.TakeGadgetInLeftHand(gadget, gadgetComp.GetAnimVariable());
267 if (targetMode == EGadgetMode.ON_GROUND)
272 if (gadgetComp.GetType() == EGadgetType.MAP)
275 if (gadgetComp.m_bFocused)
276 gadgetComp.ToggleFocused(
false);
280 gadgetComp.OnModeChanged(targetMode,
GetOwner());
289 if (targetMode != EGadgetMode.ON_GROUND && targetMode != EGadgetMode.IN_STORAGE)
292 gadgetComp.OnModeChanged(targetMode, null);
333 if (gadgetArrayID != -1)
335 array<SCR_GadgetComponent> arr = {};
351 if (!gadgets || gadgets.IsEmpty())
354 foreach (SCR_GadgetComponent comp : gadgets)
357 return comp.GetOwner();
359 Print(
GetOwner().
ToString() +
" SCR_GadgetManager::GetGadgetsByType returned null entry in an array of " +
typename.EnumToString(EGadgetType,
type) +
" gadgets",
LogLevel.ERROR);
371 SCR_InventoryStorageManagerComponent storageManager = SCR_InventoryStorageManagerComponent.Cast(
m_Controller.GetInventoryStorageManager());
376 array<ref SCR_QuickslotBaseContainer> quickSlotsContainers = charStorage.
GetQuickSlotItems();
379 SCR_GadgetComponent gadgetComp;
383 if (!entityContainer || !entityContainer.GetEntity())
386 gadgetComp = SCR_GadgetComponent.Cast(entityContainer.GetEntity().FindComponent(SCR_GadgetComponent));
389 if (gadgetComp.GetType() ==
type)
390 return entityContainer.GetEntity();
404 if (gadgetArrayID != 1)
423 if (targetMode == EGadgetMode.IN_HAND || gadgetComp.GetMode() == EGadgetMode.IN_HAND)
429 CompartmentAccessComponent compAccess = character.GetCompartmentAccessComponent();
430 if (compAccess && compAccess.IsInCompartment())
433 if (!invItemComponent)
440 if (targetMode == EGadgetMode.IN_HAND && !charModifData.CanBeEquippedInVehicle())
470 IEntity hiddenGadget = inputCtx.GetWantedLefHandGadgetEntity();
473 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(hiddenGadget.
FindComponent(SCR_GadgetComponent));
488 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(gadget.
FindComponent(SCR_GadgetComponent));
505 EGadgetMode targetMode = EGadgetMode.IN_HAND;
506 bool doFocus = inputVal != 1;
509 targetMode = EGadgetMode.IN_STORAGE;
511 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(gadget.
FindComponent(SCR_GadgetComponent));
515 if (inputVal != 1 && (gadgetComp.GetUseMask() &
SCR_EUseContext.FROM_ACTION) != 0)
517 gadgetComp.ToggleActive(!gadgetComp.IsToggledOn(),
SCR_EUseContext.FROM_ACTION);
550 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(item.
FindComponent(SCR_GadgetComponent));
558 EGadgetType
type = gadgetComp.GetType();
561 if (gadgetArrayID == -1)
574 else if (
type == EGadgetType.RADIO_BACKPACK)
579 m_OnGadgetAdded.Invoke(gadgetComp);
583 SCR_RadioComponent radioGadget = SCR_RadioComponent.Cast(gadgetComp);
587 BaseRadioComponent radioComp = radioGadget.GetRadioComponent();
592 int count = radioComp.TransceiversCount();
593 for (
int i = 0; i < count; i++)
596 radioEntry.
SetRadioEntry(radioComp.GetTransceiver(i), i + 1, gadgetComp);
608 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(item.
FindComponent(SCR_GadgetComponent));
616 EGadgetType
type = gadgetComp.GetType();
619 if (gadgetArrayID == -1)
626 m_OnGadgetRemoved.Invoke(gadgetComp);
630 array<ref SCR_VONEntry> entries = {};
633 for (
int i = entries.Count() - 1; i >= 0; --i)
636 if (entry && entry.
GetGadget() == gadgetComp)
668 if (
System.IsConsoleApp())
697 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(gadget.
FindComponent(SCR_GadgetComponent));
704 gadgetComp.OnModeChanged(EGadgetMode.IN_HAND,
GetOwner());
712 gadgetComp.OnModeChanged(EGadgetMode.ON_GROUND,
GetOwner());
724 if (storageSlot && storageSlot.GetOwner() == parent)
726 gadgetComp.OnModeChanged(EGadgetMode.IN_SLOT,
GetOwner());
732 gadgetComp.OnModeChanged(EGadgetMode.IN_STORAGE,
GetOwner());
742 SCR_GadgetComponent gadgetComponent;
758 || (!isFocused && gadgetComponent.GetType() == EGadgetType.MAP && gadgetComponent.GetMode() == EGadgetMode.IN_HAND))
761 gadgetComponent.ToggleFocused(isFocused);
810 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(flashlight.
FindComponent(SCR_GadgetComponent));
812 gadgetComp.ActivateAction();
877 CompartmentAccessComponent access = character.GetCompartmentAccessComponent();
878 if (!access || !access.IsInCompartment())
886 if (!turretController)
889 turretController.SetWeaponADSInput(
false);
897 array<IEntity> foundItems = {};
898 array<typename> componentsQuery = {SCR_GadgetComponent};
904 int count = foundItems.Count();
905 for (
int i = 0; i < count; i++)
907 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(foundItems[i].FindComponent(SCR_GadgetComponent));
909 if (gadgetArrayID == -1)
914 if (gadgetComp.GetMode() != EGadgetMode.ON_GROUND)
925 if (storageSlot || gadgetComp.GetType() == EGadgetType.RADIO_BACKPACK)
949 array<SCR_GadgetComponent> radiosArray = {};
953 SCR_RadioComponent radioGadget;
954 BaseRadioComponent radioComp;
955 foreach (SCR_GadgetComponent radio : radiosArray)
957 radioGadget = SCR_RadioComponent.Cast(radio);
961 radioComp = radioGadget.GetRadioComponent();
965 int count = radioComp.TransceiversCount();
966 for (
int i = 0; i < count; ++i)
969 radioEntry.
SetRadioEntry(radioComp.GetTransceiver(i), i + 1, radio);
982 array<SCR_GadgetComponent> radiosArray = {};
986 array<ref SCR_VONEntry> entries = {};
989 foreach (SCR_GadgetComponent radio : radiosArray)
991 for (
int i = entries.Count() - 1; i >= 0; --i)
1051 return EGadgetType.MAP;
1054 return EGadgetType.COMPASS;
1057 return EGadgetType.BINOCULARS;
1060 return EGadgetType.FLASHLIGHT;
1063 return EGadgetType.WRISTWATCH;
1128 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(
Replication.FindItem(
id));
1132 gadgetComp.OnToggleActive(state);
1145 SCR_GadgetComponent gadgetComp = SCR_GadgetComponent.Cast(
Replication.FindItem(
id));
1149 gadgetComp.OnToggleActive(state);
1161 if (!gadgetManagersSystem)
1164 gadgetManagersSystem.
Register(
this);
1172 if (!gadgetManagersSystem)
1183 super.OnDelete(owner);
1186 #ifndef DISABLE_GADGETS
1202 SCR_GadgetComponent gadgetComp;
1210 m_Controller.SetWeaponNoFireTime(gadgetComp.GetWeaponNoFireTime());
1217 if (gadgetComp.IsUsingADSControls())
1220 SCR_ChimeraCharacter character = SCR_ChimeraCharacter.Cast(
GetOwner());
1221 if (character && character.IsDriving(1))
1232 if (gadgetComp.GetType() == EGadgetType.MAP)
1246 typename gadgetTypes = EGadgetType;
1247 int count = gadgetTypes.GetVariableCount();
1248 array<SCR_GadgetComponent> gadgets;
1249 for (
int i = 0; i < count; i++)
ArmaReforgerScripted GetGame()
void SCR_EditorManagerEntity(IEntitySource src, IEntity parent)
void SCR_GadgetInvokersInitState(notnull SCR_GadgetManagerComponent gadgetManager)
class SCR_GadgetInvokersInitState EntityEditorProps(category:"GameScripted/Gadgets", description:"Gadget manager", color:"0 0 255 255")
void SCR_QuickslotEntityContainer(IEntity entity)
CompartmentControllerComponent m_Controller
void Register(SCR_GadgetManagerComponent component)
void Unregister(SCR_GadgetManagerComponent component)
proto external Managed FindComponent(typename typeName)
proto external BaseWorld GetWorld()
proto external IEntity GetParent()
Replication item identifier.
OnPlayerDeathWithParamInvoker GetOnPlayerDeathWithParam()
array< ref SCR_QuickslotBaseContainer > GetQuickSlotItems()
Controls invoker resgistration for gadget manager.
void Update(float timeSlice)
EGadgetType GetGadgetInputAction()
void DisconnectFromGadgetsManagerSystem()
SCR_GadgetComponent m_LastHeldGadgetComponent
void ActionFlashlightToggle(float value, EActionTrigger reason)
static ScriptInvoker GetOnGadgetInitDoneInvoker()
SCR_VONController m_VONController
SCR_GadgetComponent m_HiddenGadgetComponent
void RegisterVONEntries()
Register radio gadgets into the VON system as entries.
SCR_GadgetComponent m_HeldGadgetComponent
void OnActivateHeldGadget()
Activate held gadget.
void OnGadgetADS()
Input action callback.
void OnControlledByPlayer(IEntity owner, bool controlled)
ref SCR_GadgetInvokersInitState m_pInvokersState
void OnItemRemoved(IEntity item, BaseInventoryStorageComponent storageOwner)
static ref ScriptInvoker< IEntity, SCR_GadgetManagerComponent > s_OnGadgetInitDone
void RPC_DoToggleGadget(RplId id, bool state)
void OnPauseMenu()
Input action callback.
void SetGadgetMode(IEntity gadget, EGadgetMode targetMode, bool doFocus=false)
void AskToggleGadget(SCR_GadgetComponent gadgetComp, bool state)
IEntity GetGadgetByType(EGadgetType type)
override void OnPostInit(IEntity owner)
void ConnectToGadgetsManagerSystem()
void UpdateHeldGadget(IEntity gadget)
bool IsGadgetOwned(SCR_GadgetComponent gadgetComp)
void OnGadgetInput(float value, EActionTrigger reason)
void RegisterInitialGadgets(IEntity character)
array< SCR_GadgetComponent > GetGadgetsByType(EGadgetType type)
bool CanChangeGadgetMode(IEntity gadget, SCR_GadgetComponent gadgetComp, EGadgetMode targetMode)
void HandleInput(IEntity gadget, float inputVal)
void OnEditorOpened()
SCR_EditorManagerEntity event //TODO we shouldnt need this, probably needs to be dependent on camera ...
void SetGadgetADS(bool gadgetADS)
static SCR_GadgetManagerComponent GetGadgetManager(IEntity entity)
void RegisterInputs()
Register input actions.
void RemoveHeldGadget()
Remove gadget held in hand.
override void EOnInit(IEntity owner)
void InitComponent(IEntity owner)
void OnGadgetFocusStateChanged(IEntity gadget, bool isFocused)
void RPC_AskToggleGadget(RplId id, bool state)
void UnregisterVONEntries()
void UnregisterInputs()
Register input actions.
void OnPlayerDeath(SCR_CharacterControllerComponent charController, IEntity instigatorEntity, notnull Instigator instigator)
SCR_CharacterControllerComponent m_Controller
void ToggleHeldGadget(bool state)
ref array< ref array< SCR_GadgetComponent > > m_aInventoryGadgetTypes
SCR_GadgetComponent GetHeldGadgetComponent()
void ClearToggleState()
Clear toggle state for cases where it needs to be done without waiting for animation.
static void SetGadgetModeStashed(SCR_GadgetComponent gadgetComp, EGadgetMode targetMode)
void OnGadgetStateChanged(IEntity gadget, bool isInHand, bool isOnGround)
override void OnDelete(IEntity owner)
void OnGadgetADSHold(float value, EActionTrigger reason)
InputManager m_InputManager
void OnItemAdded(IEntity item, BaseInventoryStorageComponent storageOwner)
IEntity GetQuickslotGadgetByType(EGadgetType type)
static bool ValidController(IEntity owner)
void CancelADSInput()
Cancel weapon and turret ADS input state.
SCR_InventoryStorageManagerComponent m_InventoryStorageMgr
ref map< EGadgetType, int > m_aGadgetArrayMap
static IEntity GetLocalControlledEntity()
SCR_QuickslotBaseContainer is intended to be used for quickslots, to allow quickslotting of non-item ...
VONEntry class for radio entries.
SCR_GadgetComponent GetGadget()
Gadget component associated with this entry.
void SetRadioEntry(notnull BaseTransceiver transceiver, int number, SCR_GadgetComponent gadgetComp)
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
EntityEvent
Various entity events.
proto external PlayerController GetPlayerController()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplCondition
Conditional replication rule. Fine grained selection of receivers.
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
proto native void Clear()
Remove all calls from list.