Add RPC Events plus reflection plus fix Ctrl+G retry

This commit is contained in:
puvvadar
2021-05-19 19:34:48 -07:00
parent e4808751f9
commit 2452149e7d
7 changed files with 163 additions and 1 deletions
@@ -188,6 +188,63 @@ virtual void Handle{{ PropertyName }}(AzNetworking::IConnection* invokingConnect
{% endmacro %}
{#
#}
{% macro DeclareRpcEventGetter(Property, HandleOn) %}
{% set paramNames = [] %}
{% set paramTypes = [] %}
{% set paramDefines = [] %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{{ ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }}
AZ::Event<{{ ', '.join(paramTypes) }}>& Get{{ PropertyName }}Event() { return m_{{ PropertyName }}Event; }
{% endmacro %}
{#
#}
{% macro DeclareRpcEventGetters(Component, InvokeFrom, HandleOn) %}
{% call(Property) ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %}
{{- DeclareRpcEventGetter(Property, HandleOn) -}}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareRpcEvent(Property, HandleOn) %}
{% set paramNames = [] %}
{% set paramTypes = [] %}
{% set paramDefines = [] %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{{ ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }}
AZ::Event<{{ ', '.join(paramTypes) }}> m_{{ PropertyName }}Event;
{% endmacro %}
{#
#}
{% macro DeclareRpcEvents(Component, InvokeFrom, HandleOn) %}
{% call(Property) ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %}
{{- DeclareRpcEvent(Property, HandleOn) -}}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareRpcSignal(Property, HandleOn) %}
{% set paramNames = [] %}
{% set paramTypes = [] %}
{% set paramDefines = [] %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{{ ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }}
void Signal{{ PropertyName }}({{ ', '.join(paramDefines) }});
{% endmacro %}
{#
#}
{% macro DeclareRpcSignals(Component, InvokeFrom, HandleOn) %}
{% call(Property) ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %}
{{- DeclareRpcSignal(Property, HandleOn) -}}
{% endcall %}
{% endmacro %}
{#
#}
{%- macro EmitDerivedClassesComment(dataFileNames, Component, ComponentName, ComponentNameBase, ComponentDerived, ControllerName, ControllerNameBase, ControllerDerived, NetworkInputCount) -%}
{% if ComponentDerived or ControllerDerived %}
@@ -214,6 +271,10 @@ namespace {{ Component.attrib['Namespace'] }}
void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
{{ DeclareRpcHandlers(Component, 'Authority', 'Client', true)|indent(8) }}
{{ DeclareRpcSignals(Component, 'Authority', 'Client')|indent(8) }}
{{ DeclareRpcEventGetters(Component, 'Authority', 'Client')|indent(8) }}
protected:
{{ DeclareRpcEvents(Component, 'Authority', 'Client')|indent(8) }}
};
{% endif %}
@@ -236,6 +297,20 @@ namespace {{ Component.attrib['Namespace'] }}
{{ DeclareRpcHandlers(Component, 'Client', 'Authority', true)|indent(8) }}
{{ DeclareRpcHandlers(Component, 'Autonomous', 'Authority', true)|indent(8) }}
{{ DeclareRpcHandlers(Component, 'Authority', 'Autonomous', true)|indent(8) }}
{{ DeclareRpcSignals(Component, 'Server', 'Authority')|indent(8) }}
{{ DeclareRpcSignals(Component, 'Client', 'Authority')|indent(8) }}
{{ DeclareRpcSignals(Component, 'Autonomous', 'Authority')|indent(8) }}
{{ DeclareRpcSignals(Component, 'Authority', 'Autonomous')|indent(8) }}
{{ DeclareRpcEventGetters(Component, 'Server', 'Authority')|indent(8) }}
{{ DeclareRpcEventGetters(Component, 'Client', 'Authority')|indent(8) }}
{{ DeclareRpcEventGetters(Component, 'Autonomous', 'Authority')|indent(8) }}
{{ DeclareRpcEventGetters(Component, 'Authority', 'Autonomous')|indent(8) }}
protected:
{{ DeclareRpcEvents(Component, 'Server', 'Authority')|indent(8) }}
{{ DeclareRpcEvents(Component, 'Client', 'Authority')|indent(8) }}
{{ DeclareRpcEvents(Component, 'Autonomous', 'Authority')|indent(8) }}
{{ DeclareRpcEvents(Component, 'Authority', 'Autonomous')|indent(8) }}
};
{% endif %}
}