/* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * * For complete copyright and license terms please see the LICENSE at the root of this * distribution (the "License"). All use of this software is governed by the License, * or, if provided, by the license below or the license accompanying this file. Do not * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ // Original file Copyright Crytek GMBH or its affiliates, used under license. #ifndef CRYINCLUDE_CRYSCRIPTSYSTEM_SCRIPTBINDINGS_SCRIPTBIND_SYSTEM_H #define CRYINCLUDE_CRYSCRIPTSYSTEM_SCRIPTBINDINGS_SCRIPTBIND_SYSTEM_H #pragma once #include struct ISystem; struct ILog; struct IRenderer; struct IConsole; struct IInput; struct ITimer; struct IEntitySystem; struct I3DEngine; #if ENABLE_CRY_PHYSICS struct IPhysicalWorld; #endif struct ICVar; #undef GetUserName /*! * This class implements script-functions for exposing the System functionalities. * This object doesn't have a global mapping(is not present as global variable into the script state). */ class CScriptBind_System : public CScriptableBase { public: CScriptBind_System(IScriptSystem* pScriptSystem, ISystem* pSystem); virtual ~CScriptBind_System(); virtual void GetMemoryUsage(ICrySizer* pSizer) const { pSizer->AddObject(this, sizeof(*this)); } public: //! System.CreateDownload() int CreateDownload(IFunctionHandler* pH); //! System.LoadFont(pszName) //! Font name. //! Loads a font. int LoadFont(IFunctionHandler* pH); //! System.ExecuteCommand(szCmd) //! Command string. //! Executes a command. int ExecuteCommand(IFunctionHandler* pH); //! System.LogToConsole(sText) //! Text to be logged. //! Logs a message to the console. int LogToConsole(IFunctionHandler* pH); //! System.ClearConsole() //! Clears the console. int ClearConsole(IFunctionHandler* pH); //! System.Log(sText) //! Text to be logged. //! Logs a message. int Log(IFunctionHandler* pH); //! System.LogAlways(sText) //! Text to be logged. //! Logs important data that must be printed regardless verbosity. int LogAlways(IFunctionHandler* pH); //! System.Warning(sText) //! Text to be logged. //! Shows a message text with the warning severity. int Warning(IFunctionHandler* pH); //! System.Error(sText) //! Text to be logged. //! Shows a message text with the error severity. int Error(IFunctionHandler* pH); //! System.IsEditor() //! Checks if the system is the editor. int IsEditor(IFunctionHandler* pH); //! System.IsEditing() //! Checks if the system is in pure editor mode, i.e. not editor game mode. int IsEditing(IFunctionHandler* pH); //! System.GetCurrTime() //! Gets the current time. int GetCurrTime(IFunctionHandler* pH); //! System.GetCurrAsyncTime() //! Gets the current asynchronous time. int GetCurrAsyncTime(IFunctionHandler* pH); //! System.GetFrameTime() //! Gets the frame time. int GetFrameTime(IFunctionHandler* pH); //! System.GetLocalOSTime() //! Gets the local operating system time. int GetLocalOSTime(IFunctionHandler* pH); //! System.GetUserName() //! Gets the username on this machine. int GetUserName(IFunctionHandler* pH); //! System.ShowConsole(nParam) //! 1 to show the console, 0 to hide. //! Shows/hides the console. int ShowConsole(IFunctionHandler* pH); //! System.CheckHeapValid(name) //! Name string. //! Checks the heap validity. int CheckHeapValid(IFunctionHandler* pH); //! System.GetConfigSpec() //! Gets the config specification. int GetConfigSpec(IFunctionHandler* pH); //! System.IsMultiplayer() //! Checks if the game is multiplayer. int IsMultiplayer(IFunctionHandler* pH); //! System.GetEntity(entityId) //! Entity identifier. //! Gets an entity from its ID. int GetEntity(IFunctionHandler* pH); //! System.GetEntityClass(entityId) //! Entity identifier. //! Gets an entity class from its ID. int GetEntityClass(IFunctionHandler* pH); //! System.PrepareEntityFromPool(entityId) //! Entity identifier. //! (optional) Specifies whether the pooled entity shall be prepared immediately rather than queuing a request in case there is a preparation already in progress. //! Prepares the given bookmarked entity from the pool, bringing it into existence. int PrepareEntityFromPool(IFunctionHandler* pH); //! System.ReturnEntityToPool(entityId) //! Entity identifier. //! the bookmarked entity to the pool, destroying it. int ReturnEntityToPool(IFunctionHandler* pH); //! System.ResetPoolEntity(entityId) //! Entity identifier. //! Resets the entity's bookmarked, which frees memory. int ResetPoolEntity(IFunctionHandler* pH); //! System.GetEntities(center, radius) //! Center position vector for the area where to get entities. //! Radius of the area. //! Gets all the entities contained in the specific area of the level. int GetEntities(IFunctionHandler* pH); //! System.GetEntitiesByClass(EntityClass) //! Entity class name. //! Gets all the entities of the specified class. int GetEntitiesByClass(IFunctionHandler* pH, const char* EntityClass); //! System.GetEntitiesInSphere( centre, radius ) //! Centre position vector for the sphere where to look at entities. //! Radius of the sphere. //! Gets all the entities contained into the specified sphere. int GetEntitiesInSphere(IFunctionHandler* pH, Vec3 center, float radius); //! System.GetEntitiesInSphereByClass( centre, radius, EntityClass ) //! Centre position vector for the sphere where to look at entities. //! Radius of the sphere. //! Entity class name. //! Gets all the entities contained into the specified sphere for the specific class name. int GetEntitiesInSphereByClass(IFunctionHandler* pH, Vec3 center, float radius, const char* EntityClass); //! System.GetPhysicalEntitiesInBox( centre, radius ) //! Centre position vector for the area where to look at entities. //! Radius of the sphere. //! Gets all the entities contained into the specified area. int GetPhysicalEntitiesInBox(IFunctionHandler* pH, Vec3 center, float radius); //! System.GetPhysicalEntitiesInBoxByClass( centre, radius, className ) //! Centre position vector for the area where to look at entities. //! Radius of the sphere. //! Entity class name. //! Gets all the entities contained into the specified area for the specific class name. int GetPhysicalEntitiesInBoxByClass(IFunctionHandler* pH, Vec3 center, float radius, const char* className); //! System.GetNearestEntityByClass( centre, radius, className ) //! Centre position vector for the area where to look at entities. //! Radius of the sphere. //! Entity class name. //! Gets the nearest entity with the specified class. int GetNearestEntityByClass(IFunctionHandler* pH, Vec3 center, float radius, const char* className); //! System.GetEntityByName( sEntityName ) //! //! Retrieve entity table for the first entity with specified name. //! If multiple entities with same name exist, first one found is returned. //! //! Name of the entity to search. int GetEntityByName(IFunctionHandler* pH, const char* sEntityName); //! System.GetEntityIdByName( sEntityName ) //! //! Retrieve entity Id for the first entity with specified name. //! If multiple entities with same name exist, first one found is returned. //! //! Name of the entity to search. int GetEntityIdByName(IFunctionHandler* pH, const char* sEntityName); //! System.DrawLabel( vPos, fSize, text [, r [, g [, b [, alpha]]]] ) //! Position vector. //! Size for the label. //! Text of the label. //! Red component for the label colour. Default is 1. //! Green component for the label colour. Default is 1. //! Blue component for the label colour. Default is 1. //! Alpha component for the label colour. Default is 1. //! Draws a label with the specified parameter. int DrawLabel(IFunctionHandler* pH); //! System.DeformTerrain() //! Deforms the terrain. int DeformTerrain(IFunctionHandler* pH); //! System.DeformTerrainUsingMat() //! Deforms the terrain using material. int DeformTerrainUsingMat(IFunctionHandler* pH); //! System.ScreenToTexture() int ScreenToTexture(IFunctionHandler* pH); //! System.DrawTriStrip(handle, nMode, vtxs, r, g, b, alpha ) //! . //! . //! . //! Red component for the label color. Default is 1. //! Green component for the label color. Default is 1. //! Blue component for the label color. Default is 1. //! Alpha component for the label color. Default is 1. //! Draws a triangle strip. int DrawTriStrip(IFunctionHandler* pH); //! System.DrawLine( p1, p2, r, g, b, alpha ) //! Start position of the line. //! End position of the line. //! Red component for the label color. Default is 1. //! Green component for the label color. Default is 1. //! Blue component for the label color. Default is 1. //! Alpha component for the label color. Default is 1. //! Draws a line. int DrawLine(IFunctionHandler* pH); //! System.Draw2DLine(p1x, p1y, p2x, p2y, r, g, b, alpha ) //! X value of the start point of the line. //! Y value of the start point of the line. //! X value of the end point of the line. //! Y value of the end point of the line. //! Red component for the label color. Default is 1. //! Green component for the label color. Default is 1. //! Blue component for the label color. Default is 1. //! Alpha component for the label color. Default is 1. //! Draws a 2D line. int Draw2DLine(IFunctionHandler* pH); //! System.DrawText( x, y, text, font, size, p2y, r, g, b, alpha ) //! X position for the text. //! Y position for the text. //! Text to be displayed. //! Font name. //! Text size. //! Red component for the label color. Default is 1. //! Green component for the label color. Default is 1. //! Blue component for the label color. Default is 1. //! Alpha component for the label color. Default is 1. //! Draws text. int DrawText(IFunctionHandler* pH); //! System.SetGammaDelta( fDelta ) //! Delta value. //! Sets the gamma/delta value. int SetGammaDelta(IFunctionHandler* pH); //! System.CachePostFxGroup( name ) //! Path to the post effect group. //! Precaches a post effect group. If this isn't called, then the XML file will be loaded on demand. int CachePostFxGroup(IFunctionHandler* pH); //! System.SetPostFxGroupEnable( name, enable ) //! Path to the post effect group. //! Boolean indicating whether to enable the group. //! Enables or disables a post effect group. int SetPostFxGroupEnable(IFunctionHandler* pH); //! System.GetPostFxGroupEnable( name ) //! Path to the post effect group. //! Returns true if post effect group is enabled, false if it's disabled, or nil if it isn't found. int GetPostFxGroupEnable(IFunctionHandler* pH); //! System.ApplyPostFxGroupAtPosition( name, position ) //! Path to the post effect group. //! Position to apply the effect at. //! //! Applies a distance-based post effect group at the specified position. //! This would need to be called once each frame per distance-based post effect group while it is enabled. //! If it's called multiple times on the same effect group in a single frame, the effect strength will be increased each time as if each call applies the effect from a different entity. //! int ApplyPostFxGroupAtPosition(IFunctionHandler* pH); //! System.SetPostProcessFxParam( pszEffectParam, value ) //! Parameter for the post processing effect. //! Value for the parameter. //! Sets a post processing effect parameter value. int SetPostProcessFxParam(IFunctionHandler* pH); //! System.GetPostProcessFxParam( pszEffectParam, value ) //! Parameter for the post processing effect. //! Value for the parameter. //! Gets a post processing effect parameter value. int GetPostProcessFxParam(IFunctionHandler* pH); //! System.SetScreenFx( pszEffectParam, value ) //! Parameter for the post processing effect. //! Value for the parameter. //! Sets a post processing effect parameter value. int SetScreenFx(IFunctionHandler* pH); //! System.GetScreenFx( pszEffectParam, value ) //! Parameter for the post processing effect. //! Value for the parameter. //! Gets a post processing effect parameter value. int GetScreenFx(IFunctionHandler* pH); //! System.SetCVar( sCVarName, value ) //! Name of the variable. //! Value of the variable. //! Sets the value of a CVariable. int SetCVar(IFunctionHandler* pH); //! System.GetCVar( sCVarName) //! Name of the variable. //! Gets the value of a CVariable. int GetCVar(IFunctionHandler* pH); //! System.AddCCommand( sCCommandName, sCommand, sHelp) //! C command name. //! Command string. //! Help for the command usage. //! Adds a C command to the system. int AddCCommand(IFunctionHandler* pH); //! System.SetScissor( x, y, w, h ) //! X position. //! Width size. //! Height size. //! Sets scissor info. int SetScissor(IFunctionHandler* pH); //! System.GetSystemMem() //! Gets the amount of the memory for the system. int GetSystemMem(IFunctionHandler* pH); //! System.IsPS20Supported() //! Checks if the PS20 is supported. int IsPS20Supported(IFunctionHandler* pH); //! System.IsHDRSupported() //! Checks if the HDR is supported. int IsHDRSupported(IFunctionHandler* pH); //! System.SetBudget(sysMemLimitInMB, videoMemLimitInMB, frameTimeLimitInMS, soundChannelsPlayingLimit, soundMemLimitInMB, numDrawCallsLimit ) //! Limit of the system memory in MB. //! Limit of the video memory in MB. //! Limit in the frame time in MS. //! Limit of the sound channels playing. //! Limit of the sound memory in MB. //! Limit of the draw calls. //! Sets system budget. int SetBudget(IFunctionHandler* pH); //! System.SetVolumetricFogModifiers( gobalDensityModifier, atmosphereHeightModifier ) //! Modifier for the global density. //! Modifier for the atmosphere height. //! Sets the volumetric fog modifiers. int SetVolumetricFogModifiers(IFunctionHandler* pH); #if ENABLE_CRY_PHYSICS //! System.SetWind( vWind ) //! Wind direction. //! Sets the wind direction. int SetWind(IFunctionHandler* pH); //! System.SetWind() //! Gets the wind direction. int GetWind(IFunctionHandler* pH); #endif // ENABLE_CRY_PHYSICS //! System.GetSurfaceTypeIdByName( surfaceName ) //! Surface name. //! Gets the surface type identifier by its name. int GetSurfaceTypeIdByName(IFunctionHandler* pH, const char* surfaceName); //! System.GetSurfaceTypeNameById( surfaceId ) //! Surface identifier. //! Gets the surface type name by its identifier. int GetSurfaceTypeNameById(IFunctionHandler* pH, int surfaceId); //! System.RemoveEntity( entityId ) //! Entity identifier. //! Removes the specified entity. int RemoveEntity(IFunctionHandler* pH, ScriptHandle entityId); //! System.SpawnEntity( params ) //! Entity parameters. //! Spawns an entity. int SpawnEntity(IFunctionHandler* pH, SmartScriptTable params); //DOC-IGNORE-BEGIN //! System.ActivateLight(name, activate) //! NOT SUPPORTED ANYMORE. int ActivateLight(IFunctionHandler* pH); //DOC-IGNORE-END // int ActivateMainLight(IFunctionHandler *pH); //pos, activate // int SetSkyBox(IFunctionHandler *pH); //szShaderName, fBlendTime, bUseWorldBrAndColor //! System.SetWaterVolumeOffset() //! SetWaterLevel is not supported by 3dengine for now. int SetWaterVolumeOffset(IFunctionHandler* pH); //! System.IsValidMapPos( v ) //! Position vector. //! Checks if the position is a valid map position. int IsValidMapPos(IFunctionHandler* pH); //DOC-IGNORE-BEGIN //! System.EnableMainView() //! Feature unimplemented. int EnableMainView(IFunctionHandler* pH); //DOC-IGNORE-END //! System.EnableOceanRendering() //! True to activate the ocean rendering, false to deactivate it. //! Enables/disables ocean rendering. int EnableOceanRendering(IFunctionHandler* pH); //! System.ScanDirectory( pszFolderName, nScanMode ) //! Folder name. //! Scan mode for the folder. Can be: //! SCANDIR_ALL //! SCANDIR_FILES //! SCANDIR_SUBDIRS //! Scans a directory. int ScanDirectory(IFunctionHandler* pH); //! System.DebugStats( cp ) int DebugStats(IFunctionHandler* pH); //! System.ViewDistanceSet( fViewDist ) //! View distance. //! Sets the view distance. int ViewDistanceSet(IFunctionHandler* pH); //! System.ViewDistanceSet() //! Gets the view distance. int ViewDistanceGet(IFunctionHandler* pH); //! System.GetTerrainElevation( v3Pos ) //! Position of the terraint to be checked. //! Gets the terrain elevation of the specified position. int GetTerrainElevation(IFunctionHandler* pH); // int SetIndoorColor(IFunctionHandler *pH); //! System.ActivatePortal( vPos, bActivate, nID ) //! Position vector. //! True to activate the portal, false to deactivate. //! Entity identifier. //! Activates/deactivates a portal. int ActivatePortal(IFunctionHandler* pH); //! System.DumpMMStats() //! Dumps the MM statistics. int DumpMMStats(IFunctionHandler* pH); //! System.EnumAAFormats( m_Width, m_Height, m_BPP ) //! Enumerates the AA formats. int EnumAAFormats(IFunctionHandler* pH); //! System.EnumDisplayFormats() //! Enumerates display formats. int EnumDisplayFormats(IFunctionHandler* pH); //! System.IsPointIndoors( vPos ) //! Position vector. //! Checks if a point is indoors. int IsPointIndoors(IFunctionHandler* pH); //! System.SetConsoleImage( pszName, bRemoveCurrent ) //! Texture image. //! True to remove the current image, false otherwise. //! Sets the console image. int SetConsoleImage(IFunctionHandler* pH); //! System.ProjectToScreen( vec ) //! Position vector. //! Projects to the screen (not guaranteed to work if used outside Renderer). int ProjectToScreen(IFunctionHandler* pH, Vec3 vec); //DOC-IGNORE-BEGIN //! System.EnableHeatVision() //! Is not supported anymore. int EnableHeatVision(IFunctionHandler* pH); //DOC-IGNORE-END //! System.DumpMemStats( bUseKB ) //! True to use KB, false otherwise. //! Dumps memory statistics. int DumpMemStats (IFunctionHandler* pH); //! System.DumpMemoryCoverage( bUseKB ) //! Dumps memory coverage. int DumpMemoryCoverage(IFunctionHandler* pH); //! System.ApplicationTest( pszParam ) //! Parameters. //! Test the application with the specified parameters. int ApplicationTest (IFunctionHandler* pH); //! System.QuitInNSeconds( fInNSeconds ) //! Number of seconds before quitting. //! Quits the application in the specified number of seconds. int QuitInNSeconds(IFunctionHandler* pH); //! System.DumpWinHeaps() //! Dumps windows heaps. int DumpWinHeaps (IFunctionHandler* pH); //! System.Break() //! Breaks the application with a fatal error message. int Break(IFunctionHandler* pH); //! System.SetViewCameraFov( fov ) //! Sets the view camera fov. int SetViewCameraFov(IFunctionHandler* pH, float fov); //! System.GetViewCameraFov() //! Gets the view camera fov. int GetViewCameraFov(IFunctionHandler* pH); //! System.IsPointVisible( point ) //! Point vector. //! Checks if the specified point is visible. int IsPointVisible(IFunctionHandler* pH, Vec3 point); //! System.GetViewCameraPos() //! Gets the view camera position. int GetViewCameraPos(IFunctionHandler* pH); //! System.GetViewCameraDir() //! Gets the view camera direction. int GetViewCameraDir(IFunctionHandler* pH); //! System.GetViewCameraUpDir() //! Gets the view camera up-direction. int GetViewCameraUpDir(IFunctionHandler* pH); //! System.GetViewCameraAngles() //! Gets the view camera angles. int GetViewCameraAngles(IFunctionHandler* pH); //! System.RayWorldIntersection(vPos, vDir, nMaxHits, iEntTypes) //! Position vector. //! Direction vector. //! Maximum number of hits. //! . //! Shots rays into the world. int RayWorldIntersection(IFunctionHandler* pH); //! System.RayTraceCheck(src, dst, skipId1, skipId2) int RayTraceCheck(IFunctionHandler* pH); //! System.BrowseURL(szURL) //! URL string. //! Browses a URL address. int BrowseURL(IFunctionHandler* pH); //! System.IsDevModeEnable() //! //! Checks if game is running in dev mode (cheat mode) //! to check if we are allowed to enable certain scripts //! function facilities (god mode, fly mode etc.). //! int IsDevModeEnable(IFunctionHandler* pH); //! System.SaveConfiguration() //! Saves the configuration. int SaveConfiguration(IFunctionHandler* pH); //! System.Quit() //! Quits the program. int Quit(IFunctionHandler* pH); //! System.GetFrameID() //! Gets the frame identifier. int GetFrameID(IFunctionHandler* pH); //! System.ClearKeyState() //! Clear the key state. int ClearKeyState(IFunctionHandler* pH); //! System.SetSunColor( vColor ) //! Set color of the sun, only relevant outdoors. //! Sun Color as an {x,y,z} vector (x=r,y=g,z=b). int SetSunColor(IFunctionHandler* pH, Vec3 vColor); //! Vec3 System.GetSunColor() //! Retrieve color of the sun outdoors. //! Sun Color as an {x,y,z} vector (x=r,y=g,z=b). int GetSunColor(IFunctionHandler* pH); //! System.SetSkyHighlight( params ) //! Set Sky highlighing parameters. //! //! Table with Sky highlighing parameters. //! //! Highligh Params Meaning //! ------------- ----------- //! size Sky highlight scale. //! color Sky highlight color. //! direction Direction of the sky highlight in world space. //! pod Position of the sky highlight in world space. //! int SetSkyHighlight(IFunctionHandler* pH, SmartScriptTable params); //! System.SetSkyHighlight( params ) //! //! Retrieves Sky highlighing parameters. //! see SetSkyHighlight for parameters description. //! //! int GetSkyHighlight(IFunctionHandler* pH, SmartScriptTable params); //! System.LoadLocalizationXml( filename ) //! Loads Excel exported xml file with text and dialog localization data. int LoadLocalizationXml(IFunctionHandler* pH, const char* filename); private: void MergeTable(IScriptTable* pDest, IScriptTable* pSrc); //log a string to console and/or to disk with support for different languages void LogString(IFunctionHandler* pH, bool bToConsoleOnly); int DeformTerrainInternal(IFunctionHandler* pH, bool nameIsMaterial); private: ISystem* m_pSystem; ILog* m_pLog; IRenderer* m_pRenderer; IConsole* m_pConsole; ITimer* m_pTimer; I3DEngine* m_p3DEngine; //Vlad is too lazy to add this to 3DEngine">so I have to put it here. It should //not be here, but I have to put it somewhere..... float m_SkyFadeStart; // when fogEnd less">start to fade sky to fog float m_SkyFadeEnd; // when fogEnd less">no sky, just fog SmartScriptTable m_pScriptTimeTable; SmartScriptTable m_pGetEntitiesCacheTable; }; #endif // CRYINCLUDE_CRYSCRIPTSYSTEM_SCRIPTBINDINGS_SCRIPTBIND_SYSTEM_H