4 [
Attribute(
"0",
desc:
"If true will try and get the Arsenal component from parent if none found. This is to check if saving is allowed. If no arsenal is found then saving is always true")]
5 protected bool m_bAllowGetArsenalFromParent;
11 protected SCR_ArsenalManagerComponent m_ArsenalManager;
14 override protected bool CanBeShownScript(IEntity user)
16 #ifdef DISABLE_ARSENAL_LOADOUTS
19 if (!m_ArsenalManager || !super.CanBeShownScript(user))
23 if (!m_ArsenalComponent || !m_ArsenalComponent.GetArsenalInventoryComponent() || (m_ArsenalComponent.GetArsenalSaveType() == SCR_EArsenalSaveType.SAVING_DISABLED && !m_ArsenalComponent.IsArsenalSavingDisplayedIfDisabled()))
27 SCR_ArsenalManagerComponent arsenalManager;
28 return (!playerController || !playerController.IsPossessing());
32 override protected bool CanBePerformedScript(IEntity user)
34 UpdateActionDisplayName(user);
36 if (m_ArsenalComponent.GetArsenalSaveType() == SCR_EArsenalSaveType.SAVING_DISABLED)
39 if (!super.CanBePerformedScript(user))
41 m_sSaveTypeDisplayName =
string.Empty;
49 override void Init(IEntity pOwnerEntity, GenericComponent pManagerComponent)
54 super.Init(pOwnerEntity, pManagerComponent);
56 SCR_ArsenalManagerComponent.GetArsenalManager(m_ArsenalManager);
57 if (!m_ArsenalManager)
62 if (!m_ArsenalComponent && m_bAllowGetArsenalFromParent &&
GetOwner().GetParent())
66 if (!m_ArsenalComponent)
68 Print(
"SCR_SaveArsenalLoadout is attached to an entity that does not have an arsenal on self or parent (if m_bAllowGetArsenalFromParent is true)!", LogLevel.WARNING);
73 m_ArsenalComponent.SetHasSaveArsenalAction(
true);
77 protected void UpdateActionDisplayName(notnull IEntity user)
80 if (!m_ArsenalComponent)
84 SCR_EArsenalSaveType arsenalSaveType = m_ArsenalComponent.GetArsenalSaveType();
87 if (!m_ArsenalManager)
99 m_sSaveTypeDisplayName =
string.Empty;
104 m_sSaveTypeDisplayName = saveTypeUIInfo.GetPlayerActionDisplayName();
109 SetCannotPerformReason(
string.Empty);
114 if (arsenalSaveType == SCR_EArsenalSaveType.SAVING_DISABLED)
116 SetCannotPerformReason(m_sSaveTypeDisplayName);
117 m_sSaveTypeDisplayName =
string.Empty;
121 if (arsenalSaveType == SCR_EArsenalSaveType.FACTION_ITEMS_ONLY)
123 FactionAffiliationComponent userFactionAffiliation = FactionAffiliationComponent.Cast(user.FindComponent(FactionAffiliationComponent));
124 if (!userFactionAffiliation)
126 m_sSaveTypeDisplayName =
string.Empty;
130 Faction faction = userFactionAffiliation.GetAffiliatedFaction();
133 m_sSaveTypeDisplayName =
string.Empty;
137 m_sSaveTypeDisplayName = WidgetManager.Translate(m_sSaveTypeDisplayName, faction.GetFactionName());
142 override bool GetActionNameScript(out
string outName)
145 outName = m_sSaveTypeDisplayName;
147 return super.GetActionNameScript(outName);
153 override protected void PerformAction(IEntity pOwnerEntity, IEntity pUserEntity)
155 if (!m_ArsenalManager || !m_ArsenalComponent)
158 int playerId =
GetGame().GetPlayerManager().GetPlayerIdFromControlledEntity(pUserEntity);
162 super.PerformAction(pOwnerEntity, pUserEntity);
164 m_ArsenalManager.SetPlayerArsenalLoadout(playerId, GameEntity.Cast(pUserEntity), m_ArsenalComponent, SCR_EArsenalSupplyCostType.RESPAWN_COST);