I'm a bit confused about your question - you talk first about WeaponComponent, which already registered and can be used, but then you have problems registering CBaseMeshComponent? Or is it about automatically getting CBaseMeshComponent in entity, which already has WeaponComponent?
I assume it's second, but let's go in steps to be sure:
1. Registering CBaseMeshComponent component
Code: Select all
scope.Register(SCHEMATYC_MAKE_ENV_COMPONENT(CBaseMeshComponent));
tells engine, that there is such entity component and it can also be used in schematyc. To be registered this way, component has to have static ReflectType() function - hence the error you get. So, yes - you have to write this function yourself. See for example StaticMesh component in CryDefaultEntities:
https://github.com/CRYTEK/CRYENGINE/blo ... nent.h#L28
Based on this example, minimal ReflectType function for your CBaseMeshComponent component would probably look something like this:
Code: Select all
static void ReflectType(Schematyc::CTypeDesc<CBaseMeshComponent>& desc)
{
desc.SetGUID("{___replace_me_with_correct_guid___}"_cry_guid);
desc.AddMember(&CBaseMeshComponent::m_filePath, 'file', "FilePath", "File", "Determines the CGF to load", "%ENGINE%/EngineAssets/Objects/Default.cgf");
}
Now you should be able to add component to any preplaced entity on the level and see your component properties.
2. Automatically getting CBaseMeshComponent to exist in entity together with WeaponComponent
It seems you would like to establish a dependency between components. Luckily, when you reflect your WeaponComponent, you can write:
Code: Select all
desc.AddComponentInteraction(SEntityComponentRequirements::EType::HardDependency, "{__guid_of_CBaseMeshComponent__}"_cry_guid);
This way engine makes sure, that whenever entity has WeaponComponent, it also has CBaseMeshComponent. And it's guaranteed that CBaseMeshComponent is initialized first. So then WeaponComponent can use GetComponent<CBaseMeshComponent> - it's already there.
Apart from HardDependency, there is also SoftDependency - component is not required, but if it's there - initialize it first.
Now, you say, that you already got working WeaponComponent. Was it registered with the new API (SCHEMATYC_MAKE_ENV_COMPONENT and ReflectType)? If no - then I'm not sure, that there was similar component dependency functionality before. You may want to change registration code or consider different options (entity classes with custom entity spawning callback). And if yes - then why registration of CBaseMeshComponent was an issue? ;)