18 private PlayerController m_PlayerController;
20 private RplComponent m_RplComponent;
22 private SCR_SpawnLockComponent m_Lock;
31 return m_PlayerController;
43 protected SCR_SpawnLockComponent
GetLock()
52 return m_FactionAffiliation;
139 return !m_RplComponent || m_RplComponent.IsOwner();
145 return m_RplComponent && m_RplComponent.IsProxy();
151 super.OnPostInit(owner);
152 m_PlayerController = PlayerController.Cast(owner);
153 if (!m_PlayerController)
154 Debug.Error(
string.Format(
"%1 is not attached to a %2",
Type().
ToString(), PlayerController));
158 if (m_FactionAffiliation)
161 m_Lock = SCR_SpawnLockComponent.Cast(owner.
FindComponent(SCR_SpawnLockComponent));
162 m_RplComponent = RplComponent.Cast(owner.
FindComponent(RplComponent));
173 if (m_FactionAffiliation)
176 super.OnDelete(owner);
184 if (old != current && !m_RplComponent || !m_RplComponent.IsProxy())
189 Print(
"Loadout manager is missing in the world!",
LogLevel.ERROR);
193 int previous = loadoutManager.GetLoadoutIndex(
m_Loadout);
227 #ifdef _ENABLE_RESPAWN_LOGS
232 int loadoutIndex =
GetGame().GetLoadoutManager().GetLoadoutIndex(
loadout);
233 SCR_SpawnLockComponent lock =
GetLock();
234 if (lock && !lock.TryLock(
this,
false))
236 Print(
"SCR_PlayerLoadoutComponent::RequestLoadout - Caught request on locked player!",
LogLevel.DEBUG);
257 #ifdef _ENABLE_RESPAWN_LOGS
262 SCR_SpawnLockComponent lock =
GetLock();
263 if (lock && !lock.TryLock(
this,
true))
265 Print(
"SCR_PlayerLoadoutComponent::Rpc_RequestLoadout_S - Caught request on locked player!",
LogLevel.DEBUG);
297 loadoutManager.UpdatePlayerLoadout_S(
this);
313 #ifdef _ENABLE_RESPAWN_LOGS
314 PrintFormat(
"%1::SendRequestLoadoutResponse_S(loadoutIdx: %2, response: %3)",
Type().
ToString(), loadoutIndex, response);
318 SCR_SpawnLockComponent lock =
GetLock();
321 lock.Unlock(
this,
true);
322 lock.Unlock(
this,
false);
340 #ifdef _ENABLE_RESPAWN_LOGS
341 PrintFormat(
"%1::RequestLoadoutResponse_O(loadoutIdx: %2, response: %3)",
Type().
ToString(), loadoutIndex, response);
345 SCR_SpawnLockComponent lock =
GetLock();
348 lock.Unlock(
this,
false);
353 m_Loadout = loadoutManager.GetLoadoutByIndex(loadoutIndex);
368 #ifdef _ENABLE_RESPAWN_LOGS
373 SCR_SpawnLockComponent lock =
GetLock();
374 if (lock && !lock.TryLock(
this,
false))
376 Print(
"SCR_PlayerLoadoutComponent::CanRequestLoadout - Caught request on locked player!",
LogLevel.DEBUG);
380 int loadoutIndex =
GetGame().GetLoadoutManager().GetLoadoutIndex(
loadout);
399 #ifdef _ENABLE_RESPAWN_LOGS
404 SCR_SpawnLockComponent lock =
GetLock();
405 if (lock && !lock.TryLock(
this,
true))
407 Print(
"SCR_PlayerLoadoutComponent::Rpc_CanRequestLoadout_S - Caught request on locked player!",
LogLevel.DEBUG);
436 if (factionAffiliation)
437 playerFaction = factionAffiliation.GetAffiliatedFaction();
443 return loadoutManager.CanAssignLoadout_S(
this,
loadout);
459 key = faction.GetFactionKey();
461 return key == factionLoadout.GetFactionKey();
471 #ifdef _ENABLE_RESPAWN_LOGS
472 PrintFormat(
"%1::SendCanRequestLoadoutResponse_S(loadoutIdx: %2, response: %3)",
Type().
ToString(), loadoutIndex, response);
476 SCR_SpawnLockComponent lock =
GetLock();
479 lock.Unlock(
this,
true);
480 lock.Unlock(
this,
false);
498 #ifdef _ENABLE_RESPAWN_LOGS
499 PrintFormat(
"%1::CanRequestLoadoutResponse_O(loadoutIdx: %2, response: %3)",
Type().
ToString(), loadoutIndex, response);
503 SCR_SpawnLockComponent lock =
GetLock();
506 lock.Unlock(
this,
false);
523 SCR_ArsenalManagerComponent arsenalManager;
524 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
529 if (arsenalManager.GetLocalPlayerLoadoutAvailable() != loadoutValid || loadoutChanged)
532 if (localData && arsenalManager.GetCalculatedLoadoutSpawnSupplyCostMultiplier() > 0)
533 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_LOADOUT_SAVED_SUPPLY_COST, localData.LoadoutCost);
535 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_LOADOUT_SAVED);
538 SCR_NotificationsComponent.SendLocal(
ENotification.PLAYER_LOADOUT_NOT_SAVED_UNCHANGED);
541 arsenalManager.SetLocalPlayerLoadoutAvailable(loadoutValid);
555 SCR_ArsenalManagerComponent arsenalManager;
556 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
559 arsenalManager.m_LocalPlayerLoadoutData =
loadoutData;
572 SCR_ArsenalManagerComponent arsenalManager;
573 if (!SCR_ArsenalManagerComponent.GetArsenalManager(arsenalManager))
576 arsenalManager.SetLocalPlayerLoadoutAvailable(
false);
589 DbgUI.Begin(
string.Format(
"PlayerLoadout (id: %1)", playerId));
592 string loadoutName =
"None";
594 loadoutName =
loadout.GetLoadoutName();
599 DbgUI.InputInt(
"Wanted Loadout Idx", wantedIdx);
604 DbgUI.Text(
string.Format(
"Wanted: %1 (%2)", wantedLoadout.GetLoadoutName(), wantedLoadout));
606 DbgUI.Text(
string.Format(
"Wanted: None (Clear)"));
608 if (
DbgUI.Button(
"CanRequest"))
610 if (
DbgUI.Button(
"Request"))
ArmaReforgerScripted GetGame()
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
ref SCR_PlayerLoadoutData loadoutData
SCR_BaseGameMode GetGameMode()
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
func PlayerLoadoutRequestDelegate
ScriptInvokerBase< PlayerLoadoutRequestDelegate > OnPlayerLoadoutRequestInvoker
ScriptInvokerBase< PlayerLoadoutResponseDelegate > OnPlayerLoadoutResponseInvoker
func PlayerLoadoutResponseDelegate
void SCR_RespawnComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void Rpc(func method, void p0=NULL, void p1=NULL, void p2=NULL, void p3=NULL, void p4=NULL, void p5=NULL, void p6=NULL, void p7=NULL)
proto external Managed FindComponent(typename typeName)
void OnPlayerLoadoutSet_S(SCR_PlayerLoadoutComponent loadoutComponent, SCR_BasePlayerLoadout loadout)
void Rpc_RequestLoadout_S(int loadoutIndex)
void DoPlayerClearHasLoadout_O()
void SendRequestLoadoutResponse_S(int loadoutIndex, bool response)
bool IsLoadoutUseableByFaction(SCR_BasePlayerLoadout loadout, Faction faction)
bool RequestLoadout(SCR_BasePlayerLoadout loadout)
SCR_BasePlayerLoadout GetLoadout()
ref OnPlayerLoadoutRequestInvoker m_OnCanPlayerLoadoutRequestInvoker_S
OnPlayerLoadoutResponseInvoker GetOnCanPlayerLoadoutResponseInvoker_S()
ref OnPlayerLoadoutResponseInvoker m_OnPlayerLoadoutResponseInvoker_S
bool CanRequestLoadout(SCR_BasePlayerLoadout loadout)
PlayerController GetPlayerController()
void DoSetPlayerHasLoadout_O(bool loadoutValid, bool loadoutChanged, bool notification)
void DoSetPlayerHasLoadout(bool loadoutValid, bool loadoutChanged, bool notification)
override void OnDelete(IEntity owner)
bool AssignLoadout_S(int loadoutIndex)
override void OnPostInit(IEntity owner)
bool CanAssignLoadout_S(int loadoutIndex)
OnPlayerLoadoutRequestInvoker GetOnCanPlayerLoadoutRequestInvoker_S()
ref OnPlayerLoadoutRequestInvoker m_OnPlayerLoadoutRequestInvoker_S
OnPlayerLoadoutRequestInvoker GetOnPlayerLoadoutRequestInvoker_S()
OnPlayerLoadoutResponseInvoker GetOnCanPlayerLoadoutResponseInvoker_O()
ref OnPlayerLoadoutResponseInvoker m_OnCanPlayerLoadoutResponseInvoker_S
SCR_BasePlayerLoadout m_Loadout
Assigned loadout index. Relevant to authority only.
OnPlayerLoadoutRequestInvoker GetOnPlayerLoadoutRequestInvoker_O()
void SendCanRequestLoadoutResponse_S(int loadoutIndex, bool response)
void DoSendPlayerLoadout_O(SCR_PlayerLoadoutData loadoutData)
void RequestLoadoutResponse_O(int loadoutIndex, bool response)
void DoSendPlayerLoadout(SCR_PlayerLoadoutData loadoutData)
ref OnPlayerLoadoutResponseInvoker m_OnCanPlayerLoadoutResponseInvoker_O
SCR_PlayerFactionAffiliationComponent GetPlayerFactionAffiliationComponent()
void OnFactionChanged(FactionAffiliationComponent owner, Faction old, Faction current)
ref OnPlayerLoadoutResponseInvoker m_OnPlayerLoadoutResponseInvoker_O
OnPlayerLoadoutResponseInvoker GetOnPlayerLoadoutResponseInvoker_S()
ref OnPlayerLoadoutRequestInvoker m_OnCanPlayerLoadoutRequestInvoker_O
void CanRequestLoadoutResponse_O(int loadoutIndex, bool response)
void DoPlayerClearHasLoadout()
ref OnPlayerLoadoutRequestInvoker m_OnPlayerLoadoutRequestInvoker_O
void Rpc_CanRequestLoadout_S(int loadoutIndex)
OnPlayerLoadoutRequestInvoker GetOnCanPlayerLoadoutRequestInvoker_O()
OnPlayerLoadoutResponseInvoker GetOnPlayerLoadoutResponseInvoker_O()
SCR_BasePlayerLoadout GetAssignedLoadout()
SCR_SpawnLockComponent GetLock()
void OnDiag(IEntity owner, float timeslice)
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
proto void PrintFormat(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL, LogLevel level=LogLevel.NORMAL)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.