24 [
Attribute(
desc:
"Voting Templates, please use configs and the VotingManagerComponent prefab for default gamemode voting templates")]
25 protected ref array<ref SCR_VotingBase> m_aVotingTemplates;
45 static const LocalizedString VOTE_TIMEOUT_FORMAT =
"#AR-Voting_TimeOut";
74 if (!
GetGame().GetPlayerManager().IsPlayerConnected(playerID))
76 Print(
string.Format(
"Non-existent player %1 is attempting to vote in %2 for %3", playerID,
typename.EnumToString(
EVotingType,
type), value),
LogLevel.WARNING);
95 voting.
SetVote(playerID, value);
158 return voting != null;
206 return votesRequired > 0;
309 bool isOngoing = vote != null;
396 int GetVotingsAboutPlayer(
int playerID, out notnull array<EVotingType> outVotingTypes,
bool onlyTemplates =
false,
bool onlyAvailable =
false)
398 array<ref SCR_VotingBase> votings;
400 votings = m_aVotingTemplates;
404 outVotingTypes.Clear();
408 bool isMatchingValue = onlyTemplates || voting.GetValue() == playerID;
409 bool isAvailable = !onlyAvailable || voting.IsAvailable(playerID,
IsVoting(voting.GetType(), playerID)) || (onlyTemplates &&
DiagMenu.GetValue(
SCR_DebugMenuID.DEBUGUI_VOTING_ENABLE_ALL));
410 if (voting.IsValuePlayerID() && isMatchingValue && isAvailable)
411 outVotingTypes.Insert(voting.GetType());
413 return outVotingTypes.Count();
424 int GetAllVotingsAboutPlayer(
bool aboutPlayer, out notnull array<EVotingType> outVotingTypes,
bool onlyTemplates =
false,
bool onlyAvailable =
false)
426 array<ref SCR_VotingBase> votings;
428 votings = m_aVotingTemplates;
432 outVotingTypes.Clear();
435 if (aboutPlayer == voting.IsValuePlayerID() && (!onlyAvailable || voting.IsAvailable(voting.GetValue(),
true)))
436 outVotingTypes.Insert(voting.GetType());
438 return outVotingTypes.Count();
449 int GetAllVotingsWithValue(out notnull array<EVotingType> outVotingTypes, array<EVotingType> outValues,
bool onlyTemplates =
false,
bool onlyAvailable =
false)
451 array<ref SCR_VotingBase> votings;
453 votings = m_aVotingTemplates;
457 outVotingTypes.Clear();
462 outVotingTypes.Insert(voting.GetType());
463 outValues.Insert(voting.GetValue());
466 return outVotingTypes.Count();
478 array<ref SCR_VotingBase> votings;
480 votings = m_aVotingTemplates;
487 if (voting.GetType() ==
type && (!onlyAvailable || voting.IsAvailable(voting.GetValue(),
true)))
488 outValues.Insert(voting.GetValue());
490 return outValues.Count();
502 if (
template.HasInitiatedVotingLocallyOnce())
504 Print(
"Trying to get Join Server vote delay but the local player has already voted for the vote type + (" +
typename.EnumToString(
EVotingType,
type) +
") once so this will always returns 0",
LogLevel.WARNING);
508 if (!
template.HasCooldown())
512 float joinTimeStamp =
template.GetLocalCooldownTimeStamp();
513 if (joinTimeStamp < 0)
516 return Math.Max((
template.GetJoinServerVoteCooldown() + joinTimeStamp) -
GetTimeStamp(), 0);
525 if (!
template || !
template.HasCooldown())
528 float lastTimeStamp =
template.GetLocalCooldownTimeStamp();
529 if (lastTimeStamp <= 0)
532 return Math.Max((
template.GetVoteCooldownTime() + lastTimeStamp) -
GetTimeStamp(), 0);
545 if (
template.HasInitiatedVotingLocallyOnce())
558 return System.GetTickCount() * 0.001;
560 return world.GetLocalTimestamp().DiffMilliseconds(null) * 0.001;
571 return template.GetInfo();
585 return template.GetValueName(value);
587 return value.ToString();
596 array<EVotingType> validActiveVotingTypes = {};
597 array<int> votingValues = {};
602 for (
int i = 0, count = validActiveVotingTypes.Count(); i < count; i++)
604 if (validActiveVotingTypes[i] ==
type && votingValues[i] == value)
610 if (!
template || !
template.HasCooldown())
615 template.SetHasInitiatedVotingLocallyOnce();
730 Print(
"---------------------------------------------");
736 Print(
"---------------------------------------------");
746 int value = voting.GetValue();
748 bool resultSuccessful =
false;
753 winner = voting.GetWinner();
760 voting.OnVotingEnd(value, winner);
766 resultSuccessful =
true;
792 for (
int i, count = m_aVotingTemplates.Count(); i < count; i++)
795 return m_aVotingTemplates[i];
819 Debug.Error2(
"SCR_VotingManagerComponent",
string.Format(
"Cannot initiate voting of type %1, it does not have a template!",
typename.EnumToString(
EVotingType,
type)));
826 Print(
string.Format(
"Cannot create voting %1 about %2, player with given ID does not exist!",
typename.EnumToString(
EVotingType,
type), value),
LogLevel.WARNING);
832 voting.
InitFromTemplate(
template, startingPlayerID, value, remainingDuration);
834 if (currentVoteCount > 0)
847 SCR_NotificationsComponent.SendLocal(
template.
GetInfo().GetVotingStartNotification(), value, startingPlayerID);
905 if (
type == record.param1 && value == record.param2)
947 gameRunTime =
float.MAX;
956 if (
template.GetJoinServerVoteCooldown() > 0 && gameRunTime >=
template.GetServerRuntimeIgnoreJoinServerCooldown())
958 template.SetLocalCooldownTimeStamp(timeStamp);
987 int votingTypeMin, votingTypeMax;
993 writer.WriteInt(count);
995 for (
int i; i < count; i++)
1010 int votingTypeMin, votingTypeMax;
1016 reader.ReadInt(count);
1019 int value, currentVoteCount, authorId;
1020 float remainingDuration;
1021 for (
int i; i < count; i++)
1023 reader.ReadIntRange(
type, votingTypeMin, votingTypeMax);
1024 reader.ReadInt(value);
1025 reader.ReadFloat(remainingDuration);
1026 reader.ReadInt(currentVoteCount);
1027 reader.ReadInt(authorId);
ArmaReforgerScripted GetGame()
override bool RplLoad(ScriptBitReader reader)
enum EAIGroupCombatMode ComponentEditorProps(category:"GameScripted/AI", description:"Component for utility AI system for groups")
SCR_BaseGameMode GetGameMode()
void SCR_BaseGameModeComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
override bool RplSave(ScriptBitWriter writer)
SCR_DestructionSynchronizationComponentClass ScriptComponentClass int index
override SCR_UIInfo GetInfo()
override void EOnFrame(IEntity owner, float timeSlice)
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void RemoveVote(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
void Vote(EVotingType type, int value)
override bool IsMatching(EVotingType type, int value=DEFAULT_VALUE)
override int GetPlayerVote(int playerID)
override bool CanSendNotification(int value)
ScriptInvokerBase< ScriptInvoker_VotingManagerStartMethod > ScriptInvoker_VotingManagerStart
ScriptInvokerBase< ScriptInvoker_VotingManagerPlayerMethod > ScriptInvoker_VotingManagerPlayer
ScriptInvoker_VotingManagerPlayer GetOnRemoveVote()
ref ScriptInvoker_VotingManagerStart m_OnVotingStart
void SCR_VotingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
ref ScriptInvoker_VotingManagerStart m_OnAbstainVoteLocal
SCR_VotingBase FindTemplate(EVotingType type)
void PreVoteLocal(EVotingType type, int value)
func ScriptInvoker_VotingManagerPlayerMethod
ref ScriptInvoker_VotingManagerStart m_OnVoteLocal
void RPC_PlayerVoteCountChanged(EVotingType type, int value, int voteCount)
ref array< ref Tuple2< int, int > > m_LocalVoteRecords
void AbstainVoteLocally(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
int GetVoteAuthorId(EVotingType type, int value)
ref ScriptInvoker_VotingManagerPlayer m_OnVote
func ScriptInvoker_VotingManagerVoteCountChangedMethod
bool GetVoteAlwaysDisplayVoteInitiatorVotingTimer(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
int GetAllVotingsWithValue(out notnull array< EVotingType > outVotingTypes, array< EVotingType > outValues, bool onlyTemplates=false, bool onlyAvailable=false)
void RemoveVoteLocal(EVotingType type, int value)
int GetAllVotingsAboutPlayer(bool aboutPlayer, out notnull array< EVotingType > outVotingTypes, bool onlyTemplates=false, bool onlyAvailable=false)
int GetLocalVote(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
bool GetVoteAlwaysDisplayVoteSubjectVotingTimer(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
ref ScriptInvoker_VotingManagerVoteCountChanged m_PlayerVoteCountChanged
ref ScriptInvoker_VotingManagerStart m_OnRemoveVoteLocal
ScriptInvokerBase< ScriptInvoker_VotingManagerVoteCountChangedMethod > ScriptInvoker_VotingManagerVoteCountChanged
bool StartVoting(EVotingType type, int startingPlayerID, int value=SCR_VotingBase.DEFAULT_VALUE)
ScriptInvoker_VotingManagerStart GetOnRemoveVoteLocal()
void StartVotingBroadcast(EVotingType type, int value, int startingPlayerID)
bool IsVotingAboutPlayer(int playerID, EVotingType type)
bool IsLocalVote(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
SCR_VotingBase FindVoting(EVotingType type, int value)
ScriptInvoker_VotingManagerStart GetOnVotingStart()
int GetVotingsAboutPlayer(int playerID, out notnull array< EVotingType > outVotingTypes, bool onlyTemplates=false, bool onlyAvailable=false)
void EndVoting(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE, EVotingOutcome outcome=EVotingOutcome.EVALUATE)
bool GetVoteCounts(EVotingType type, int value, out int currentVotes, out int votesRequired)
bool IsVoting(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
int GetCurrentVoteCooldownTime(EVotingType type)
ref array< ref SCR_VotingBase > m_aVotingInstances
ref ScriptInvoker_VotingManagerPlayer m_OnRemoveVote
SCR_VotingBase CreateVotingInstance(EVotingType type, int startingPlayerID, int value, float remainingDuration=-1, int currentVoteCount=-1)
ScriptInvoker_VotingManagerStart GetOnAbstainVoteLocal()
ScriptInvokerBase< ScriptInvoker_VotingManagerEndMethod > ScriptInvoker_VotingManagerEnd
func ScriptInvoker_VotingManagerEndMethod
int GetCurrentJoinServerVoteCooldown(EVotingType type)
void EndVotingBroadcast(EVotingType type, int value, int winner)
bool IsVotingAvailable(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
int GetCurrentVoteCooldownForLocalPlayer(EVotingType type)
void DeleteVotingInstance(EVotingType type, int value, int winner)
void VoteLocal(EVotingType type, int value)
ScriptInvoker_VotingManagerPlayer GetOnVote()
SCR_VotingUIInfo GetVotingInfo(EVotingType type)
func ScriptInvoker_VotingManagerStartMethod
bool HasAbstainedLocally(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
ScriptInvoker_VotingManagerVoteCountChanged GetOnVoteCountChanged()
string GetValueName(EVotingType type, int value)
ref ScriptInvoker_VotingManagerEnd m_OnVotingEnd
ref set< SCR_VotingBase > m_aAbstainedVotingInstances
float GetRemainingDurationOfVote(EVotingType type, int value=SCR_VotingBase.DEFAULT_VALUE)
ScriptInvoker_VotingManagerStart GetOnVoteLocal()
int GetAllVotingValues(EVotingType type, out notnull array< int > outValues, bool onlyTemplates=false, bool onlyAvailable=false)
ScriptInvoker_VotingManagerEnd GetOnVotingEnd()
static int GetLocalPlayerId()
Returns either a valid ID of local player or 0.
bool Evaluate(out EVotingOutcome outcome)
bool AddPlayerVotedServer(int playerID)
void InitFromTemplate(SCR_VotingBase template, int startingPlayerID, int value, float remainingDuration)
void SetVoteLocal(int value)
int GetCurrentVoteCount()
bool RemovePlayerVotedServer(int playerID)
float GetRemainingDuration()
static const int DEFAULT_VALUE
bool RemoveVote(int playerID)
int GetVoteCountRequired()
void Update(float timeSlice)
int GetPlayerVote(int playerID)
void SetVote(int playerID, int value=DEFAULT_VALUE)
bool GetAlwaysDisplayVoteSubjectVotingTimer()
void SetCurrentVoteCount(int currentVoteCount)
bool IsAvailable(int value, bool isOngoing)
string GetValueName(int value)
bool GetAlwaysDisplayVoteInitiatorVotingTimer()
bool RemoveValue(int value)
bool ShouldCancelWhenSubjectLeavesTheServer()
static const int ALTERNATIVE_VALUE
Value of the vote, that is used when vote ends in an alternative solution.
ENotification GetVotingSucceedNotification()
ENotification GetLocalVoteCastNotification()
ENotification GetVotingAlternativeNotification()
ENotification GetLocalVoteAbstainedNotification()
ENotification GetVotingFailNotification()
AISpawnerGroupClass AIGroupClass Spawn()
Spawns a new group entity, sets its transformation and then calls OnSpawn.
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.
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)
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
override void OnPlayerRegistered(int playerId)
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout)
void OnPlayerConnected(int playerId)
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.