static ETgMODULE_STATE s_enExecute_State = ETgMODULE_STATE_FREED;
TgRESULT tgEX_Init_Module()
{
TgASSERT(ETgMODULE_STATE_FREED == s_enExecute_State);
s_enExecute_State = ETgMODULE_STATE_INITIALIZING;
if (TgFAILED(tgGB_Init()))
{
return (TgE_FAIL);
};
tgEX_PM_Init_Module();
if (TgFAILED(tgKN_Init_Module()))
goto Fail_Init_GB;
if (TgFAILED(tgIN_Init_Module()))
goto Fail_Init_KN;
if (TgFAILED(tgSN_Init_Module()))
goto Fail_Init_IN;
if (TgFAILED(tgRN_Init_Module()))
goto Fail_Init_SN;
if (TgFAILED(tgFX_Init_Module()))
goto Fail_Init_RN;
if (TgFAILED(tgPH_Init_Module()))
goto Fail_Init_FX;
if (TgFAILED(tgAM_Init_Module()))
goto Fail_Init_PH;
if (TgFAILED(tgOB_Init_Module()))
goto Fail_Init_AM;
if (TgFAILED(tgSE_Init_Module()))
goto Fail_Init_OT;
s_enExecute_State = ETgMODULE_STATE_INITIALIZED;
return (TgS_OK);
Fail_Init_OT: tgOB_Free_Module();
Fail_Init_AM: tgAM_Free_Module();
Fail_Init_PH: tgPH_Free_Module();
Fail_Init_FX: tgFX_Free_Module();
Fail_Init_RN: tgRN_Free_Module();
Fail_Init_SN: tgSN_Free_Module();
Fail_Init_IN: tgIN_Free_Module();
Fail_Init_KN: tgKN_Free_Module();
Fail_Init_GB: tgEX_PM_Free_Module();
tgGB_Free();
return (TgE_FAIL);
}
TgRESULT tgEX_Boot_Module()
{
TgASSERT(ETgMODULE_STATE_INITIALIZED == s_enExecute_State);
s_enExecute_State = ETgMODULE_STATE_BOOTING;
TgLOGF( ETgCON_CHANEL_MESSAGE, TgT("%-16.16s(%-32.32s): %-48.48s % 14d\n"), TgT("Execute"), TgT("Boot_Module"),
TgT("Static Memory Size"), tgEX_Query_Fixed_Memory() );
if (TgFAILED(tgGB_Boot()))
{
return (TgE_FAIL);
};
tgEX_PM_Boot_Module();
if (TgFAILED(tgKN_Boot_Module()))
goto Fail_Boot_GB;
if (TgFAILED(tgIN_Boot_Module()))
goto Fail_Boot_KN;
if (TgFAILED(tgSN_Boot_Module()))
goto Fail_Boot_IN;
if (TgFAILED(tgRN_Boot_Module()))
goto Fail_Boot_SN;
if (TgFAILED(tgFX_Boot_Module()))
goto Fail_Boot_RN;
if (TgFAILED(tgPH_Boot_Module()))
goto Fail_Boot_FX;
if (TgFAILED(tgAM_Boot_Module()))
goto Fail_Boot_PH;
if (TgFAILED(tgOB_Boot_Module()))
goto Fail_Boot_AM;
if (TgFAILED(tgSE_Boot_Module()))
goto Fail_Boot_OT;
s_enExecute_State = ETgMODULE_STATE_BOOTED;
return (TgS_OK);
Fail_Boot_OT: tgOB_Stop_Module();
Fail_Boot_AM: tgAM_Stop_Module();
Fail_Boot_PH: tgPH_Stop_Module();
Fail_Boot_FX: tgFX_Stop_Module();
Fail_Boot_RN: tgRN_Stop_Module();
Fail_Boot_SN: tgSN_Stop_Module();
Fail_Boot_IN: tgIN_Stop_Module();
Fail_Boot_KN: tgKN_Stop_Module();
Fail_Boot_GB: tgEX_PM_Stop_Module();
tgGB_Stop();
return (TgE_FAIL);
}
TgVOID tgEX_Stop_Module()
{
TgASSERT(ETgMODULE_STATE_BOOTED == s_enExecute_State);
s_enExecute_State = ETgMODULE_STATE_STOPPING;
tgSE_Stop_Module();
tgOB_Stop_Module();
tgAM_Stop_Module();
tgPH_Stop_Module();
tgFX_Stop_Module();
tgRN_Stop_Module();
tgSN_Stop_Module();
tgIN_Stop_Module();
tgKN_Stop_Module();
tgEX_PM_Stop_Module();
tgGB_Stop();
s_enExecute_State = ETgMODULE_STATE_STOPPED;
}
TgVOID tgEX_Free_Module()
{
TgASSERT(ETgMODULE_STATE_STOPPED == s_enExecute_State || ETgMODULE_STATE_INITIALIZED == s_enExecute_State);
s_enExecute_State = ETgMODULE_STATE_FREEING;
tgSE_Free_Module();
tgOB_Free_Module();
tgAM_Free_Module();
tgPH_Free_Module();
tgFX_Free_Module();
tgRN_Free_Module();
tgSN_Free_Module();
tgIN_Free_Module();
tgKN_Free_Module();
tgEX_PM_Free_Module();
tgGB_Free();
s_enExecute_State = ETgMODULE_STATE_FREED;
}
TgRESULT tgEX_Update_Module( C_TgFLOAT32 fDt )
{
tgIN_Update_Module( fDt );
tgKN_Update_Module( fDt );
//// Camera is updated at the start of the game loop so that render image queries done by the game systems are valid for the
//// resulting image produced by the render. This way game code can test for visibility in the image and other image specific
//// queries when attempting to load balance.
////tgST_Update_Camera( fDt );
//// Update the scripting system. Scripting has to be done before actor processing so that render changes can correctly
//// be taken into account during actor processing.
////tgSC_Update_Module( fDt ); //« Update Script System
//// TBD: Elements of the set may need updating. This may allow for some dynamic actions in the static set without having
//// to turn the element into a loaded object.
//// Update the primary AI system. A master AI controller can be very useful in dispatching deferred AI tasks. As well
//// this can allow for an over watch of multiple AIs to provide higher order behaviors. This is the last mechanism by
//// which input is passed into a game object/actor.
////tgAI_Update_AI( fDt ); //« Primary AI Loop
//// Build the current list of all the processing and rendering objects. Objects may have their desired processing state
//// changed by either the input systems or set logic. If this request is approved by the object and the system then at
//// the end of this frame the object will have its state changed. This may cause resources to be released and is not
//// considered to be a light-weight change.
////tgSE_Build_Lists();
//// Movement and Animation //
//// This section is set up to be pipelined to allow for maximum concurrency.
//// The animation system processes the active entities given the animation state to determine a predictive motion. This
//// is done by calculating the movement of only the "pivot" bone - as set by the controlling actor code.
////tgAM_Update_Prediction();
//// Update the pathing system with the desired motion computed from the animation system or set by higher level logic.
////tgAI_Update_Pathing();
//// Objects that are not contained by the normal motion execution update their desired physical volumes. This is also
//// where those physical volumes that are not swept but need to be warped/slammed to their location should verify that
//// the desired location is valid. This would also be the point where any external non simulated factors can apply
//// physical affects to the world. For instance this would be the location where a wind object may influence the world
//// or a gravity controller can alter the force field.
////tgST_Update_Simulation( fDt );
//// The primary physics loop is performed synchronously with the game loop. This is required to provide some of the desired
//// final reactions in the game. For instance, use of the rag doll system in physical animation blends require the system
//// to be update with the animation system to reduce the amount of possible popping that may occur. However, it is possible
//// and is quite likely that the effects physical world will be processed asynchronously and at a lower frequency than the
//// primary loop for load balancing reasons.
//// The position of the actors is updated based on the final positions as determined by the physics system. The resulting
//// position may be reprocessed by the actor code to allow for possible animation changes. It is up to the programmer to
//// make sure that any changes done at this point to the animation and/or the actor is a legal change. The primary use of
//// this reprocessing is to prevent the character from doing illogical animation action (like walking against a wall).
////tgST_Update_Movement( fDt );
//// Now that the final animation state has been determined it is necessary to generate all of the animation blends and
//// calculate the final skeleton.
////tgAM_Update_Animation( fDt );
//// Update the sound module.
////tgSN_Update( fDt );
//// With a data buffer the following two functions could be threaded off for multi-core
return (TgS_OK);
}
TgBOOL tgEX_Query_Init()
{
return (ETgMODULE_STATE_INITIALIZED <= s_enExecute_State && s_enExecute_State <= ETgMODULE_STATE_STOPPED);
}
TgBOOL tgEX_Query_Boot()
{
return (ETgMODULE_STATE_BOOTED == s_enExecute_State);
}
TgVOID tgEX_Load_Config_BIN()
{
}
TgVOID tgEX_Load_Config_TXT()
{
}
TgVOID tgEX_Save_Config_BIN()
{
}
TgVOID tgEX_Save_Config_TXT()
{
}