Integrating up through commit 90f050496

This commit is contained in:
alexpete
2021-04-07 14:03:29 -07:00
parent 8f2ed080a9
commit c2cbd430fe
2694 changed files with 285622 additions and 176874 deletions
@@ -0,0 +1,13 @@
#pragma once
{% set Namespace = dataFiles[0].attrib['Namespace'] %}
namespace {{ Namespace }}
{
enum class ComponentTypes
{
{% for Component in dataFiles %}
{% set ComponentName = Component.attrib['Name'] %}
{{ ComponentName }},
{% endfor %}
};
}
@@ -0,0 +1,306 @@
{% macro UpperFirst(text) %}{{ text[0] | upper}}{{ text[1:] }}{% endmacro %}
{% macro LowerFirst(text) %}{{ text[0] | lower}}{{ text[1:] }}{% endmacro %}
{#
#}
{%- macro ParseRpcParams(property, outNames, outTypes, outDefines, use_default_value=False) -%}
{%- for Param in property.iter('Param') -%}
{%- do outNames.append(Param.attrib['Name']) -%}
{%- do outTypes.append(Param.attrib['Type']) -%}
{%- if use_default_value and Param.attrib['DefaultValue'] -%}
{%- do outDefines.append('const ' ~ Param.attrib['Type'] ~ '& ' + Param.attrib['Name'] + ' = ' + Param.attrib['DefaultValue']) -%}
{%- else -%}
{%- do outDefines.append('const ' ~ Param.attrib['Type'] ~ '& ' ~ Param.attrib['Name']) -%}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{#
#}
{%- macro ParseIncludes(Component) -%}
{%- for Include in Component.iter('Include') -%}
{{ caller(Include) -}}
{%- endfor -%}
{%- endmacro -%}
{#
#}
{%- macro ParseNetworkInputs(Component) -%}
{%- for NetworkInput in Component.iter('NetworkInput') -%}
{{ caller(NetworkInput) -}}
{%- endfor -%}
{%- endmacro -%}
{#
#}
{%- macro ParseArchetypeProperties(Component) -%}
{%- for ArchetypeProperty in Component.iter('ArchetypeProperty') -%}
{{ caller(ArchetypeProperty) -}}
{%- endfor -%}
{%- endmacro -%}
{#
#}
{%- macro ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) -%}
{%- for NetworkProperty in Component.iter('NetworkProperty') -%}
{%- if NetworkProperty.attrib['ReplicateFrom'] == ReplicateFrom and NetworkProperty.attrib['ReplicateTo'] == ReplicateTo -%}
{{ caller(NetworkProperty) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{#
#}
{%- macro ParseRemoteProcedures(Component, InvokeFrom, HandleOn) -%}
{%- for RemoteProcedure in Component.iter('RemoteProcedure') -%}
{%- if RemoteProcedure.attrib['InvokeFrom'] == InvokeFrom and RemoteProcedure.attrib['HandleOn'] == HandleOn -%}
{{ caller(RemoteProcedure) -}}
{%- endif -%}
{%- endfor -%}
{%- endmacro -%}
{#
#}
{%- macro GetNetPropertiesClassName(Component, ClassType) -%}
{{ Component.attrib['Name'] }}{{ ClassType }}NetProperties
{%- endmacro -%}
{#
#}
{%- macro GetNetPropertiesDirtyEnumName(Component, ClassType, ReplicateFrom, ReplicateTo) -%}
{{ ReplicateFrom }}To{{ ReplicateTo }}DirtyEnum
{%- endmacro -%}
{#
#}
{%- macro GetNetPropertiesPropertyDirtyEnum(Property) -%}
{{ Property.attrib['Name'] }}_DirtyFlag
{%- endmacro -%}
{#
#}
{%- macro GetNetPropertiesQualifiedPropertyDirtyEnum(Component, ClassType, ReplicateFrom, ReplicateTo, Property) -%}
{{ GetNetPropertiesDirtyEnumName(Component, ClassType, ReplicateFrom, ReplicateTo) }}::{{ GetNetPropertiesPropertyDirtyEnum(Property) }}
{%- endmacro -%}
{#
#}
{%- macro GetModelClassName(Component, ClassType) -%}
{{ Component.attrib['Name'] }}Model{{ ClassType }}
{%- endmacro -%}
{#
#}
{%- macro GetArchetypeClassName(Entity, ClassType) -%}
{{ Entity.attrib['Name'] }}Archetype{{ ClassType }}
{%- endmacro -%}
{#
#}
{%- macro GetNetPropertiesSetName(ReplicateFrom, ReplicateTo) -%}
{{ ReplicateFrom }}To{{ ReplicateTo }}
{%- endmacro -%}
{#
#}
{%- macro GetModelReplicationRecordName(Component, ClassType) -%}
{{ Component.attrib['Name'] }}{{ ClassType }}ReplicationRecord
{%- endmacro -%}
{#
#}
{%- macro GetComponentDeltaName(Component, ClassType) -%}
{{ Component.attrib['Name'] }}Delta{{ ClassType }}
{%- endmacro -%}
{#
#}
{%- macro GetNetworkPropertyEventType(Property) -%}
AZ::Event<{{ Property.attrib['Type'] }}>
{%- endmacro -%}
{#
#}
{%- macro GetEntityClassName(Entity, ClassType) -%}
{{ Entity.attrib['Name'] }}{{ ClassType }}
{%- endmacro -%}
{#
#}
{%- macro GetEntityReplicatorName(Entity, ClassType) -%}
{{ Entity.attrib['Name'] }}{{ ClassType }}Replicator
{%- endmacro -%}
{#
#}
{%- macro GetEntityReplicationRecordName(Entity) -%}
{{ Entity.attrib['Name'] }}ReplicationRecord
{%- endmacro -%}
{#
#}
{% macro DefineNetworkPropertyReflection(Component, ReplicateFrom, ReplicateTo, ClassName) %}
{% call(Property) ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% if Property.attrib['ExposeToEditor'] | booleanTrue %}
->Field("{{ Property.attrib['Name'] }}", &{{ ClassName }}::m_{{ LowerFirst(Property.attrib['Name']) }})
{% endif %}
{% endcall -%}
{% endmacro %}
{#
#}
{% macro DefineArchetypePropertyReflection(Component, ClassName) %}
{% call(Property) ParseArchetypeProperties(Component) %}
{% if Property.attrib['ExposeToEditor'] | booleanTrue %}
->Field("{{ Property.attrib['Name'] }}", &{{ ClassName }}::m_{{ LowerFirst(Property.attrib['Name']) }})
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DefineNetworkPropertyConstructors(Component, ReplicateFrom, ReplicateTo, ClassType) %}
{% call(Property) ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% if Property.attrib['Container'] == 'Array' %}
, m_{{ LowerFirst(Property.attrib['Name']) }}({% if Property.attrib['IsRewindable']|booleanTrue %}Multiplayer::RewindableObject<{{ Property.attrib['Type'] }}, Multiplayer::RewindHistorySize>({% endif %}{{ Property.attrib['Init'] }}{% if Property.attrib['IsRewindable']|booleanTrue %}, this){% endif %})
{% elif Property.attrib['Container'] == 'Vector' %}
, m_{{ LowerFirst(Property.attrib['Name']) }}({{ Property.attrib['Init'] }})
{% elif Property.attrib['IsRewindable']|booleanTrue %}
, m_{{ LowerFirst(Property.attrib['Name']) }}({{ Property.attrib['Init'] }}, this)
{% else %}
, m_{{ LowerFirst(Property.attrib['Name']) }}({{ Property.attrib['Init'] }})
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DefineArchetypePropertyConstructors(Component) %}
{% call(Property) ParseArchetypeProperties(Component) %}
{% if Property.attrib['Container'] == 'Vector' %}
, m_{{ LowerFirst(Property.attrib['Name']) }}({{ Property.attrib['Init'] }}, {{ Property.attrib['Count'] }})
{% else %}
, m_{{ LowerFirst(Property.attrib['Name']) }}({{ Property.attrib['Init'] }})
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro ParseComponentServiceTypeAndName(Component) %}
{% for Service in Component.iter('ComponentRelation') %}
{% if Service.attrib['Constraint'] != 'Incompatible' %}
{% set Type = Service.attrib['Namespace'] + "::" + Service.attrib['Name'] %}
{% set Name = 'm_' + LowerFirst(Service.attrib['Name']) %}
{{ caller(Type, Name) -}}
{% endif %}
{% endfor %}
{% endmacro %}
{#
#}
{%- macro GetRpcEventAccessorName(InvokeFrom, HandleOn) -%}
{{ "GetRpc" + InvokeFrom + "To" + HandleOn + "Event" }}
{% endmacro %}
{#
#}
{% macro DeclareRpcHandler(Property, HandleOn, IsOverride) %}
{% set paramNames = [] %}
{% set paramTypes = [] %}
{% set paramDefines = [] %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{{ ParseRpcParams(Property, paramNames, paramTypes, paramDefines) }}
{% if IsOverride %}
void Handle{{ PropertyName }}({{ ', '.join(paramDefines) }}) override {}
{% else %}
//! {{ PropertyName }} Handler
//! {{ Property.attrib['Description'] }}
//! HandleOn {{ HandleOn }}
virtual void Handle{{ PropertyName }}({{ ', '.join(paramDefines) }}) = 0;
{% endif %}
{% endmacro %}
{#
#}
{% macro DeclareRpcHandlers(Component, InvokeFrom, HandleOn, IsOverride) %}
{% call(Property) ParseRemoteProcedures(Component, InvokeFrom, HandleOn) %}
{{- DeclareRpcHandler(Property, HandleOn, IsOverride) -}}
{% endcall %}
{% endmacro %}
{#
#}
{%- macro EmitDerivedClassesComment(dataFileNames, Component, ComponentName, ComponentNameBase, ComponentDerived, ControllerName, ControllerNameBase, ControllerDerived, NetworkInputCount) -%}
{% if ComponentDerived or ControllerDerived %}
/*
/// You may use the classes below as a basis for your new derived classes. Derived classes must be marked in {{ (dataFileNames[0] | basename) }}
/// Place in your .h
#pragma once
#include <Source/AutoGen/{{ ComponentName }}.AutoComponent.h>
namespace {{ Component.attrib['Namespace'] }}
{
{% if ComponentDerived %}
class {{ ComponentName }}
: public {{ ComponentNameBase }}
{
public:
AZ_MULTIPLAYER_COMPONENT({{ Component.attrib['Namespace'] }}::{{ ComponentName }}, s_{{ LowerFirst(ComponentName) }}ConcreteUuid, {{ Component.attrib['Namespace'] }}::{{ ComponentNameBase }});
static void Reflect([[maybe_unused]] AZ::ReflectContext* context);
void OnInit() override {}
void OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
void OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
{{ DeclareRpcHandlers(Component, 'Authority', 'Client', true)|indent(8) }}
};
{% endif %}
{% if ControllerDerived %}
class {{ ControllerName }}
: public {{ ControllerNameBase }}
{
public:
{{ ControllerName }}({{ ComponentName }}& parent) : {{ ControllerNameBase }}(parent) {}
void OnActivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
void OnDeactivate([[maybe_unused]] Multiplayer::EntityIsMigrating entityIsMigrating) override {}
{% if NetworkInputCount > 0 %}
//! Common input processing logic for the NetworkInput.
//! @param input input structure to process
//! @param deltaTime amount of time to integrate the provided inputs over
void ProcessInput([[maybe_unused]] Multiplayer::NetworkInput& input, [[maybe_unused]] float deltaTime) override {}
{%endif %}
{{ DeclareRpcHandlers(Component, 'Server', 'Authority', true)|indent(8) }}
{{ DeclareRpcHandlers(Component, 'Client', 'Authority', true)|indent(8) }}
{{ DeclareRpcHandlers(Component, 'Autonomous', 'Authority', true)|indent(8) }}
{{ DeclareRpcHandlers(Component, 'Authority', 'Autonomous', true)|indent(8) }}
};
{% endif %}
}
{% if ComponentDerived %}
/// Place in your .cpp
namespace {{ Component.attrib['Namespace'] }}
{
void {{ ComponentName }}::{{ ComponentName }}::Reflect(AZ::ReflectContext* context)
{
AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context);
if (serializeContext)
{
serializeContext->Class<{{ ComponentName }}, {{ ComponentNameBase }}>()
->Version(1);
}
}
}
{% endif %}
*/
{% else %}
// NOTE:
// No component roles have been overridden. You can modify {{ (dataFileNames[0] | basename) }} to specify derived classes for your desired network role.
// Once your modifications are complete, build the game.
// Your build will fail, but this comment will be replaced with a stub that can be used as the basis for your derived component roles.
{% endif %}
{%- endmacro -%}
@@ -0,0 +1,479 @@
{% import 'AutoComponent_Common.jinja' as AutoComponentMacros %}
{% macro UpperFirst(text) %}{{ text[0] | upper}}{{ text[1:] }}{% endmacro %}
{% macro LowerFirst(text) %}{{ text[0] | lower}}{{ text[1:] }}{% endmacro %}
{#
#}
{% macro DeclareNetworkPropertyGetter(Property) %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{% if Property.attrib['Container'] == 'Array' %}
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
void {{ PropertyName }}AddEvent(AZ::Event<int32_t, {{ Property.attrib['Type'] }}>::Handler& handler);
{% endif %}
const AZStd::array<{% if Property.attrib['IsRewindable']|booleanTrue %}Multiplayer::RewindableObject<{% endif %}{{ Property.attrib['Type'] }}{% if Property.attrib['IsRewindable']|booleanTrue %}, Multiplayer::k_RewindHistorySize>{% endif %}, {{ Property.attrib['Count'] }}> &Get{{ PropertyName }}Array() const;
const {{ Property.attrib['Type'] }} &Get{{ PropertyName }}(int32_t index) const;
{% elif Property.attrib['Container'] == 'Vector' %}
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
void {{ PropertyName }}AddEvent(AZ::Event<int32_t, {{ Property.attrib['Type'] }}>::Handler& handler);
void {{ PropertyName }}SizeChangedAddEvent(AZ::Event<uint32_t>::Handler& handler);
{% endif %}
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> &Get{{ PropertyName }}Vector() const;
const {{ Property.attrib['Type'] }} &Get{{ PropertyName }}(int32_t index) const;
const {{ Property.attrib['Type'] }} &{{ PropertyName }}GetBack() const;
uint32_t {{ PropertyName }}GetSize() const;
{% else %}
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
void {{ PropertyName }}AddEvent(AZ::Event<{{ Property.attrib['Type'] }}>::Handler& handler);
{% endif %}
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}() const;
{% endif %}
{% endmacro %}
{#
#}
{% macro DeclareNetworkPropertySetter(Property) %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{% if Property.attrib['IsPredictable'] | booleanTrue %}
{% if Property.attrib['Container'] == 'Array' %}
void Set{{ PropertyName }}(const Multiplayer::NetworkInput&, int32_t index, const {{ Property.attrib['Type'] }}& value);
{{ Property.attrib['Type'] }}& Modify{{ PropertyName }}(const Multiplayer::NetworkInput&, int32_t index);
{% elif Property.attrib['Container'] == 'Vector' %}
void Set{{ PropertyName }}(const Multiplayer::NetworkInput&, int32_t index, const {{ Property.attrib['Type'] }}& value);
{{ Property.attrib['Type'] }}& Modify{{ PropertyName }}(const Multiplayer::NetworkInput&, int32_t index);
bool {{ PropertyName }}PushBack(const Multiplayer::NetworkInput&, const {{ Property.attrib['Type'] }}& value);
bool {{ PropertyName }}PopBack(const Multiplayer::NetworkInput&);
void {{ PropertyName }}Clear(const Multiplayer::NetworkInput&);
{% elif Property.attrib['Container'] == 'Object' %}
void Set{{ PropertyName }}(const Multiplayer::NetworkInput&, const {{ Property.attrib['Type'] }}& value);
{{ Property.attrib['Type'] }}& Modify{{ PropertyName }}(const Multiplayer::NetworkInput&);
{% else %}
void Set{{ PropertyName }}(const Multiplayer::NetworkInput&, const {{ Property.attrib['Type'] }}& value);
{% endif %}
{% endif %}
{% endmacro %}
{#
#}
{% macro DeclareNetworkPropertyGetters(Component, ReplicateFrom, ReplicateTo, IsProtected) %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{% if Property.attrib['IsPublic'] | booleanTrue != IsProtected %}
//! {{ PropertyName }} Accessors
//! {{ Property.attrib['Description'] }}.
{{ DeclareNetworkPropertyGetter(Property) }}
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareArchetypePropertyGetter(Property) %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{% if Property.attrib['Container'] == 'Array' %}
const AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& Get{{ PropertyName }}Array() const;
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}(int32_t index) const;
{% elif Property.attrib['Container'] == 'Vector' %}
const AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}>& Get{{ PropertyName }}Vector() const;
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}(int32_t index) const;
const {{ Property.attrib['Type'] }}& {{ PropertyName }}GetBack() const;
uint32_t {{ PropertyName }}GetSize() const;
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}() const;
{% else %}
const {{ Property.attrib['Type'] }}& Get{{ PropertyName }}() const;
{% endif %}
{% endmacro %}
{#
#}
{% macro DeclareArchetypePropertyGetters(Component) %}
{% call(Property) AutoComponentMacros.ParseArchetypeProperties(Component) %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
//! Get{{ PropertyName }}
//! {{ Property.attrib['Description'] }}.
{{ DeclareArchetypePropertyGetter(Property) }}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareNetworkPropertyAccessors(Component, ReplicateFrom, ReplicateTo, IsProtected) %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{% if Property.attrib['IsPublic'] | booleanTrue != IsProtected %}
//! {{ PropertyName }} Accessors
//! {{ Property.attrib['Description'] }}.
{{ DeclareNetworkPropertyGetter(Property) -}}
{{ DeclareNetworkPropertySetter(Property) }}
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareRpcInvocation(Property, HandleOn) %}
{% set paramNames = [] %}
{% set paramTypes = [] %}
{% set paramDefines = [] %}
{% set PropertyName = UpperFirst(Property.attrib['Name']) %}
{{ AutoComponentMacros.ParseRpcParams(Property, paramNames, paramTypes, paramDefines, true) }}
//! {{ PropertyName }} Invocation
//! {{ Property.attrib['Description'] }}
//! HandleOn {{ HandleOn }}
void {{ PropertyName }}({{ ', '.join(paramDefines) }});
{% endmacro %}
{#
#}
{% macro DeclareRpcInvocations(Component, Section, HandleOn, ProctectedSection) %}
{% call(Property) AutoComponentMacros.ParseRemoteProcedures(Component, Section, HandleOn) %}
{% if Property.attrib['IsPublic']|booleanTrue == ProctectedSection %}
{{- DeclareRpcInvocation(Property, HandleOn) -}}
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareNetworkPropertyEvents(Component, ReplicateFrom, ReplicateTo) %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% if Property.attrib['Container'] == 'Array' %}
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
AZ::Event<int32_t, {{ Property.attrib['Type'] }}> m_{{ LowerFirst(Property.attrib['Name']) }}Event;
{% endif %}
{% elif Property.attrib['Container'] == 'Vector' %}
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
AZ::Event<int32_t, {{ Property.attrib['Type'] }}> m_{{ LowerFirst(Property.attrib['Name']) }}Event;
AZ::Event<uint32_t> m_{{ LowerFirst(Property.attrib['Name']) }}SizeChangedEvent;
{% endif %}
{% else %}
{% if Property.attrib['GenerateEventBindings']|booleanTrue %}
AZ::Event<{{ Property.attrib['Type'] }}> m_{{ LowerFirst(Property.attrib['Name']) }}Event;
{% endif %}
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareNetworkPropertyVars(Component, ReplicateFrom, ReplicateTo) %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, ReplicateFrom, ReplicateTo) %}
{% if Property.attrib['Container'] == 'Array' %}
AZStd::array<{% if Property.attrib['IsRewindable']|booleanTrue %}Multiplayer::RewindableObject<{% endif %}{{ Property.attrib['Type'] }}{% if Property.attrib['IsRewindable']|booleanTrue %}, Multiplayer::RewindHistorySize>{% endif %}, {{ Property.attrib['Count'] }}> m_{{ Property.attrib['Name'] }};
{% elif Property.attrib['Container'] == 'Vector' %}
AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> m_{{ LowerFirst(Property.attrib['Name']) }};
{% elif Property.attrib['IsRewindable']|booleanTrue %}
Multiplayer::RewindableObject<{{ Property.attrib['Type'] }}, Multiplayer::RewindHistorySize> m_{{ LowerFirst(Property.attrib['Name']) }} = {{ Property.attrib['Init'] }};
{% else %}
{{ Property.attrib['Type'] }} m_{{ LowerFirst(Property.attrib['Name']) }} = {{ Property.attrib['Init'] }};
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
{% macro DeclareArchetypePropertyVars(Component) %}
{% call(Property) AutoComponentMacros.ParseArchetypeProperties(Component) %}
{% if Property.attrib['Container'] == 'Array' %}
AZStd::array<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> m_{{ LowerFirst(Property.attrib['Name']) }};
{% elif Property.attrib['Container'] == 'Vector' %}
AZStd::fixed_vector<{{ Property.attrib['Type'] }}, {{ Property.attrib['Count'] }}> m_{{ LowerFirst(Property.attrib['Name']) }};
{% else %}
{{ Property.attrib['Type'] }} m_{{ LowerFirst(Property.attrib['Name']) }};
{% endif %}
{% endcall %}
{% endmacro %}
{#
#}
#pragma once
{% for Component in dataFiles %}
{% set ComponentName = Component.attrib['Name'] %}
{% set ComponentBaseName = ComponentName %}
{% set ComponentDerived = Component.attrib['OverrideComponent']|booleanTrue %}
{% set ControllerDerived = Component.attrib['OverrideController']|booleanTrue %}
{% if ComponentDerived %}
{% set ComponentBaseName = ComponentName + "Base" %}
{% endif %}
{% set ControllerName = ComponentName + "Controller" %}
{% set ControllerBaseName = ControllerName %}
{% if ControllerDerived %}
{% set ControllerBaseName = ControllerName + "Base" %}
{% endif %}
{% set NetworkInputCount = Component.findall('NetworkInput') | len %}
{% set NetworkPropertyCount = Component.findall('NetworkProperty') | len %}
{% set RpcCount = Component.findall('RemoteProcedure') | len %}
#include "AutoComponentTypes.h"
#include <AzCore/EBus/Event.h>
#include <AzCore/EBus/ScheduledEvent.h>
#include <AzNetworking/DataStructures/FixedSizeBitsetView.h>
#include <Source/NetworkEntity/NetworkEntityHandle.h>
#include <Source/NetworkEntity/EntityReplication/ReplicationRecord.h>
#include <Source/Components/MultiplayerComponent.h>
#include <Source/Components/MultiplayerController.h>
#include <Source/NetworkInput/IMultiplayerComponentInput.h>
#include <Source/NetworkTime/RewindableObject.h>
#include <Source/MultiplayerTypes.h>
{% call(Include) AutoComponentMacros.ParseIncludes(Component) %}
#include <{{ Include.attrib['File'] }}>
{% endcall %}
{% for Service in Component.iter('ComponentRelation') %}
{% if Service.attrib['Constraint'] != 'Incompatible' %}
namespace {{ Service.attrib['Namespace'] }}
{
class {{ Service.attrib['Name'] }};
{% if Service.attrib['HasController']|booleanTrue %}
class {{ Service.attrib['Name'] }}Controller;
{% endif %}
}
{% endif %}
{% endfor %}
{{ AutoComponentMacros.EmitDerivedClassesComment(dataFileNames, Component, ComponentName, ComponentBaseName, ComponentDerived, ControllerName, ControllerBaseName, ControllerDerived, NetworkInputCount) }}
namespace {{ Component.attrib['Namespace'] }}
{
//! Forward declarations
class {{ ComponentName }};
class {{ ControllerName }};
//! Returns a human readable name for the provided remoteProcedureId.
const char* GetRemoteProcedureName(uint16_t remoteProcedureId);
{% set RecordName = ComponentName + "Record" %}
//! @class {{RecordName }}
//! @brief A record of the changed bits in the NetworkProperties for component {{ ComponentName }}.
class {{ RecordName }}
{
public:
//! AllocateRecord
//! Allocates and returns a new record. Will reserve storage in the provided ReplicationRecord.
static AZStd::unique_ptr<{{ RecordName }}> AllocateRecord(Multiplayer::ReplicationRecord& replicationRecord);
//! CanAttachRecord
//! Returns a true if we can attach a {{ ClassType }}Record to the ReplicationRecord.
static bool CanAttachRecord(Multiplayer::ReplicationRecord& replicationRecord);
//! AttachRecord
//! Returns a {{ ClassType }}Record that has been attached to the ReplicationRecord. This will consume bits in the provided ReplicationRecord.
static {{ RecordName }} AttachRecord(Multiplayer::ReplicationRecord& replicationRecord);
//! SetPredictableBits
//! Sets the bits in the attached record that correspond to predictable network properties.
void SetPredictableBits();
{% set networkPropertyCount = {'value' : 0} %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, 'Authority', 'Client') %}
{%- if networkPropertyCount.update({'value': networkPropertyCount.value + 1}) %}{% endif -%}
{% endcall %}
{% if networkPropertyCount.value > 0 %}
AzNetworking::FixedSizeBitsetView m_authorityToClient;
{% endif %}
{% set networkPropertyCount = {'value' : 0} %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, 'Authority', 'Server') %}
{%- if networkPropertyCount.update({'value': networkPropertyCount.value + 1}) %}{% endif -%}
{% endcall %}
{% if networkPropertyCount.value > 0 %}
AzNetworking::FixedSizeBitsetView m_authorityToServer};
{% endif %}
{% set networkPropertyCount = {'value' : 0} %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, 'Authority', 'Autonomous') %}
{%- if networkPropertyCount.update({'value': networkPropertyCount.value + 1}) %}{% endif -%}
{% endcall %}
{% if networkPropertyCount.value > 0 %}
AzNetworking::FixedSizeBitsetView m_authorityToAutonomous;
{% endif %}
{% set networkPropertyCount = {'value' : 0} %}
{% call(Property) AutoComponentMacros.ParseNetworkProperties(Component, 'Autonomous', 'Authority') %}
{%- if networkPropertyCount.update({'value': networkPropertyCount.value + 1}) %}{% endif -%}
{% endcall %}
{% if networkPropertyCount.value > 0 %}
AzNetworking::FixedSizeBitsetView m_autonomousToAuthority;
{% endif %}
private:
{{ RecordName }}
(
Multiplayer::ReplicationRecord& replicationRecord,
uint32_t authorityToClientSimluationStartOffset,
uint32_t authorityToServerSimluationStartOffset,
uint32_t authorityToAutonomousStartOffset,
uint32_t autonomousToAuthorityStartOffset
);
};
{% if NetworkInputCount > 0 %}
class NetworkInput
: public Multiplayer::IMultiplayerComponentInput
{
public:
static const Multiplayer::NetComponentId s_componentId = static_cast<Multiplayer::NetComponentId>({{ Component.attrib['Namespace'] }}::ComponentTypes::{{ Component.attrib['Name'] }});
Multiplayer::NetComponentId GetComponentId() const override;
INetworkInput& operator=(const INetworkInput& rhs) override;
bool Serialize(AzNetworking::ISerializer& serializer);
{% call(Input) AutoComponentMacros.ParseNetworkInputs(Component) %}
{{ Input.attrib['Type'] }} m_{{ LowerFirst(Input.attrib['Name']) }} = {{ Input.attrib['Type'] }}({{ Input.attrib['Init'] }});
{% endcall %}
};
{% endif %}
class {{ ControllerBaseName }}{% if not ControllerDerived %} final{% endif %}{{ "" }}
: public Multiplayer::MultiplayerController
{
public:
{{ ControllerBaseName }}({{ ComponentName }}& owner);
~{{ ControllerBaseName }}() override = default;
void NetworkAttach(Multiplayer::NetBindComponent* netBindComponent, Multiplayer::ReplicationRecord& predictableEntityRecord);
void Activate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
void Deactivate(Multiplayer::EntityIsMigrating entityIsMigrating) override;
const {{ ComponentName }}& GetParent() const;
{{ ComponentName }}& GetParent();
{% if ControllerDerived %}
virtual void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) = 0;
virtual void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) = 0;
{% endif %}
//! MultiplayerController interface
//! @{
Multiplayer::MultiplayerController::InputPriorityOrder GetInputOrder() const override { return Multiplayer::MultiplayerController::InputPriorityOrder::Default; }
AZ::Aabb GetRewindBoundsForInput([[maybe_unused]] const NetworkInput& networkInput, [[maybe_unused]] float deltaTime) const override { return AZ::Aabb::CreateNull(); }
void CreateInput([[maybe_unused]] Multiplayer::NetworkInput& input, [[maybe_unused]] float deltaTime) override {}
void ProcessInput([[maybe_unused]] Multiplayer::NetworkInput& input, [[maybe_unused]] float deltaTime) override {}
//! @}
{{ DeclareNetworkPropertyAccessors(Component, 'Authority', 'Server', false)|indent(8) -}}
{{ DeclareNetworkPropertyAccessors(Component, 'Authority', 'Client', false)|indent(8) -}}
{{ DeclareNetworkPropertyAccessors(Component, 'Authority', 'Autonomous', false)|indent(8) }}
{{ DeclareArchetypePropertyGetters(Component)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Server', 'Authority', false)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Server', 'Authority', true)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Client', 'Authority', false)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Client', 'Authority', true)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Autonomous', 'Authority', false)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Autonomous', 'Authority', true)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Authority', 'Autonomous', false)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Authority', 'Autonomous', true)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Authority', 'Client', false)|indent(8) }}
{{ DeclareRpcInvocations(Component, 'Authority', 'Client', true)|indent(8) }}
{{ AutoComponentMacros.DeclareRpcHandlers(Component, 'Server', 'Authority', false)|indent(8) }}
{{ AutoComponentMacros.DeclareRpcHandlers(Component, 'Client', 'Authority', false)|indent(8) }}
{{ AutoComponentMacros.DeclareRpcHandlers(Component, 'Autonomous', 'Authority', false)|indent(8) }}
{{ AutoComponentMacros.DeclareRpcHandlers(Component, 'Authority', 'Autonomous', false)|indent(8) }}
{% for Service in Component.iter('ComponentRelation') %}
{% if (Service.attrib['HasController']|booleanTrue) and (Service.attrib['Constraint'] != 'Incompatible') %}
{{ Service.attrib['Namespace'] }}::{{ Service.attrib['Name'] }}Controller* Get{{ Service.attrib['Name'] }}Controller();
{% endif %}
{% endfor %}
};
static const AZ::Uuid s_{{ LowerFirst(ComponentName) }}ConcreteUuid = "{{ (ComponentName) | createHashGuid }}";
class {{ ComponentBaseName }}{% if not ComponentDerived %} final{% endif %}{{ "" }}
: public Multiplayer::MultiplayerComponent
{
friend class {{ ControllerName }};
friend class {{ ControllerBaseName }};
public:
{% if ComponentDerived %}
AZ_CLASS_ALLOCATOR({{ ComponentBaseName }}, AZ::SystemAllocator, 0);
AZ_RTTI({{ ComponentBaseName }}, s_{{ LowerFirst(ComponentName) }}ConcreteUuid, AZ::Component);
{% else %}
AZ_MULTIPLAYER_COMPONENT({{ Component.attrib['Namespace'] }}::{{ ComponentBaseName }}, s_{{ LowerFirst(ComponentName) }}ConcreteUuid, Multiplayer::MultiplayerComponent);
{% endif %}
static const Multiplayer::NetComponentId s_componentId = static_cast<Multiplayer::NetComponentId>({{ Component.attrib['Namespace'] }}::ComponentTypes::{{ Component.attrib['Name'] }});
static void Reflect(AZ::ReflectContext* context);
static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided);
static void GetRequiredServices(AZ::ComponentDescriptor::DependencyArrayType& required);
static void GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& dependent);
static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible);
{{ ComponentBaseName }}() = default;
~{{ ComponentBaseName }}() override = default;
void Init() override;
void Activate() override;
void Deactivate() override;
{% if ComponentDerived %}
virtual void OnInit() = 0;
virtual void OnActivate(Multiplayer::EntityIsMigrating entityIsMigrating) = 0;
virtual void OnDeactivate(Multiplayer::EntityIsMigrating entityIsMigrating) = 0;
{% endif %}
{{ DeclareNetworkPropertyGetters(Component, 'Authority', 'Server', false)|indent(8) -}}
{{ DeclareNetworkPropertyGetters(Component, 'Authority', 'Client', false)|indent(8) }}
{{ DeclareArchetypePropertyGetters(Component)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Server', 'Authority', false)|indent(8) }}
//! MultiplayerComponent interface
//! @{
NetComponentId GetNetComponentId() const override;
bool HandleRpcMessage(Multiplayer::NetEntityRole remoteRole, Multiplayer::NetworkEntityRpcMessage& rpcMessage) override;
bool SerializeStateDeltaMessage(Multiplayer::ReplicationRecord& replicationRecord, AzNetworking::ISerializer& serializer) override;
void NotifyStateDeltaChanges(Multiplayer::ReplicationRecord& replicationRecord) override;
protected:
bool HasController() const override;
MultiplayerController* GetController() override;
void ConstructController() override;
void DestructController() override;
void ActivateController(Multiplayer::EntityIsMigrating entityIsMigrating) override;
void DeactivateController(Multiplayer::EntityIsMigrating entityIsMigrating) override;
void NetworkAttach(Multiplayer::NetBindComponent* netBindComponent, Multiplayer::ReplicationRecord& currentEntityRecord, Multiplayer::ReplicationRecord& predictableEntityRecord) override;
//! @}
{{ DeclareNetworkPropertyGetters(Component, 'Authority', 'Server', true)|indent(8) -}}
{{ DeclareNetworkPropertyGetters(Component, 'Authority', 'Autonomous', true)|indent(8) -}}
{{ DeclareNetworkPropertyGetters(Component, 'Autonomous', 'Authority', true)|indent(8) -}}
{{ DeclareNetworkPropertyGetters(Component, 'Authority', 'Client', true)|indent(8) -}}
{{ DeclareRpcInvocations(Component, 'Server', 'Authority', true)|indent(8) -}}
{{ AutoComponentMacros.DeclareRpcHandlers(Component, 'Authority', 'Client', false)|indent(8) }}
{% for Service in Component.iter('ComponentRelation') %}
{% if Service.attrib['Constraint'] != 'Incompatible' %}
const {{ Service.attrib['Namespace'] }}::{{ Service.attrib['Name'] }}* Get{{ Service.attrib['Name'] }}() const;
{{ Service.attrib['Namespace'] }}::{{ Service.attrib['Name'] }}* Get{{ Service.attrib['Name'] }}();
{% endif %}
{% endfor %}
private:
//! Authority to Client serializers
bool SerializeAuthorityToClientProperties({{ RecordName }}& replicationRecord, AzNetworking::ISerializer& serializer);
void NotifyChangesAuthorityToClientProperties(const {{ RecordName }}& replicationRecord) const;
//! Authority To Server serializers
bool SerializeAuthorityToServerProperties({{ RecordName }}& replicationRecord, AzNetworking::ISerializer& serializer);
void NotifyChangesAuthorityToServerProperties(const {{ RecordName }}& replicationRecord) const;
//! Authority To Autonomous serializers
bool SerializeAuthorityToAutonomousProperties({{ RecordName }}& replicationRecord, AzNetworking::ISerializer& serializer);
void NotifyChangesAuthorityToAutonomousProperties(const {{ RecordName }}& replicationRecord) const;
//! Autonomous To Authority serializers
bool SerializeAutonomousToAuthorityProperties({{ RecordName }}& replicationRecord, AzNetworking::ISerializer& serializer);
void NotifyChangesAutonomousToAuthorityProperties(const {{ RecordName }}& replicationRecord) const;
AZStd::unique_ptr<{{ RecordName }}> m_currentRecord;
AZStd::unique_ptr<{{ ControllerName }}> m_controller;
//! Network Properties
{{ DeclareNetworkPropertyVars(Component, 'Authority', 'Server')|indent(8) -}}
{{ DeclareNetworkPropertyVars(Component, 'Authority', 'Client')|indent(8) -}}
{{ DeclareNetworkPropertyVars(Component, 'Authority', 'Autonomous')|indent(8) -}}
{{ DeclareNetworkPropertyVars(Component, 'Autonomous', 'Authority')|indent(8) }}
//! NetworkProperty Events
{{ DeclareNetworkPropertyEvents(Component, 'Authority', 'Server')|indent(8) -}}
{{ DeclareNetworkPropertyEvents(Component, 'Authority', 'Client')|indent(8) -}}
{{ DeclareNetworkPropertyEvents(Component, 'Authority', 'Autonomous')|indent(8) -}}
{{ DeclareNetworkPropertyEvents(Component, 'Autonomous', 'Authority')|indent(8) }}
//! Archetype Properties
{{ DeclareArchetypePropertyVars(Component)|indent(8) }}
{% call(Type, Name) AutoComponentMacros.ParseComponentServiceTypeAndName(Component) %}
{{ Type }}* {{ Name }} = nullptr;
{% endcall %}
};
}
{% endfor %}
File diff suppressed because it is too large Load Diff
@@ -52,6 +52,5 @@
<Member Type="Multiplayer::NetEntityId" Name="entityId" Init="Multiplayer::InvalidNetEntityId" />
<Member Type="Multiplayer::PrefabEntityId" Name="prefabEntityId" Init="" />
<Member Type="AzNetworking::PacketEncodingBuffer" Name="propertyUpdateData" Init="" SuppressFromInitializerList="true" />
<Member Type="AzNetworking::PacketEncodingBuffer" Name="migrationData" Init="" SuppressFromInitializerList="true" />
</Packet>
</PacketGroup>
@@ -0,0 +1,53 @@
<?xml version="1.0"?>
<Component
Name="NetworkTransformComponent"
Namespace="Multiplayer"
OverrideComponent="true"
OverrideController="true"
OverrideInclude="Source/Components/NetworkTransformComponent.h"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComponentRelation Constraint="Weak" HasController="false" Name="TransformComponent" Namespace="AzFramework" Include="AzFramework/Components/TransformComponent.h" />
<Include File="Source/MultiplayerTypes.h"/>
<NetworkProperty Type="AZ::Quaternion" Name="rotation" Init="AZ::Quaternion::CreateIdentity()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="true" GenerateEventBindings="true" />
<NetworkProperty Type="AZ::Vector3" Name="translation" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="true" GenerateEventBindings="true" />
<NetworkProperty Type="AZ::Vector3" Name="scale" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="true" GenerateEventBindings="true" />
<NetworkProperty Type="AZ::Vector3" Name="velocity" Init="AZ::Vector3::CreateZero()" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="true" GenerateEventBindings="true" />
<NetworkProperty Type="uint8_t" Name="resetCount" Init="0" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="false" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="NetEntityId" Name="parentEntityId" Init="InvalidNetEntityId" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<NetworkProperty Type="int32_t" Name="parentAttachmentBoneId" Init="-1" ReplicateFrom="Authority" ReplicateTo="Client" IsRewindable="true" IsPredictable="true" IsPublic="true" Container="Object" ExposeToEditor="false" GenerateEventBindings="true" />
<ArchetypeProperty Type="bool" Name="snapToGround" Init="false" ExposeToEditor="true" />
<ArchetypeProperty Type="bool" Name="useGroundNormal" Init="false" ExposeToEditor="true" />
<!--
This is reference only, will be deleted when we make a better test component that exercizes all aspects of component autogen
<RemoteProcedure Name="RPCServerToAuthorityPublic" InvokeFrom="Server" HandleOn="Authority" IsPublic="true" IsReliable="false" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RPCServerToAuthorityScriptProtected" InvokeFrom="Server" HandleOn="Authority" IsPublic="false" IsReliable="false" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RPCAutonomousToAuthorityPublic" InvokeFrom="Autonomous" HandleOn="Authority" IsPublic="true" IsReliable="false" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RPCAuthorityToAutonomousPublic" InvokeFrom="Authority" HandleOn="Autonomous" IsPublic="true" IsReliable="false" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RpcAuthorityToClientPublic" InvokeFrom="Authority" HandleOn="Client" IsPublic="true" IsReliable="false" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RpcAuthorityToClientProtected" InvokeFrom="Authority" HandleOn="Client" IsPublic="false" IsReliable="false" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RpcAuthorityToServerPublic" InvokeFrom="Authority" HandleOn="Server" IsPublic="true" IsReliable="true" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
<RemoteProcedure Name="RpcAuthorityToServerProtected" InvokeFrom="Authority" HandleOn="Server" IsPublic="false" IsReliable="true" Description="Description" >
<Param Name="Test" Type="int" DefaultValue="0" Description="Description"/>
</RemoteProcedure>
-->
</Component>