Spawn Entity with Custom Entity Class Refused

#1
This is my custom entity class header:

Code: Select all

#ifndef __SimpleEntity_H__ #define __SimpleEntity_H__ #include <IGameObject.h> class CSimpleEntity : public CGameObjectExtensionHelper<CSimpleEntity, IGameObjectExtension> { public: CSimpleEntity(void); ~CSimpleEntity(void); virtual void GetMemoryUsage(ICrySizer *pSizer) const{} virtual bool Init( IGameObject * pGameObject ); virtual void PostInit( IGameObject * pGameObject ); virtual void InitClient(int channelId) {} virtual void PostInitClient(int channelId) {} virtual bool ReloadExtension( IGameObject * pGameObject, const SEntitySpawnParams &params ) { return true; } virtual void PostReloadExtension( IGameObject * pGameObject, const SEntitySpawnParams &params ) { } virtual bool GetEntityPoolSignature( TSerialize signature ) { return true; } virtual void Release() {} virtual void FullSerialize( TSerialize ser ) {} virtual bool NetSerialize( TSerialize ser, EEntityAspects aspect, uint8 profile, int pflags ){ return true; } virtual NetworkAspectType GetNetSerializeAspects() { return eEA_All; } virtual void PostSerialize() {} virtual void SerializeSpawnInfo( TSerialize ser ) {} virtual ISerializableInfoPtr GetSpawnInfo() { ISerializableInfoPtr is; return is;} virtual void Update( SEntityUpdateContext& ctx, int updateSlot ); virtual void HandleEvent( const SGameObjectEvent& event ); virtual void ProcessEvent( SEntityEvent& event ); virtual void SetChannelId(uint16 id) {} virtual void SetAuthority( bool auth ) {} virtual void PostUpdate( float frameTime ) {} virtual void PostRemoteSpawn() {} }; #endif
and this is where I register the class in GameFactory:

Code: Select all

void InitGameFactory(IGameFramework *pFramework) { assert(pFramework); REGISTER_FACTORY(pFramework, "Actor", CActor, false); REGISTER_FACTORY(pFramework, "GameRules", CGameRules, false); REGISTER_GAME_OBJECT(pFramework, SimpleEntity, ""); }
and this is how I spawn the entity:

Code: Select all

SetGameObject(pGameObject); g_pGame->GetIGameFramework()->GetIGameRulesSystem()->SetCurrentGameRules(this); SEntitySpawnParams sp; IEntity* simpleEntity = 0; sp.pClass = gEnv->pEntitySystem->GetClassRegistry()->FindClass("SimpleEntity"); simpleEntity = gEnv->pEntitySystem->SpawnEntity(sp);
but the entity was not spawned. The log said: "Trying to spawn entity with no entity class. Spawning refused." I really have no idea why my class wasn't recognized. I followed 1Richmar tutorial to create custom entity in youtube but I used blank project so I used a minimum implementation of GameFactory. I omitted anything that I didn't need and only registered Actor, GameRules and my new game object class. Please help, I am clueless about what was wrong here.

Who is online

Users browsing this forum: No registered users and 1 guest