@ -1152,7 +1152,8 @@ m_{{ LowerFirst(Property.attrib['Name']) }} = m_{{ LowerFirst(Property.attrib['N
{% else %}
{% else %}
{% set ControllerBaseName = ControllerName %}
{% set ControllerBaseName = ControllerName %}
{% endif %}
{% endif %}
{% set NetworkInputCount = Component.findall('NetworkInput') | len %}
{% set NetworkInputCount = AutoComponentMacros.GetNetworkInputCount(Component) | int %}
{% set NetworkInputsExposedToScriptCount = AutoComponentMacros.GetNetworkInputsExposedToScriptCount(Component) | int %}
{% set NetworkPropertyCount = Component.findall('NetworkProperty') | len %}
{% set NetworkPropertyCount = Component.findall('NetworkProperty') | len %}
{% set RpcCount = Component.findall('RemoteProcedure') | len %}
{% set RpcCount = Component.findall('RemoteProcedure') | len %}
#include "{{ includeFile }}"
#include "{{ includeFile }}"
@ -1299,6 +1300,56 @@ namespace {{ Component.attrib['Namespace'] }}
}
}
{% if NetworkInputCount > 0 %}
{% if NetworkInputCount > 0 %}
{% set ScriptableNetworkInputParamNames = [] %}
{% call(netInput) AutoComponentMacros.ParseNetworkInputsExposedToScript(Component) %}
{% set ScriptableNetworkInputParamNames = ScriptableNetworkInputParamNames.append(LowerFirst(netInput.attrib['Name'])) %}
{% endcall %}
{% if NetworkInputsExposedToScriptCount > 0 %}
{{ ComponentName }}NetworkInput Construct{{ ComponentName }}NetworkInput({{ AutoComponentMacros.GetCommaSeparatedParamListOfScriptableNetworkInputs(Component) }})
{
return {{ ComponentName }}NetworkInput({{ ScriptableNetworkInputParamNames|join(', ') }});
}
{{ ComponentName }}NetworkInput::{{ ComponentName }}NetworkInput({{ AutoComponentMacros.GetCommaSeparatedParamListOfScriptableNetworkInputs(Component) }})
: {% for param_name in ScriptableNetworkInputParamNames %}m_{{ LowerFirst(param_name) }}({{ LowerFirst(param_name) }}){% if not loop.last %}, {% endif %}{% endfor -%}{}
void {{ ComponentName }}NetworkInput::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<{{ ComponentName }}NetworkInput>()
->Version(1)
;
}
AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context);
if (behaviorContext)
{
behaviorContext->Class<{{ ComponentName }}NetworkInput>("{{ ComponentName }}NetworkInput")
->Attribute(AZ::Script::Attributes::Module, "{{ LowerFirst(Component.attrib['Namespace']) }}")
->Attribute(AZ::Script::Attributes::Category, "{{ UpperFirst(Component.attrib['Namespace']) }}")
{% set ScriptableNetInputNames = [] %}
{% call (netInput) AutoComponentMacros.ParseNetworkInputsExposedToScript(Component) %}
{% set ScriptableNetInputNames = ScriptableNetInputNames.append(netInput.attrib['Name']) %}
{% endcall %}
->Method("CreateFromValues", &Construct{{ ComponentName }}NetworkInput, { { {% for param_name in ScriptableNetInputNames %}{"{{ LowerFirst(param_name) }}"}{% if not loop.last %}, {% endif %}{% endfor -%} } })
{% for param_name in ScriptableNetInputNames %}
->Property("{{ param_name }}", BehaviorValueProperty(&{{ ComponentName }}NetworkInput::m_{{ LowerFirst(param_name) }}))
{% endfor %}
;
behaviorContext->EBus<{{ ComponentName }}RequestBus>("{{ ComponentName }}BusHandler")
->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common)
->Attribute(AZ::Script::Attributes::Module, "{{ LowerFirst(Component.attrib['Namespace']) }}")
->Attribute(AZ::Script::Attributes::Category, "{{ UpperFirst(Component.attrib['Namespace']) }}")
->Handler<{{ ComponentName }}BusHandler>()
;
}
}
{% endif %}
Multiplayer::NetComponentId {{ ComponentName }}NetworkInput::GetNetComponentId() const
Multiplayer::NetComponentId {{ ComponentName }}NetworkInput::GetNetComponentId() const
{
{
return {{ ComponentName }}NetworkInput::s_netComponentId;
return {{ ComponentName }}NetworkInput::s_netComponentId;
@ -1347,6 +1398,26 @@ namespace {{ Component.attrib['Namespace'] }}
{% endif %}
{% endif %}
}
}
{% if NetworkInputsExposedToScriptCount > 0 %}
void {{ ControllerBaseName }}::CreateInputFromScript([[maybe_unused]] Multiplayer::NetworkInput& input, [[maybe_unused]] float deltaTime)
{
{{ ComponentName }}NetworkInput result;
{{ ComponentName }}RequestBus::EventResult(result, GetEntity()->GetId(), &{{ ComponentName }}RequestBus::Events::CreateInput, deltaTime);
// Inputs for your own component always exist
{{ ComponentName }}NetworkInput* {{ LowerFirst(ComponentName) }}Input = input.FindComponentInput<{{ ComponentName }}NetworkInput>();
{% call(netInput) AutoComponentMacros.ParseNetworkInputsExposedToScript(Component) %}
{{ LowerFirst(ComponentName) }}Input->m_{{ LowerFirst(netInput.attrib['Name']) }} = result.m_{{ LowerFirst(netInput.attrib['Name']) }};
{% endcall %}
}
void {{ ControllerBaseName }}::ProcessInputFromScript([[maybe_unused]] Multiplayer::NetworkInput& input, [[maybe_unused]] float deltaTime)
{
{{ ComponentName }}NetworkInput* {{ LowerFirst(ComponentName) }}Input = input.FindComponentInput<{{ ComponentName }}NetworkInput>();
{{ ComponentName }}RequestBus::Event(GetEntity()->GetId(), &{{ ComponentName }}RequestBus::Events::ProcessInput, {{ LowerFirst(ComponentName) }}Input, deltaTime);
}
{% endif %}
const {{ ComponentName }}& {{ ControllerBaseName }}::GetParent() const
const {{ ComponentName }}& {{ ControllerBaseName }}::GetParent() const
{
{
return static_cast<const {{ ComponentName }}&>(GetOwner());
return static_cast<const {{ ComponentName }}&>(GetOwner());
@ -1399,6 +1470,9 @@ namespace {{ Component.attrib['Namespace'] }}
}
}
ReflectToEditContext(context);
ReflectToEditContext(context);
ReflectToBehaviorContext(context);
ReflectToBehaviorContext(context);
{% if NetworkInputsExposedToScriptCount > 0 %}
{{ ComponentName }}NetworkInput::Reflect(context);
{% endif %}
}
}
void {{ ComponentBaseName }}::ReflectToEditContext(AZ::ReflectContext* context)
void {{ ComponentBaseName }}::ReflectToEditContext(AZ::ReflectContext* context)
@ -1448,8 +1522,8 @@ namespace {{ Component.attrib['Namespace'] }}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Authority', 'Server', ComponentName) | indent(16) -}}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Authority', 'Server', ComponentName) | indent(16) -}}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Authority', 'Client', ComponentName) | indent(16) -}}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Authority', 'Client', ComponentName) | indent(16) -}}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Authority', 'Autonomous', ComponentName) | indent(16) -}}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Authority', 'Autonomous', ComponentName) | indent(16) -}}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Autonomous', 'Authority', ComponentName) | indent(16) - }}
{{ DefineNetworkPropertyBehaviorReflection(Component, 'Autonomous', 'Authority', ComponentName) | indent(16) }}
// Reflect RPCs
// Reflect RPCs
{{ ReflectRpcInvocations(Component, ComponentName, 'Server', 'Authority')|indent(4) -}}
{{ ReflectRpcInvocations(Component, ComponentName, 'Server', 'Authority')|indent(4) -}}
{{ ReflectRpcInvocations(Component, ComponentName, 'Autonomous', 'Authority')|indent(4) -}}
{{ ReflectRpcInvocations(Component, ComponentName, 'Autonomous', 'Authority')|indent(4) -}}
@ -1459,7 +1533,6 @@ namespace {{ Component.attrib['Namespace'] }}
{{ ReflectRpcEvents(Component, ComponentName, 'Autonomous', 'Authority')|indent(4) -}}
{{ ReflectRpcEvents(Component, ComponentName, 'Autonomous', 'Authority')|indent(4) -}}
{{ ReflectRpcEvents(Component, ComponentName, 'Authority', 'Autonomous')|indent(4) -}}
{{ ReflectRpcEvents(Component, ComponentName, 'Authority', 'Autonomous')|indent(4) -}}
{{ ReflectRpcEvents(Component, ComponentName, 'Authority', 'Client')|indent(4) -}}
{{ ReflectRpcEvents(Component, ComponentName, 'Authority', 'Client')|indent(4) -}}
{{- DefineArchetypePropertyBehaviorReflection(Component, ComponentName) | indent(16) }}
{{- DefineArchetypePropertyBehaviorReflection(Component, ComponentName) | indent(16) }}
;
;
}
}
@ -1508,7 +1581,6 @@ namespace {{ Component.attrib['Namespace'] }}
}
}
{{ ComponentBaseName }}::{{ ComponentBaseName }}() = default;
{{ ComponentBaseName }}::{{ ComponentBaseName }}() = default;
{{ ComponentBaseName }}::~{{ ComponentBaseName }}() = default;
{{ ComponentBaseName }}::~{{ ComponentBaseName }}() = default;
void {{ ComponentBaseName }}::Init()
void {{ ComponentBaseName }}::Init()