Cry::IEnginePlugin

#include

Inherits ICryUnknown.

Inherited by ICryUserAnalyticsPlugin.

Public Types

enum EUpdateStep : uint8 {
BeforeSystem = 1 << 0, BeforePhysics = 1 << 1, MainUpdate = 1 << 2, BeforeFinalizeCamera = 1 << 3,
BeforeRender = 1 << 4, AfterRender = 1 << 5, AfterRenderSubmit = 1 << 6, Count = 7
}

Public Member Functions

CRYINTERFACE_DECLARE_GUID (IEnginePlugin, "f491a0db-3863-4fca-b6e6-bcfe2d98eea2"_cry_guid)
virtual const char * GetName () const
Used to check the name of the plug-in, by default returns the string specified with CRYGENERATE_CLASS_GUID or CRYGENERATE_SINGLETONCLASS_GUID.
virtual const char * GetCategory () const
Used to check what category this plug-in belongs to.
virtual bool Initialize (SSystemGlobalEnvironment &env, const SSystemInitParams &initParams)=0
Called shortly after plug-in load when the plug-in is expected to initialize all its systems.
virtual void UpdateBeforeSystem ()
virtual void UpdateBeforePhysics ()
virtual void MainUpdate (float frameTime)
virtual void UpdateBeforeFinalizeCamera ()
virtual void UpdateBeforeRender ()
virtual void UpdateAfterRender ()
virtual void UpdateAfterRenderSubmit ()
virtual bool RegisterFlowNodes ()
virtual bool UnregisterFlowNodes ()

Protected Member Functions

void EnableUpdate (EUpdateStep step, bool enable)

Protected Attributes

std::vector< TFlowNodeTypeId > m_registeredFlowNodeIds

Detailed Description

Represents an engine plug-in that can be loaded as a dynamic library, or statically linked in. Plug-ins are loaded from JSON in your .cryproject file on engine startup. For a fully functional example, see Code.

#include 

// Minimal plug-in implementation example, initializing and receiving per-frame Update callbacks
class CMyPlugin final : public Cry::IEnginePlugin
{
    // Start declaring the inheritance hierarchy for this plug-in
    // This is followed by any number of CRYINTERFACE_ADD, passing an interface implementing ICryUnknown that has declared its own GUID using CRYINTERFACE_DECLARE_GUID
    CRYINTERFACE_BEGIN()
    // Indicate that we implement Cry::IEnginePlugin, this is mandatory in order for the plug-in instance to be detected after the plug-in has been loaded
    CRYINTERFACE_ADD(Cry::IEnginePlugin)
    // End the declaration of inheritance hierarchy
    CRYINTERFACE_END()

    // Set the GUID for our plug-in, this should be unique across all used plug-ins
    // Can be generated in Visual Studio under Tools -> Create GUID
    CRYGENERATE_SINGLETONCLASS_GUID(CMyPlugin, "MyPluginName", "{0C7B8742-5FBF-4C48-AE7C-6E70308538EC}"_cry_guid)

    // Called shortly after loading the plug-in from disk
    // This is usually where you would initialize any third-party APIs and custom code
    virtual bool Initialize(SSystemGlobalEnvironment& env, const SSystemInitParams& initParams) override
    {
        /* Initialize plug-in here */

        // Make sure that we receive per-frame call to MainUpdate
        EnableUpdate(IEnginePlugin::EUpdateStep::MainUpdate, true);

        return true;
    }

    virtual void MainUpdate(float frameTime) override
    {
        /* Perform update here */
    }
};

// Register the factory that can create this plug-in instance
// Note that this has to be done in a source file that is not included anywhere else.
CRYREGISTER_SINGLETON_CLASS(CMyPlugin)

Member Enumeration Documentation

◆ EUpdateStep

enum Cry::IEnginePlugin::EUpdateStep : uint8
strong

Used to determine what type of updates a plug-in interested in, treated as bit flags This enumeration is ordered in the same order as the functions are called each frame

Member Function Documentation

◆ EnableUpdate()

void Cry::IEnginePlugin::EnableUpdate ( EUpdateStep step,
bool enable
)
inline
protected

Enables a particular update step to be called each frame on this plug-in

#include 

// Minimal plug-in implementation example, initializing and receiving per-frame Update callbacks
class CMyPlugin final : public Cry::IEnginePlugin
{
    // Start declaring the inheritance hierarchy for this plug-in
    // This is followed by any number of CRYINTERFACE_ADD, passing an interface implementing ICryUnknown that has declared its own GUID using CRYINTERFACE_DECLARE_GUID
    CRYINTERFACE_BEGIN()
    // Indicate that we implement Cry::IEnginePlugin, this is mandatory in order for the plug-in instance to be detected after the plug-in has been loaded
    CRYINTERFACE_ADD(Cry::IEnginePlugin)
    // End the declaration of inheritance hierarchy
    CRYINTERFACE_END()

    // Set the GUID for our plug-in, this should be unique across all used plug-ins
    // Can be generated in Visual Studio under Tools -> Create GUID
    CRYGENERATE_SINGLETONCLASS_GUID(CMyPlugin, "MyPluginName", "{0C7B8742-5FBF-4C48-AE7C-6E70308538EC}"_cry_guid)

    // Called shortly after loading the plug-in from disk
    // This is usually where you would initialize any third-party APIs and custom code
    virtual bool Initialize(SSystemGlobalEnvironment& env, const SSystemInitParams& initParams) override
    {
        /* Initialize plug-in here */

        // Make sure that we receive per-frame call to MainUpdate
        EnableUpdate(IEnginePlugin::EUpdateStep::MainUpdate, true);

        return true;
    }

    virtual void MainUpdate(float frameTime) override
    {
        /* Perform update here */
    }
};

// Register the factory that can create this plug-in instance
// Note that this has to be done in a source file that is not included anywhere else.
CRYREGISTER_SINGLETON_CLASS(CMyPlugin)

◆ MainUpdate()

virtual void Cry::IEnginePlugin::MainUpdate ( float frameTime)
inline
virtual

Called after ISystem has been updated, this is the main update where most game logic is expected to occur This is the default update that should be preferred if you don't need any special behavior Called on a plug-in if it has called EnableUpdate(EUpdateStep::MainUpdate, true)

◆ RegisterFlowNodes()

virtual bool Cry::IEnginePlugin::RegisterFlowNodes ( )
inline
virtual

Called when the plug-in should register all its flow nodes Automated version can be enabled using the PLUGIN_FLOWNODE_REGISTER macro

◆ UnregisterFlowNodes()

virtual bool Cry::IEnginePlugin::UnregisterFlowNodes ( )
inline
virtual

Called when the plug-in should unregister all its flow nodes Automated version can be enabled using the PLUGIN_FLOWNODE_UNREGISTER macro

◆ UpdateAfterRender()

virtual void Cry::IEnginePlugin::UpdateAfterRender ( )
inline
virtual

Called after we have submitted the render request to the render thread Called on a plug-in if it has called EnableUpdate(EUpdateStep::AfterRender, true)

◆ UpdateAfterRenderSubmit()

virtual void Cry::IEnginePlugin::UpdateAfterRenderSubmit ( )
inline
virtual

Called after the renderer has submitted the frame to the output device Called on a plug-in if it has called EnableUpdate(EUpdateStep::AfterRenderSubmit, true)

◆ UpdateBeforeFinalizeCamera()

virtual void Cry::IEnginePlugin::UpdateBeforeFinalizeCamera ( )
inline
virtual

Called immediately before the camera is considered finalized and passed on to occlusion culling Called on a plug-in if it has called EnableUpdate(EUpdateStep::BeforeFinalizeCamera, true)

◆ UpdateBeforePhysics()

virtual void Cry::IEnginePlugin::UpdateBeforePhysics ( )
inline
virtual

Called before physics is updated for the new frame, best point for queuing physics jobs Called on a plug-in if it has called EnableUpdate(EUpdateStep::BeforePhysics, true)

◆ UpdateBeforeRender()

virtual void Cry::IEnginePlugin::UpdateBeforeRender ( )
inline
virtual

Called before we begin rendering the scene Called on a plug-in if it has called EnableUpdate(EUpdateStep::BeforeRender, true)

◆ UpdateBeforeSystem()

virtual void Cry::IEnginePlugin::UpdateBeforeSystem ( )
inline
virtual

Earliest point of update in a frame, before ISystem itself is updated Called on a plug-in if it has called EnableUpdate(EUpdateStep::BeforeSystem, true)