コード例 #1
0
ファイル: EntityClass.cpp プロジェクト: amrhead/eaascode
IScriptTable* CEntityClass::GetScriptTable() const
{
	IScriptTable *pScriptTable = NULL;

	if (m_pEntityScript)
	{
		CEntityScript *pScript = (CEntityScript*)m_pEntityScript;
		pScriptTable = (pScript ? pScript->GetScriptTable() : NULL);
	}

	return pScriptTable;
}
コード例 #2
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
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();
}
コード例 #3
0
IEntityClass* CEntityClassRegistry::RegisterStdClass( const SEntityClassDesc &entityClassDesc )
{
	// Creates a new entity class.
	CEntityClass *pClass = new CEntityClass;
	pClass->SetName(entityClassDesc.sName);
	pClass->SetFlags(entityClassDesc.flags);
	pClass->SetScriptFile(entityClassDesc.sScriptFile);
	pClass->SetUserProxyCreateFunc(entityClassDesc.pUserProxyCreateFunc, entityClassDesc.pUserProxyData);
	pClass->SetPropertyHandler(entityClassDesc.pPropertyHandler);
	pClass->SetEventHandler(entityClassDesc.pEventHandler);
	pClass->SetScriptFileHandler(entityClassDesc.pScriptFileHandler);
	pClass->SetEditorClassInfo(entityClassDesc.editorClassInfo);
	pClass->SetClassAttributes(entityClassDesc.classAttributes);
	pClass->SetEntityAttributes(entityClassDesc.entityAttributes);

	// Check if need to create entity script.
	if (entityClassDesc.sScriptFile[0] || entityClassDesc.pScriptTable)
	{
		// Create a new entity script.
		CEntityScript *pScript = new CEntityScript;
		bool ok = false;
		if(entityClassDesc.sScriptFile[0])
			ok = pScript->Init(entityClassDesc.sName,entityClassDesc.sScriptFile);
		else 
			ok = pScript->Init(entityClassDesc.sName, entityClassDesc.pScriptTable);
		
		if(!ok)
		{
			EntityWarning( "EntityScript %s failed to initialize",entityClassDesc.sScriptFile );
			pScript->Release();
			pClass->Release();
			return NULL;
		}
		pClass->SetEntityScript( pScript );
	}

	if (!RegisterEntityClass( pClass ))
	{
		// Register class failed.
		pClass->Release();
		return NULL;
	}
	return pClass;
}
コード例 #4
0
ファイル: EntityClass.cpp プロジェクト: amrhead/eaascode
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;
}
コード例 #5
0
ファイル: ScriptProxy.cpp プロジェクト: joewan/pycmake
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);
	}
}