Seralise a list on a component

Hi all,

Recently started picking up CryEngine and I've hit my first big hurdle when trying to seralise a std::vector<T> on a component. I found a similar use case in the engine code for the AI navigation waypoint component and tried replicating it but when adding the component to an entity in the editor it does not give me the option to add to the vector.

Here's some relevant code:

Code: Select all

struct SGas { inline bool operator==(const SGas& r) const { return 0 == memcmp(this, &r, sizeof(r)); } inline bool operator!=(const SGas& r) const { return 0 != memcmp(this, &r, sizeof(r)); } static void ReflectType(Schematyc::CTypeDesc<SGas>& d) { d.SetGUID("{8C25621F-7E28-4655-AB2A-F4F0691E4322}"_cry_guid); d.SetLabel("Gas"); d.SetDescription("A Gas"); d.AddMember(&SGas::m_name, 'name', "GasName", "Gas Name", "The name of the Gas", ""); d.AddMember(&SGas::m_gasSymbol, 'symb', "GasSymbol", "Gas Symbol", "The molecular symbol of the Gas", ""); d.AddMember(&SGas::m_atmoComp, 'comp', "AtmoComp", "Atmo Comp", "What percent of the atmosphere the gas occupies", 0.f); } Schematyc::CSharedString m_name; Schematyc::CSharedString m_gasSymbol; float m_atmoComp; };

Code: Select all

struct SGasArray { inline bool operator==(const SGasArray& r) const { return 0 == memcmp(this, &r, sizeof(r)); } inline bool operator!=(const SGasArray& r) const { return 0 != memcmp(this, &r, sizeof(r)); } static void ReflectType(Schematyc::CTypeDesc<SGasArray>& d) { d.SetGUID("{1040CB20-F06F-45A4-8CC7-82A1113D43BD}"_cry_guid); d.AddMember(&SGasArray::m_gasses, 'gass', "Gasses", "Gasses", nullptr, std::vector<SGas>()); } std::vector<SGas> m_gasses; }; };
Then the component I'm trying to add `SGasArray` to

Code: Select all

class CRoomContainer final : public IEntityComponent { public: CRoomContainer() = default; virtual ~CRoomContainer() = default; inline bool operator==(const CRoomContainer& r) const { return 0 == memcmp(this, &r, sizeof(r)); } inline bool operator!=(const CRoomContainer& r) const { return 0 != memcmp(this, &r, sizeof(r)); } static void ReflectType(Schematyc::CTypeDesc<CRoomContainer>& d) { d.SetGUID("{515206F3-EC04-47C6-9D9B-77B52B3CCF79}"_cry_guid); d.SetEditorCategory("Room"); d.SetLabel("Room Container"); d.AddMember(&CRoomContainer::m_gasses, 'gas', "Gas", "Gas", nullptr, CAtmosphereData::SGasArray()); } virtual void Initialize() override; virtual void ProcessEvent(const SEntityEvent& e) override; Cry::Entity::EventFlags GetEventMask() const override; CAtmosphereData::SGasArray m_gasses; };
Thanks in advance,


Re: Seralise a list on a component

use Schematyc::CArray instead.

check Galaxsys_Sample_Project. this is the case

Code: Select all

class CEnemySpawner : public IEntityComponent { public: struct SEnemyDefinition { friend class CEnemySpawner; static void ReflectType(Schematyc::CTypeDesc<SEnemyDefinition>& desc) { desc.SetLabel("Enemy Definition"); desc.SetDescription("Describes an enemy that can be activated/spawned by the spawner component."); desc.SetGUID("{267F79B6-66B1-47CE-93C6-A74A0E628289}"_cry_guid); desc.AddMember(&SEnemyDefinition::m_enabled, 'enab', "Enabled", "Enabled", "Whether this spawn type is enabled.", false); desc.AddMember(&SEnemyDefinition::m_spawnId, 'spid', "SpawnId", "Spawn Type Id", "Identifier of this spawn type.", ""); desc.AddMember(&SEnemyDefinition::m_entityClass, 'scls', "EntityClass", "Entity Class", "Entity class type of this enemy spawn.", ""); desc.AddMember(&SEnemyDefinition::m_spawnInterval, 'spni', "SpawnInterval", "Spawn Interval", "Time in seconds between each spawn.", 1.f); } inline bool Serialize(Serialization::IArchive& archive); inline bool operator==(const SEnemyDefinition& rhs) const { return 0 == memcmp(this, &rhs, sizeof(rhs)); } inline bool operator!=(const SEnemyDefinition& rhs) const { return !(*this == rhs); } bool m_enabled = false; Schematyc::CSharedString m_spawnId = ""; Schematyc::EntityClassName m_entityClass = ""; float m_spawnInterval = 1.f; CControllableTimer* m_pTimer = nullptr; }; typedef Schematyc::CArray<SEnemyDefinition> TEnemyList; CEnemySpawner() = default; virtual ~CEnemySpawner() override; static void ReflectType(Schematyc::CTypeDesc<CEnemySpawner>& desc) { desc.SetLabel("Enemy Spawner"); desc.SetEditorCategory("Enemies"); desc.SetDescription("Controls the spawning of enemy entities in the playable area."); desc.SetGUID("{A10A2857-A603-428E-8836-947F6F53AC14}"_cry_guid); desc.SetComponentFlags({ IEntityComponent::EFlags::Singleton }); desc.AddMember(&CEnemySpawner::m_enemyList, 'elst', "EnemyList", "Enemy List", "List of enemies assigned to the enemy spawner", TEnemyList()); } private: TEnemyList m_enemyList = TEnemyList(); };

Who is online

Users browsing this forum: No registered users and 0 guests