Page 1 of 2

is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Wed Jul 25, 2018 7:00 pm
by grb1212
the goal would be to make a bool logic signal so the FG functions could be trigger from schematyc using a schematyc library signal

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Wed Jul 25, 2018 8:50 pm
by fury22uk
I havent touched flowgraph in months, but I know there is very simple way of calling flowgraph modules from C++. So you could create flowgraph module, and then call it from the component that you want. Passing whatever you want to this module.

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Wed Jul 25, 2018 10:48 pm
by grb1212
a simple bool bridge between FG and schematyc would be great for those of us who do not have the time or resources, if my 2 person team ever publishes our current project it will be for free and for fun, we both work an when we have time try and learn more about coding, but having little time to learn so much the flow graph is useful for basic function that don't require a lot of flow graphing.





I havent touched flowgraph in months, but I know there is very simple way of calling flowgraph modules from C++. So you could create flowgraph module, and then call it from the component that you want. Passing whatever you want to this module.

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Thu Jul 26, 2018 1:16 am
by mknmknmknjk
get luascriptComponent

auto* pComponent = static_cast<CEntityComponentLuaScript*>(pEntity->GetComponent<IEntityScriptComponent>())

IEntityScriptComponent* pScriptProxy = static_cast<IEntityScriptComponent*>(pR->GetEntity()->GetProxy(ENTITY_PROXY_SCRIPT));

old
https://github.com/CRYTEK/CRYENGINE/blo ... d_Entity.h

http://docs.cryengine.com/display/CEPRO ... +Reference

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Thu Jul 26, 2018 3:20 am
by mknmknmknjk
call lua function

Code: Select all

void CGameRulesStandardRounds::CallScript( EntityId entityId, const char *pFunction ) { IEntity *pEntity = gEnv->pEntitySystem->GetEntity(entityId); if (pEntity) { IScriptTable *pScriptTable = pEntity->GetScriptTable(); if (pScriptTable) { if (pScriptTable->GetValueType(pFunction) == svtFunction) { IScriptSystem *pScriptSystem = gEnv->pScriptSystem; pScriptSystem->BeginCall(pScriptTable, pFunction); pScriptSystem->PushFuncParam(pScriptTable); pScriptSystem->EndCall(); } } } }

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Thu Jul 26, 2018 5:54 am
by mknmknmknjk

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Fri Jul 27, 2018 11:55 am
by grb1212
ive never wrote code into any engine, no clue where to even start most of my studying has been terminology, and syntax.

is there any way one could add the ability for a schematyc node that writes a value to xml.

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Fri Jul 27, 2018 1:20 pm
by mknmknmknjk

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Fri Jul 27, 2018 8:01 pm
by grb1212
i thank you for the information, unfortunately idk no what to do with it.

i was hoping some kind person out there would have something that all i have to do is copy it some where in engine and bam any schematyc entity could send a bool signal to the flowgraph.

Crytek should make this possible and consider keeping FG around even if the sdk is totally dropped in future versions

id like to have a schematyc entity send a signal to FG when the schematyc's particle emitter is activated .

Re: is there anyone who could make a way to send a basic bool signal from schematyc to FG

Posted: Tue Jul 31, 2018 4:31 pm
by Cry-Flare
Hey grb1212, this does seem to be requested a far amount so let me help you out a bit here.

First, you will need to install Visual Studio, I recommend 2017 Community edition. Be sure to follow the documentation with regards to the pre-requisites.

Next, you will want to create a "C++ Plugin" template from the CRYENGINE Launcher.

Follow the documentation regarding generating a solution and compiling and running the template project. If all goes well, you can modify the code like so;

Plugin.h

Code: Select all

#pragma once

#include <CrySystem/ICryPlugin.h>

#include <CryFlowGraph/IFlowBaseNode.h>
#include <CrySchematyc/CoreAPI.h>
#include <CrySchematyc/Env/IEnvRegistrar.h>

class CPlugin
: public Cry::IEnginePlugin
, public ISystemEventListener
{
public:
CRYINTERFACE_SIMPLE(Cry::IEnginePlugin)
CRYGENERATE_SINGLETONCLASS_GUID(CPlugin, "MyPlugin", "2711a23d-3848-4cdd-a95b-e9d88ffa23b0"_cry_guid)

PLUGIN_FLOWNODE_REGISTER
PLUGIN_FLOWNODE_UNREGISTER

virtual ~CPlugin();

// Cry::IEnginePlugin
virtual bool Initialize(SSystemGlobalEnvironment& env, const SSystemInitParams& initParams) override;
// ~Cry::IEnginePlugin

// ISystemEventListener
virtual void OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam) override;
// ~ISystemEventListener
};

// Interface to allow classes to register as a receiver for signals sent
// by the Flow Graph Signal component
class ISchematycReceiver
{
public:
virtual void OnSchematycSignal(string& name) = 0;
};

// Used to track registration and de-registration of ISchematycReceiver
// implementors.
class CSchematycTransmitter
{
public:
CSchematycTransmitter() = delete;
CSchematycTransmitter(CSchematycTransmitter*) = delete;

static void RegisterSchematycReceiver(ISchematycReceiver* pReceiver)
{
m_receivers.insert(pReceiver);
}

static void UnregisterSchematycReceiver(ISchematycReceiver* pReceiver)
{
m_receivers.erase(pReceiver);
}

static void Transmit(const char* name)
{
for (auto pReceiver : m_receivers)
pReceiver->OnSchematycSignal(string(name));
}

private:
static std::set<ISchematycReceiver*> m_receivers;
};

// Component that sends named signals through the CSchematycTransmitter to
// registered inheritors of ISchematycReceiver
class CFlowGraphTransmitComponent
: public IEntityComponent
{
protected:

// IEntityComponent
virtual void ProcessEvent(const SEntityEvent& event) final {};
virtual uint64 GetEventMask() const final { return 0; };
// ~IEntityComponent

public:
virtual ~CFlowGraphTransmitComponent() {}
static void Register(Schematyc::IEnvRegistrar& registrar);
static void ReflectType(Schematyc::CTypeDesc<CFlowGraphTransmitComponent>& desc);

void SendSignal() { CSchematycTransmitter::Transmit(m_name.c_str()); }
void SetName(const char* szText) { m_name = szText; };
const char* GetName() const { return m_name.c_str(); }

protected:
Schematyc::CSharedString m_name;
};

// Flow Graph node implementing the ISchematycReceiver interface
// to allow flow Graph to receive signals from Schematyc components
class CFlowSchematycReceiverNode : public ISchematycReceiver, public CFlowBaseNode<eNCT_Instanced>
{
public:
CFlowSchematycReceiverNode(SActivationInfo* pActInfo);
~CFlowSchematycReceiverNode();

void GetConfiguration(SFlowNodeConfig& config);

// ISchematycReceiver
virtual void OnSchematycSignal(string& name) override;
// ~ISchematycReceiver

void ProcessEvent(EFlowEvent, SActivationInfo* pActInfo);
virtual void GetMemoryUsage(ICrySizer* s) const { s->Add(*this); }
virtual IFlowNodePtr Clone(SActivationInfo* pActInfo) override { return new CFlowSchematycReceiverNode(pActInfo); }

private:
string m_nameFilter;
SActivationInfo m_actInfo;
};

Plugin.cpp

Code: Select all

#include "StdAfx.h"
#include "Plugin.h"

// Included only once per DLL module.
#include <CryCore/Platform/platform_impl.inl>

//////////////////////////////////////////////////////////////////////
CPlugin::~CPlugin()
{
gEnv->pSystem->GetISystemEventDispatcher()->RemoveListener(this);

if (gEnv->pSchematyc)
{
gEnv->pSchematyc->GetEnvRegistry().DeregisterPackage(CPlugin::GetCID());
}
}

bool CPlugin::Initialize(SSystemGlobalEnvironment& env, const SSystemInitParams& initParams)
{
gEnv->pSystem->GetISystemEventDispatcher()->RegisterListener(this,"CPlugin");
return true;
}

void CPlugin::OnSystemEvent(ESystemEvent event, UINT_PTR wparam, UINT_PTR lparam)
{
switch (event)
{
case ESYSTEM_EVENT_REGISTER_SCHEMATYC_ENV:
{
auto staticAutoRegisterLambda = [](Schematyc::IEnvRegistrar& registrar)
{
Detail::CStaticAutoRegistrar<Schematyc::IEnvRegistrar&>::InvokeStaticCallbacks(registrar);
};

if (gEnv->pSchematyc)
{
gEnv->pSchematyc->GetEnvRegistry().RegisterPackage(
stl::make_unique<Schematyc::CEnvPackage>(
CPlugin::GetCID(),
"EntityComponents",
"Crytek GmbH",
"Components",
staticAutoRegisterLambda
)
);
}
}
break;
}
}
CRYREGISTER_SINGLETON_CLASS(CPlugin)

//////////////////////////////////////////////////////////////////////
void CFlowGraphTransmitComponent::ReflectType(Schematyc::CTypeDesc<CFlowGraphTransmitComponent>& desc)
{
desc.SetGUID("{9C255A6C-B3E2-4AF2-BDB4-9A6CC29E07D3}"_cry_guid);
desc.SetEditorCategory("Debug");
desc.SetLabel("Flow Graph Signal");
desc.SetDescription("Allows sending a named signal to all Schematyc:Receiver nodes");
desc.SetComponentFlags({ IEntityComponent::EFlags::ClientOnly });

desc.AddMember(&CFlowGraphTransmitComponent::m_name, 'text', "SignalName", "Signal Name", "Name sent ot flow Graph to differentiate between other signals", "");
}
void CFlowGraphTransmitComponent::Register(Schematyc::IEnvRegistrar& registrar)
{
Schematyc::CEnvRegistrationScope scope = registrar.Scope(IEntity::GetEntityScopeGUID());
{
Schematyc::CEnvRegistrationScope componentScope = scope.Register(SCHEMATYC_MAKE_ENV_COMPONENT(CFlowGraphTransmitComponent));
{
auto pFunction = SCHEMATYC_MAKE_ENV_FUNCTION(&CFlowGraphTransmitComponent::SendSignal, "{CC469973-B569-4DBC-8A37-316D81793719}"_cry_guid, "SendSignal");
pFunction->SetDescription("Sends a signal to the flow nodes");
pFunction->SetFlags(Schematyc::EEnvFunctionFlags::None);
componentScope.Register(pFunction);
}
}
}
std::set<ISchematycReceiver*> CSchematycTransmitter::m_receivers = {};
CRY_STATIC_AUTO_REGISTER_FUNCTION(&CFlowGraphTransmitComponent::Register)

//////////////////////////////////////////////////////////////////////
CFlowSchematycReceiverNode::CFlowSchematycReceiverNode(SActivationInfo* pActInfo) :
m_actInfo{0},
m_nameFilter{}
{
CSchematycTransmitter::RegisterSchematycReceiver(this);
}
CFlowSchematycReceiverNode::~CFlowSchematycReceiverNode()
{
CSchematycTransmitter::UnregisterSchematycReceiver(this);
}
void CFlowSchematycReceiverNode::GetConfiguration(SFlowNodeConfig& config)
{
static const SInputPortConfig in_ports[] =
{
InputPortConfig<string>("Filter", _HELP("Filter for the Schematyc signal name")),
{ 0 }
};

static const SOutputPortConfig out_ports[] =
{
OutputPortConfig_AnyType("Activated", _HELP("Activated when the signal has been recieved from Schematyc and the signal name matches")),
OutputPortConfig<string>("Name", _HELP("Name of the signal that was received")),
{ 0 }
};

config.pInputPorts = in_ports;
config.pOutputPorts = out_ports;
config.sDescription = _HELP("Allows receiving signals sent from the 'Flow Graph Signal' component");
config.SetCategory(EFLN_DEBUG);
}
void CFlowSchematycReceiverNode::ProcessEvent(EFlowEvent event, SActivationInfo* pActInfo)
{
m_actInfo = *pActInfo;

if (event == eFE_Activate || event == eFE_Initialize)
if (IsPortActive(pActInfo, 0))
m_nameFilter = GetPortString(pActInfo, 0);

}
void CFlowSchematycReceiverNode::OnSchematycSignal(string& name)
{
if (m_nameFilter.IsEmpty() || m_nameFilter == name)
{
ActivateOutput(&m_actInfo, 1, name);
ActivateOutput(&m_actInfo, 0, true);
}
}
REGISTER_FLOW_NODE("Schematyc:Receiver", CFlowSchematycReceiverNode);

Now after compiling and opening the project in the Sandbox editor, you can test it with something like;

ExampleSchematycEntity.png
ExampleSchematycEntity.png (26.19 KiB) Viewed 2431 times

ExampleFlowGraph.PNG
ExampleFlowGraph.PNG (8.02 KiB) Viewed 2431 times

Let us know if you get stuck or need any help with this. As mentioned though, this is generally not something we would encourage. This is provided as a naive example of the most basic method of combining Flow Graph and Schematyc and should not be used for production. Please let us know what you would like to be implemented in Schematyc :P.