Esempio n. 1
0
IEntityProxyPtr CreateScriptProxy( CEntity* pEntity,IEntityScript* pScript,SEntitySpawnParams* pSpawnParams )
{
	// Load script now (Will be ignored if already loaded).
	CEntityScript* pEntityScript = (CEntityScript*)pScript;
	if (pEntityScript->LoadScript())
	{
		IEntityProxyPtr                                pScriptProxy = ComponentCreate_DeleteWithRelease<CScriptProxy>();
		CScriptProxy::SComponentInitializerScriptProxy initializer( pEntity, pEntityScript, pSpawnParams );
		pEntity->RegisterComponent( pScriptProxy, IComponent::EComponentFlags_Enable | IComponent::EComponentFlags_LazyRegistration );
		pScriptProxy->Initialize( initializer );
		return pScriptProxy;
	}

	return IEntityProxyPtr();
}
Esempio n. 2
0
bool CEntityClass::LoadScript( bool bForceReload )
{
	bool bRes = true;
	if (m_pEntityScript)
	{
		CEntityScript *pScript = (CEntityScript*)m_pEntityScript;
		bRes = pScript->LoadScript(bForceReload);

		m_bScriptLoaded = true;
	}

	if (m_pScriptFileHandler && bForceReload)
		m_pScriptFileHandler->ReloadScriptFile();

	if (m_pPropertyHandler && bForceReload)
		m_pPropertyHandler->RefreshProperties();

	if (m_pEventHandler && bForceReload)
		m_pEventHandler->RefreshEvents();

	return bRes;
}
Esempio n. 3
0
void CScriptProxy::Reload( IEntity* pEntity,SEntitySpawnParams &params )
{
	FUNCTION_PROFILER( GetISystem(), PROFILE_ENTITY );

	IEntityClass*  pClass        = (pEntity ? pEntity->GetClass() : NULL);
	CEntityScript* pEntityScript = (pClass ? (CEntityScript*)pClass->GetIEntityScript() : NULL);
	if (pEntityScript && pEntityScript->LoadScript())
	{
		// Release current
		SAFE_RELEASE(m_pThis);

		m_pEntity                = (CEntity*)pEntity;
		m_pScript                = pEntityScript;
		m_nCurrStateId           = 0;
		m_fScriptUpdateRate      = 0;
		m_fScriptUpdateTimer     = 0;
		m_bEnableSoundAreaEvents = false;

		m_bUpdateScript = CurrentState()->IsStateFunctionImplemented(ScriptState_OnUpdate);

		// New object must be created here.
		CreateScriptTable(&params);
	}
}