Re: Schematyc functions

#2
Hello,

You have to reflect those functions separately. I will post an example below which should show the process.
Component.h:

Code: Select all

#pragma once #include <CryEntitySystem/IEntityComponent.h> #include <CryEntitySystem/IEntity.h> class CSpawnPointComponent final : public IEntityComponent { public: CSpawnPointComponent() = default; virtual ~CSpawnPointComponent() {} static void ReflectType(Schematyc::CTypeDesc<CSpawnPointComponent>& desc) { desc.SetGUID("{41316132-8A1E-4073-B0CD-A242FD3D2E90}"_cry_guid); desc.SetEditorCategory("Game"); desc.SetLabel("SpawnPoint"); desc.SetDescription("This spawn point can be used to spawn entities"); desc.SetComponentFlags({ IEntityComponent::EFlags::Transform, IEntityComponent::EFlags::Socket, IEntityComponent::EFlags::Attach }); } // The function you want to use in Schematyc. bool Foo(int a, float b) { } };


Component.cpp:

Code: Select all

#include "StdAfx.h" #include "SpawnPoint.h" #include <CrySchematyc/Reflection/TypeDesc.h> #include <CrySchematyc/Utils/EnumFlags.h> #include <CrySchematyc/Env/IEnvRegistry.h> #include <CrySchematyc/Env/IEnvRegistrar.h> #include <CrySchematyc/Env/Elements/EnvComponent.h> #include <CrySchematyc/Env/Elements/EnvFunction.h> #include <CrySchematyc/Env/Elements/EnvSignal.h> #include <CrySchematyc/ResourceTypes.h> #include <CrySchematyc/MathTypes.h> #include <CrySchematyc/Utils/SharedString.h> static void RegisterSpawnPointComponent(Schematyc::IEnvRegistrar& registrar) { Schematyc::CEnvRegistrationScope scope = registrar.Scope(IEntity::GetEntityScopeGUID()); { Schematyc::CEnvRegistrationScope componentScope = scope.Register(SCHEMATYC_MAKE_ENV_COMPONENT(CSpawnPointComponent)); // Functions { auto pFunction = SCHEMATYC_MAKE_ENV_FUNCTION(&CSpawnPointComponent::Foo, "{40F9CF4D-EC81-47B3-B9A5-46F6441FD543}"_cry_guid, "Foo"); pFunction->SetDescription("Description of your function"); pFunction->SetFlags({ Schematyc::EEnvFunctionFlags::Member, Schematyc::EEnvFunctionFlags::Construction }); pFunction->BindInput(1, 'fir', "FirstVar"); pFunction->BindInput(2, 'sec', "SecondVar"); pFunction->BindOutput(0, 'ret' "ReturnVar") componentScope.Register(pFunction); } } } CRY_STATIC_AUTO_REGISTER_FUNCTION(&RegisterSpawnPointComponent)
Keep in mind that every function needs an unique id. If you have more questions let me know.

Cheers,
Alex

Re: Schematyc functions

#5
Hello,

From a technical point of view the EntityId is just an integer at the end, but if you want to have it explicit you can add that information at the end of the BindInput function.

Code: Select all

pFunction->BindInput(1, 'eid', "EntityId", "", Schematyc::ExplicitEntityId());
Cheers,
Alex

Re: Schematyc functions

#7
Hi,

Whenever the function gets called from schematyc it just throws an error saying "Exception thrown: read access violation. **param1** was nullptr." And it points me to the EnvFunction.h file and this function:

Code: Select all

static void Stub(const SBinding& binding, CRuntimeParamMap& params, void* pObject) { typename SParamTraits<PARAM1>::ProxyType param1 = ReadParam<PARAM1>(binding, 1, params); FunctionPtr pFunction = *reinterpret_cast<const FunctionPtr*>(binding.pFunction); (static_cast<OBJECT*>(pObject)->*pFunction)(param1); //Error here }
I can't figure out why this is happening. My function is registered like this:

Code: Select all

auto pEntering = SCHEMATYC_MAKE_ENV_FUNCTION(&CInfectedAreaComponent::Entering, "{C0D4C3C9-8099-4CD7-B1FE-EC3043A36E6F}"_cry_guid, "Entering"); pEntering->SetDescription("Should be called when player is entering an area"); pEntering->SetFlags({ Schematyc::EEnvFunctionFlags::Member }); pEntering->BindInput(1, 'eid', "EntityId", "The entity id of the player entering", Schematyc::ExplicitEntityId()); componentScope.Register(pEntering);
Anyone who knows why this happens?

Thanks!

Who is online

Users browsing this forum: mknmknmknjk and 3 guests