1#ifdef BREAK_COMPILATION
2 THIS DEFINE BREAKS
GAME SCRIPT MODULE COMPILATION
3 DO
NOT REMOVE IT, IT IS NEEDED FOR VARIOUS TESTS
58 private bool m_bGameStarted =
false;
61 protected ref SCR_Stack<SCR_GameErrorMessage>
m_aErrorStack =
new SCR_Stack<SCR_GameErrorMessage>();
93 if (!prefabResource.IsValid())
96 if (!randomizeEditableVariant)
142 Print(
"Trying to register a SCR_DataCollectorComponent, but one is already registered!",
LogLevel.ERROR);
166 Print(
"Trying to register a SCR_BuildingDestructionManagerComponent, but one is already registered!",
LogLevel.ERROR);
270 enabledSaveTypes = pHeader.m_eSaveTypes;
272 GetSaveGameManager().SetEnabledSaveTypes(enabledSaveTypes);
300 SCR_CharacterCameraHandlerComponent camHandlerComp = SCR_CharacterCameraHandlerComponent.Cast(playerEntity.FindComponent(SCR_CharacterCameraHandlerComponent));
303 camHandlerComp.UpdateHeadVisibility(cameraPosition);
320 const string format =
"Kick cause code: group=%1 '%2', reason=%3 '%4'";
321 string strDetail =
string.Format(format, groupInt, group, reasonInt,
reason);
325 string dialogTag = group +
"_" +
reason;
328 if (group ==
"<unknown>")
329 dialogTag =
"DEFAULT_ERROR";
333 if (
reason ==
"<unknown>")
367 group =
"REPLICATION";
373 group =
"BATTLEYE_INIT";
397 group =
"PLAYER_MANAGER";
414 if (strAttempt.IsEmpty())
420 attempt = strAttempt.ToInt();
456 if (currentDialog != null)
479 return m_bGameStarted;
563 m_bGameStarted =
true;
567 if (currentMode !=
RplMode.Client)
570 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_DEPLOYABLE_SPAWNPOINTS_ENABLE_DIAG,
"",
"Show Exclusion Zones",
"Deployable SpawnPoints");
573 DiagMenu.RegisterItem(
SCR_DebugMenuID.DEBUGUI_INPUT_MANAGER,
"",
"Show input manager",
"GameCode",
"disabled,active,all");
576 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_GAME_BOUNDS_OVERLAP_PREFAB,
"",
"Show bounds overlap target info",
"Game");
577 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_GAME_CURSOR_TARGET_PREFAB,
"",
"Show cursor target info",
"Game");
578 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_GAME_COPY_ENF_VIEW_LINK,
"lctrl+lshift+l",
"Copy view link",
"Game");
587 DiagMenu.RegisterBool(
SCR_DebugMenuID.DEBUGUI_SHOW_INTERIOR_BOUNDING_BOX,
"",
"Show interior bounding box",
"Scripts");
603#ifndef PLATFORM_CONSOLE
604 if (
System.IsCLIParam(
"listScenarios"))
609 if (!
FileIO.FileExists(
"$profile:.save\\settings\\customInputConfigs"))
610 FileIO.MakeDirectory(
"$profile:.save\\settings\\customInputConfigs");
613#ifdef PLATFORM_CONSOLE
621 if (settingsVideoModule)
623 int lastUsedPresetID = -1;
627 videoSettings.Get(
"m_iLastUsedPreset", lastUsedPresetID);
628 if (lastUsedPresetID == -1 &&
System.GetPlatform() ==
EPlatform.XBOX_SERIES_S)
629 settingsVideoModule.
SetConsolePreset(EVideoQualityPreset.SERIES_S_PRESET_PERFORMANCE);
630 else if (lastUsedPresetID == -1 &&
System.GetPlatform() ==
EPlatform.XBOX_SERIES_X)
631 settingsVideoModule.
SetConsolePreset(EVideoQualityPreset.SERIES_X_PRESET_PERFORMANCE);
632 else if (lastUsedPresetID == -1 &&
System.GetPlatform() ==
EPlatform.PS5)
634 else if (lastUsedPresetID == -1 &&
System.GetPlatform() ==
EPlatform.PS5_PRO)
635 settingsVideoModule.
SetConsolePreset(EVideoQualityPreset.PS5_PRO_PERFORMANCE);
637 if (lastUsedPresetID != -1)
645 if (additionalSettingsComp && ((currentMode ==
RplMode.Listen || currentMode ==
RplMode.Dedicated) &&
System.IsCLIParam(
"enableNightGrain")))
646 additionalSettingsComp.SetNightNoiseEffectState_S(
false);
654 MenuManager menuManager =
GetGame().GetMenuManager();
663 static void OnShowPlayerList()
665 MenuManager manager =
GetGame().GetMenuManager();
674 static void OnShowGroupMenu()
683 static void OpenPauseMenu(
bool hideParentMenu =
true,
bool fadeBackground =
false)
689 PauseMenuUI pauseMenu = PauseMenuUI.Cast(menu);
691 pauseMenu.FadeBackground(
true,
true);
697 static SCR_PlayerListMenu OpenPlayerList()
699 MenuManager menuManager =
GetGame().GetMenuManager();
707 return SCR_PlayerListMenu.Cast(menu);
716 if (!groupManager || !groupManager.IsGroupMenuAllowed())
719 SCR_Faction playerFaction;
722 playerFaction = SCR_Faction.Cast(factionManager.GetLocalPlayerFaction());
727 MenuManager menuManager =
GetGame().GetMenuManager();
739 GetGame().GetMenuManager().CloseMenu(menu);
741 return SCR_GroupMenu.Cast(menu);
749 GetGame().GetMenuManager().CloseAllMenus();
807 inputManager.AddActionListener(
"ShowScoreboard",
EActionTrigger.DOWN, OnShowPlayerList);
808 inputManager.AddActionListener(
"ShowGroupMenu",
EActionTrigger.DOWN, OnShowGroupMenu);
821 inputManager.RemoveActionListener(
"ShowScoreboard",
EActionTrigger.DOWN, OnShowPlayerList);
822 inputManager.RemoveActionListener(
"ShowGroupMenu",
EActionTrigger.DOWN, OnShowGroupMenu);
831 private ref QueryTargetDiag m_pQueryTargetDiag =
new QueryTargetDiag();
834 private bool GetQueryTargetInfo(
IEntity ent, out
string name, out
string tree)
843 name = prefabData.GetPrefabName();
846 BaseContainer cont = prefabData.GetPrefab();
849 string contName = cont.GetName();
850 if (!contName.IsEmpty())
860 cont = cont.GetAncestor();
870 super.OnUpdate(world, timeslice);
895 if (bGetEnfLinkToClipboard)
898 vector cameraTransform[4];
899 world.GetCurrentCamera(cameraTransform);
900 System.ExportToClipboard(GetWorldEditorLink(cameraTransform));
907 CameraManager cameraManager =
GetGame().GetCameraManager();
910 CameraBase current = cameraManager.CurrentCamera();
913 DbgUI.Begin(
"Cursor target info");
914 IEntity ent = current.GetCursorTarget();
924 pname =
"Unnamed entity";
926 pname =
"Name: " + name;
934 if (GetQueryTargetInfo(ent, prfab, ptree))
936 pepos =
"Position: <" + pos[0] +
", " + pos[1] +
", " + pos[2] +
">";
939 if (phys && phys.GetVelocity().Length() > 0)
941 string pevel =
"Velocity: " + phys.GetVelocity().Length();
947 DbgUI.Text(
"Prefab: " + prfab);
948 DbgUI.Text(
"Prefab Inheritance Tree: " + ptree);
951 string infoText =
string.Format(
"%1\n%2\nPrefab: \"%3\"\nPrefab Inheritance Tree: \"%4\"", pname, pepos, prfab, ptree);
953 if (
DbgUI.Button(
"Copy to clipboard"))
955 System.ExportToClipboard(infoText);
964 DebugTextWorldSpace.Create(current.GetWorld(), infoText,
DebugTextFlags.FACE_CAMERA |
DebugTextFlags.CENTER |
DebugTextFlags.ONCE, pos[0], maxs[1] + 0.5, pos[2], 8,
ARGB(255, 0, 255, 255),
ARGB(64, 0, 0, 0));
973 CameraManager cameraManager =
GetGame().GetCameraManager();
976 CameraBase current = cameraManager.CurrentCamera();
979 DbgUI.Begin(
"Bounds overlap target info");
981 current.GetWorldTransform(cameraMat);
983 m_pQueryTargetDiag.Prepare();
984 m_pQueryTargetDiag.DoQuery(current.GetWorld(), cameraMat[3], cameraMat[3] + 3.0 * cameraMat[2]);
985 IEntity ent = m_pQueryTargetDiag.GetClosestEntity(cameraMat[3]);
995 pname =
"Unnamed entity";
997 pname =
"Name: " + name;
1005 if (GetQueryTargetInfo(ent, prfab, ptree))
1007 pepos =
"Position: <" + pos[0] +
", " + pos[1] +
", " + pos[2] +
">";
1010 if (phys && phys.GetVelocity().Length() > 0)
1012 string pevel =
"Velocity: " + phys.GetVelocity().Length();
1018 DbgUI.Text(
"Prefab: " + prfab);
1019 DbgUI.Text(
"Prefab Inheritance Tree: " + ptree);
1022 string infoText =
string.Format(
"%1\n%2\nPrefab: \"%3\"\nPrefab Inheritance Tree: \"%4\"", pname, pepos, prfab, ptree);
1023 if (
DbgUI.Button(
"Copy to clipboard"))
1025 System.ExportToClipboard(infoText);
1034 DebugTextWorldSpace.Create(current.GetWorld(), infoText,
DebugTextFlags.FACE_CAMERA |
DebugTextFlags.CENTER |
DebugTextFlags.ONCE, pos[0], maxs[1] + 0.5, pos[2], 8,
ARGB(255, 0, 255, 255),
ARGB(64, 0, 0, 0));
1045 GetGame().GetMenuManager().CloseAllMenus();
1059 array<Widget> widgets = {};
1063 int count = widgets.Count();
1064 Print(
string.Format(
"Widgets under cursor (x = %1, y = %2): %3", mouseX, mouseY, count),
LogLevel.NORMAL);
1065 for (
int i; i < count; i++)
1096 if (!instance || !
ChimeraWorld.CastFrom(instance.GetWorld()))
1101 Print(
"Trying to register a SCR_LoadoutManager, but one is already registered!",
LogLevel.ERROR);
1103 Print(
string.Format(
" newEntity: %1", instance),
LogLevel.ERROR);
1123 if (instance && !
ChimeraWorld.CastFrom(instance.GetWorld()))
1128 Print(
"Trying to unregister a SCR_LoadoutManager, but none is registered!",
LogLevel.ERROR);
1134 Print(
"Trying to unregister an invalid SCR_LoadoutManager!",
LogLevel.ERROR);
1140 Print(
"Trying to unregister a SCR_LoadoutManager, but different one is registered!",
LogLevel.ERROR);
1144 Print(
"SCR_LoadoutManager unregistered successfully, released instance: " + instance,
LogLevel.VERBOSE);
1160 static string GetWorldEditorLink(vector transformation[4])
1163 vector
position = transformation[3];
1166 vector
angles = Math3D.MatrixToAngles(transformation);
1170 string fullLink =
GetGame().GetWorldFile();
1171 string fullLinkLower = fullLink;
1172 fullLinkLower.ToLower();
1173 int begin = fullLinkLower.IndexOf(
"worlds/");
1174 string worldPath = fullLink.Substring(begin, fullLink.Length() - begin);
1177 string link =
string.Format(
1178 "enfusion://WorldEditor/%1;%2,%3,%4;%5,%6,%7",
1215 return header.m_sName;
1223 Print(
string.Format(
"PlayGameConfig {Resource: %1; Addons: %2}", sResource, addonsList),
LogLevel.NORMAL);
1225 if (sResource.Empty)
1227 Print(
string.Format(
"PlayGameConfig: Empty resource passed!"),
LogLevel.NORMAL);
1232 GetGame().GetMenuManager().CloseAllMenus();
1234 Print(
string.Format(
"Failed to start scenario."),
LogLevel.ERROR);
1243 GetGame().GetMenuManager().CloseAllMenus();
1261 const ResourceName config =
"{CB4130E7FBE99D74}Configs/Workshop/DefaultScenarios.conf";
1266 BaseContainer entries = resource.GetResource().ToBaseContainer();
1270 array<ResourceName> resources = {};
1272 entries.Get(
"m_aDefaultScenarios", resources);
1289 resources.Insert(scenario);
1295 protected static bool CheckMissionHeader(MissionWorkshopItem mission)
1297 SCR_MissionHeader header = SCR_MissionHeader.Cast(mission.GetHeader());
1301 Print(
string.Format(
"Mission header doesn't exist or is not of SCR_MissionHeader class: %1", mission.Name()),
LogLevel.ERROR);
1305 string worldPath = header.GetWorldPath();
1306 if (worldPath.IsEmpty())
1308 Print(
string.Format(
"Mission world path is incorrect: %1", mission.Name()),
LogLevel.ERROR);
1317 static SCR_2DPIPSightsComponent GetCurrentPIPSights()
1319 IEntity controlledEntity = SCR_PlayerController.GetLocalControlledEntity();
1320 if (!controlledEntity)
1323 ChimeraCharacter character = ChimeraCharacter.Cast(controlledEntity);
1327 BaseWeaponManagerComponent weaponManager = character.GetCharacterController().GetWeaponManagerComponent();
1331 BaseSightsComponent currentSights = weaponManager.GetCurrentSights();
1335 SCR_2DPIPSightsComponent pip = SCR_2DPIPSightsComponent.Cast(currentSights);
1347 static bool IsScreenPointInPIPSights(vector screenPosition, SCR_2DPIPSightsComponent sightsComponent)
1349 if (!sightsComponent)
1352 return sightsComponent.IsScreenPositionInSights(screenPosition);
1359 #ifdef PLATFORM_CONSOLE
1393 g_ARGame =
new ArmaReforgerScripted;
1404class QueryTargetDiag
1406 private ref array<IEntity> m_aQueriedTargetEntities = {};
1413 m_aQueriedTargetEntities.Clear();
1422 void DoQuery(BaseWorld world, vector from, vector to)
1424 world.QueryEntitiesByLine(from, to, QueryTargetEntity);
1428 private bool QueryTargetEntity(
IEntity ent)
1430 if (CameraBase.Cast(ent))
1433 m_aQueriedTargetEntities.Insert(ent);
1440 if (m_aQueriedTargetEntities.Count() > 0)
1441 return m_aQueriedTargetEntities[0];
1450 IEntity GetClosestEntity(vector relativeTo)
1453 float sqDistance =
float.MAX;
1454 foreach (
IEntity ent : m_aQueriedTargetEntities)
1456 float currentSqDist = vector.DistanceSq(ent.
GetOrigin(), relativeTo);
1457 if (currentSqDist < sqDistance)
1460 sqDistance = currentSqDist;
ref ScriptInvokerVoid m_OnHUDManagerChanged
EGameFlags m_eGameFlags
Game Flags specific for current game mode, or for the game mode which is going to be played when it i...
SCR_ResourceGrid GetResourceGrid()
ScriptedChatEntity m_ChatEntity
SCR_SettingsManager GetSettingsManager()
IEntity SpawnEntityPrefabEx(ResourceName prefab, bool randomizeEditableVariant, BaseWorld world=null, EntitySpawnParams params=null)
ref ScriptInvoker m_OnWorldSimulatePhysicsInvoker
void UnregisterBuildingDestructionManager(notnull SCR_BuildingDestructionManagerComponent manager)
override void OnCinematicStart()
void ~ArmaReforgerScripted()
void RegisterLoadoutManager(SCR_LoadoutManager instance)
ref SCR_Stack< SCR_GameErrorMessage > m_aErrorStack
Stack of queued error messages. All messages are popped one by one as user closes them and only in th...
ScriptInvokerVoid GetOnHUDManagerChanged()
SCR_LoadoutManager GetLoadoutManager()
ScriptInvoker OnUserSettingsChangedInvoker()
override void OnUserSignedOut()
ref ScriptInvoker m_OnInputDeviceUserChangedInvoker
ref ScriptInvoker m_OnInputDeviceIsGamepadInvoker
bool IsPlatformGameConsole()
ArmaReforgerScripted GetGame()
void SetHUDManager(SCR_HUDManagerComponent hud)
ScriptInvoker OnWindowResizeInvoker()
ArmaReforgerScripted g_ARGame
bool AreGameFlagsObtained()
SCR_DataCollectorComponent GetDataCollector()
ref ScriptInvoker m_OnMissionSetInvoker
ref ScriptInvoker Event_OnObtainedGameFlags
bool m_bAreGameFlagsObtained
override void OnGameInstallComplete()
SCR_HUDManagerComponent GetHUDManager()
ref SCR_ResourceGrid m_ResourceGrid
bool GetFullKickReason(KickCauseCode kickCode, out KickCauseGroup2 groupInt, out int reasonInt, out string group, out string reason)
SCR_ResourceSystemSubscriptionManager GetResourceSystemSubscriptionManager()
ref ScriptInvoker< int, int, bool > m_OnWindowResizeInvoker
override void OnCinematicEnd()
void RegisterBuildingDestructionManager(notnull SCR_BuildingDestructionManagerComponent manager)
ref SCR_ProfaneFilter m_ProfanityFilter
void AddActionListeners()
bool AreGameFlagsSet(EGameFlags checkGameFlags)
ScriptInvoker GetOnObtainedGameFlagsInvoker()
EGameFlags GetGameFlags()
SCR_DataCollectorComponent m_DataCollectorComponent
Object responsible for tracking and connecting to the database for Career Profile.
void InsertNewScenario(ResourceName scenario, inout array< ResourceName > resources)
ScriptInvoker OnWorldSimulatePhysicsInvoker()
void SetGameFlags(EGameFlags newGameFlags, bool shouldInvoke)
SCR_HUDManagerComponent m_HUDManager
ref RplSessionErrorHandler m_SessionErrorHandler
SCR_LoadoutManager m_pLoadoutManager
Object responsible for managing and providing game modes with list of available loadouts.
void ShowNextErrorDialog()
ScriptInvoker OnInputDeviceIsGamepadInvoker()
void RegisterDataCollector(SCR_DataCollectorComponent instance)
override void OnCinematicBlending(float blendFactor, vector cameraPosition)
ref SCR_GameCoresManager m_CoresManager
SCR_BuildingDestructionManagerComponent m_BuildingDestructionManager
ScriptInvoker OnInputDeviceUserChangedInvoker()
void UnregisterLoadoutManager(SCR_LoadoutManager instance)
EGameFlags
GameMode Game Flags represented by bit mask.
ref SCR_SettingsManager m_SettingsManager
ref SCR_ResourceSystemSubscriptionManager m_ResourceSystemSubscriptionManager
SCR_BuildingDestructionManagerComponent GetBuildingDestructionManager()
SCR_ProfaneFilter GetProfanityFilter()
SCR_SpawnerAIGroupManagerComponent m_SpawnerAIGroupManager
enum EGameFlags CONFIG_CORES_PATH
Enum of DiagMenu id values, generated by Game.
ref ScriptInvoker m_OnChangeUserSettingsInvoker
ref ScriptInvoker< bool > m_OnGameInstallComplete
EDiagMenuGameLib
Enum of DiagMenu id values, generated by GameLib.
ref array< string > angles
RplMode
Mode of replication.
ref ScriptCallQueue m_Callqueue
ScriptCallQueue GetCallqueue()
Returns CallQueue of this AI. It gets updated from EvaluateBehavior, so that it's synchronous with ot...
void SCR_AdditionalGameModeSettingsComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
SCR_BaseGameMode GetGameMode()
void SCR_FactionManager(IEntitySource src, IEntity parent)
void RemoveActionListeners()
void SCR_GroupsManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
void SCR_LoadoutManager(IEntitySource src, IEntity parent)
SCR_PlayerManagerKickReason
ScriptInvokerBase< ScriptInvokerVoidMethod > ScriptInvokerVoid
ESettingManagerModuleType
enum EVehicleType IEntity
ref Managed GetPlayerDataStats(int playerID)
Called when the player data is requested.
void OnKickedFromGame(KickCauseCode kickCode)
Called after player was kicked from game back to main menu, providing reason for the kick.
void OnBeforeWorldCleanup()
Called when the current world is about to be unloaded. Can be used to disable any event listeners tha...
string GetMissionName()
Called when DS downloads required addons and is ready to run a world FIXME: I'm not named properly!
ref Managed GetSessionDataStats()
Called when the session data is requested.
void ShowErrorMessage(string msg)
Shows dialog with a provided string.
void OnMissionSet(MissionHeader mission)
Called when a mission header is set (to both a valid one or to null as well).
void SetMessage(string text)
void SetTitle(string text)
event void OnWorldPostProcess(World world)
Event called once loading of all entities of the world have been finished. (still within the loading)...
event void HostGameConfig()
Called after reload to host a modded scenario.
proto external GenericWorldEntity GetWorldEntity()
Returns path of world file loaded.
event void OnGamepadConnectionStatus(bool isConnected)
Event which is called on Gamepad Connection/Disconnection.
proto external IEntity SpawnEntityPrefab(notnull Resource templateResource, BaseWorld world=null, EntitySpawnParams params=null)
event Managed ReadGameConfig(string sResource)
event void OnWindowResize(int w, int h, bool windowed)
Event which is called when window size of fullscreen state changed.
sealed MenuManager GetMenuManager()
event void OnInputDeviceIsGamepadEvent(bool isGamepad)
Event which is called when input device binded to user changes between gamepad and keyboard/mouse,...
event bool OnGameStart()
Event which is called right before game starts (all entities are created and initialized)....
event ref array< ResourceName > GetDefaultGameConfigs()
sealed InputManager GetInputManager()
event void OnGameEnd()
Event which is called right before game end.
event void OnInputDeviceUserChangedEvent(EInputDeviceType oldDevice, EInputDeviceType newDevice)
Event which is called when input device binded to user changed.
sealed WorkspaceWidget GetWorkspace()
event void OnUserSettingsChangedEvent()
Event which is called when user change settings.
event void OnWorldSimulatePhysics(float timeSlice)
Event which is called before each fixed step of the physics simulation.
event void PlayGameConfig(ResourceName sResource, string addonsList)
proto external bool InPlayMode()
event LoadingAnim CreateLoadingAnim(WorkspaceWidget workspaceWidget)
event void OnAfterInit(BaseWorld world)
Called after full initialization of Game instance.
GameSessionStorage is used to store data for whole lifetime of game executable run....
proto external vector GetOrigin()
proto external Physics GetPhysics()
proto external void GetWorldBounds(out vector mins, out vector maxs)
proto external EntityPrefabData GetPrefabData()
proto external string GetName()
Object holding reference to resource. In destructor release the resource.
override event void OnWorldPostProcess(World world)
static ResourceName GetRandomVariant(ResourceName prefab)
static SCR_GameCoresManager CreateCoresManager()
Wrapper for error messages.
Dialog displayed when the gamepad is removed.
static void CloseGamepadRemovalDialog()
static SCR_GamepadRemovalUI OpenGamepadRemovalDialog()
static void CreateKickErrorDialog(string msg, string group, string details="")
Set message for error dialog and create it.
static IEntity GetLocalControlledEntity()
Handles filtering profanities in texts.
SCR_SettingsManagerModuleBase GetModule(ESettingManagerModuleType moduleType)
void SetConsolePreset(int presetIndex)
ScriptCallQueue Class provide "lazy" calls - when we don't want to execute function immediately but l...
Instance of created debug visualizer.
proto external bool Prepare(ResourceName animation, float startTime, float speed, bool loop)
Prepare this component for playing, provide an animation, start time, playing speed and loop flag.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
KickCauseGroup2
Extends KickCauseGroup by adding game-specific groups.
proto int ARGB(int a, int r, int g, int b)