Permalink
Browse files

Squashed commit of the following:

commit 36f642bc875ca751c837ef47a3416f59dfca20aa
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sun Jan 8 12:56:40 2017 +1000

    Check pointer on getting the actor.

commit 286b895deadeecad559dd4c0eedf547212801397
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Jan 7 00:34:23 2017 +1000

    Fixed the scans for items and actors. Fixed DRS registrations.

commit 0d58258131bad0bd139716b8fd6a8a920175be5a
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Jan 7 00:24:23 2017 +1000

    Added a small hack that fixes the calls to the plugin manager.

commit 830ea5dec46804077dae8a55ddae26ee0f2b64f1
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Jan 6 23:49:19 2017 +1000

    Switched to using split system for plugin and core features. Fixed issue with not attaching to 'Character1' - now using 'Hero' as a default.
    Plugin query still not working correctly.

commit 39a78896ab66d750deae456ad879da59fc3b8188
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Jan 6 21:59:03 2017 +1000

    Removed annoying debug sphere over character's head.

commit 128791ae38de3082e1fcbfc7817f3dc8d40c3ba1
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Jan 6 14:02:12 2017 +1000

    Camera and player input working fine now.
    There is an outstanding issue with GamePlugin querying for itself using the plugin manager. It can't access instance variables correctly. I am working around that for now. A fix is needed.

commit 9ee136304a2eff66cc9e7d9c98a4adacb4cd42ae
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Jan 6 00:36:54 2017 +1000

    Camera is now working, or would be if the cvars on the plugin weren't getting trashed sometime between loading the plugin and running the game.
    Character still isn't walking, not sure why yet, but most likely it's somewhere in the CAnimatedCharacter code.

commit 34ef9363a4e63b0cbc65c3bd4175b52f509e90eb
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Wed Jan 4 23:27:39 2017 +1000

    Camera is attaching to character - but not on level start - must be done by hand after level load.
    Cameras are updating and getting their view functions called - but returning a camera position and rotation that is quite wrong - like a 90 degree rotation off or something.

commit bee8fda7884ad4767a96c4a1a26584af250838ac
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Wed Jan 4 16:44:00 2017 +1000

    I've moved back all the player components to use the old system of creation. They do not receive proper Init and postinit calls unless declared correctly and instanced using AcquireExtension

commit 4b7dd2b563af6cbde524a76cfeccc90250106132
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Mon Jan 2 23:09:25 2017 +1000

    Game rules now get initialised. Player is correctly started, and camera manager - but Initialise() is not being called for the cameras and player input.

commit 1f6ae4d0ae736e8f8c47f7b7c3eb7ad640b970d3
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 31 23:07:04 2016 +1000

    Found that there is a marked difference in calling:

    CChrysalisCore::RegisterEntityWithDefaultComponent<CCharacter>("Character");

    vs

    RegisterEntityWithDefaultComponent<CCharacter>("Character", "Actors", "Light.bmp");

    The first will make it a GameObjectExtension, which is needed for actors right now.

commit 4cffe83cf11a06ec802528aaa5235fe148640b1c
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 31 22:32:42 2016 +1000

    Restoring some things. cmake is broken for some reason.

commit 0008c4a18ec032c98889c55e3b2f65f47f3fcbb5
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 31 21:35:47 2016 +1000

    Minor fixups - still no luck getting the right init sequence for gameobjects.

commit 7bd7367172011d98d3072fe7d20d24c137714469
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 31 20:36:41 2016 +1000

    Character init is wrong due to lack of access to GameObject. Checking in code now to begin removal of IActor from Player and Character.

commit 0fb846ebbac941c6793c8252cfcc3cfcb8190741
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Dec 30 04:37:37 2016 +1000

    Code finally builds again, albeit with a few hacks and raycasts not currently working due to being missing from header only CryAction code.
    It runs, but fails in places. Debug and fixes will be needed to get it working as expected. There's a lot of untested code in there right now.

commit 2999785a4c64a8625a179fbf957bf5f675ca6b01
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Dec 30 01:00:43 2016 +1000

    Code compiles, but build fails due to missing links for CryAction and all the new entity stuff using CRY_ENTITY_COMPONENT_INTERFACE_AND_CLASS

commit 9fcf4717efb47caa0ece948118987d2d63c74016
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Thu Dec 29 15:09:20 2016 +1000

    Some work on getting core functionality like cvars available.

commit 7edb25dcb902e2e638c62ab90ecc14337f073ebe
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Tue Dec 27 21:14:40 2016 +1000

    Removed ReloadExtension code. Small fixes.

commit cb21b43155dd047cd5aafddb800688a9c56ce178
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sun Dec 25 13:28:46 2016 +1000

    More fixes and changes. Merry Christmas!

commit c9f74588e76795ecf01cab3f9dcf88475dd6ef94
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 24 23:20:23 2016 +1000

    Lots more fixes and adjustments for the new entity system. Most things except game and gameobjectexension have been tackled.

commit 11d9cad4e03c70c5fec5901acdbaa6950d315036
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 24 15:33:24 2016 +1000

    Working on actors, characters and players. It's tricky because they all depend on gameobjects.

commit 9e5835c7095a77f423ecd1b189dde4548b5366fb
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Fri Dec 23 21:26:55 2016 +1000

    Work on camera and player code.

commit a90c7bd8e12a6d8e8ff883df573cd6280a04a700
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Wed Dec 21 17:55:21 2016 +1000

    Slowly slogging through it all. Lots of work on switching to new components, removal of game, that sort of thing.

commit f373654deafd746c6c6052804f7eba449dfccbf6
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 17 15:51:27 2016 +1000

    Progressing. Still broken.

commit f7e510ea043f3d7d6ef1e8e8039286810797408c
Author: Ivan Hawkes <ivan.hawkes@gmail.com>
Date:   Sat Dec 17 00:03:01 2016 +1000

    Initial efforts switching to new entity component system. Starting to remove game specific code. Have to find new place for game specific actions.
    Very broken build.
  • Loading branch information...
ivanhawkes committed Jan 8, 2017
1 parent ac9e06d commit 6dbf1ff8b112165ad2e8e62d7f4babcd74cbad6a
Showing with 1,731 additions and 4,647 deletions.
  1. +103 −149 Actor/Actor.cpp
  2. +19 −9 Actor/Actor.h
  3. +2 −1 Actor/ActorPhysics.h
  4. +1 −0 Actor/ActorState.h
  5. +47 −76 Actor/Character/Character.cpp
  6. +22 −20 Actor/Character/Character.h
  7. +5 −4 Actor/Character/Movement/CharacterRotation.cpp
  8. +3 −2 Actor/Character/Movement/StateMachine/CharacterStateAnimationControlled.cpp
  9. +1 −2 Actor/Character/Movement/StateMachine/CharacterStateDead.cpp
  10. +1 −1 Actor/Character/Movement/StateMachine/CharacterStateFly.cpp
  11. +6 −7 Actor/Character/Movement/StateMachine/CharacterStateGround.cpp
  12. +2 −3 Actor/Character/Movement/StateMachine/CharacterStateJump.cpp
  13. +8 −8 Actor/Character/Movement/StateMachine/CharacterStateLadder.cpp
  14. +1 −2 Actor/Character/Movement/StateMachine/CharacterStateLedge.cpp
  15. +0 −1 Actor/Character/Movement/StateMachine/CharacterStateMovement.cpp
  16. +0 −1 Actor/Character/Movement/StateMachine/CharacterStateSwim.cpp
  17. +2 −0 Actor/Character/Movement/StateMachine/CharacterStateSwim.h
  18. +4 −3 Actor/Character/Movement/StateMachine/CharacterStateSwimWaterTestProxy.cpp
  19. +1 −1 Actor/IActorEventListener.h
  20. +2 −106 Actor/ISimpleActor.h
  21. +0 −16 Actor/Inventory/EntityInventory.cpp
  22. +3 −10 Actor/Inventory/EntityInventory.h
  23. +1 −0 Actor/Movement/StateMachine/ActorStateEvents.h
  24. +2 −3 Actor/Movement/StateMachine/ActorStateUtility.cpp
  25. +42 −124 CMakeLists.txt
  26. +8 −7 ConsoleCommands/ConsoleCommands.cpp
  27. +0 −1 DynamicResponseSystem/ActionClose.cpp
  28. +0 −1 DynamicResponseSystem/ActionLock.cpp
  29. +0 −1 DynamicResponseSystem/ActionOpen.cpp
  30. +3 −2 DynamicResponseSystem/ActionPlayAnimation.cpp
  31. +0 −1 DynamicResponseSystem/ActionSwitch.cpp
  32. +0 −1 DynamicResponseSystem/ActionUnlock.cpp
  33. +1 −2 DynamicResponseSystem/ConditionDistanceToEntity.cpp
  34. +33 −60 Entities/Doors/AnimatedDoorComponent.cpp
  35. +36 −50 Entities/Doors/AnimatedDoorComponent.h
  36. +2 −0 Entities/EntityEffects.h
  37. +2 −2 Entities/Environment/Ledge/LedgeManager.h
  38. +5 −3 Entities/Gameplay/SpawnPoint.cpp
  39. +2 −2 Entities/Gameplay/SpawnPoint.h
  40. +21 −8 Entities/Gameplay/Weapons/Bullet.cpp
  41. +2 −2 Entities/Gameplay/Weapons/Bullet.h
  42. +1 −1 Entities/Gameplay/Weapons/ISimpleWeapon.h
  43. +31 −6 Entities/Gameplay/Weapons/Rifle.cpp
  44. +5 −1 Entities/Gameplay/Weapons/Rifle.h
  45. +1 −2 Entities/Helpers/ISimpleExtension.h
  46. +0 −100 Entities/Helpers/NativeEntityBase.cpp
  47. +0 −51 Entities/Helpers/NativeEntityBase.h
  48. +0 −119 Entities/Helpers/NativeEntityPropertyHandling.cpp
  49. +0 −70 Entities/Helpers/NativeEntityPropertyHandling.h
  50. +106 −84 Entities/Interaction/EntityAwarenessComponent.cpp
  51. +68 −55 Entities/Interaction/EntityAwarenessComponent.h
  52. +47 −57 Entities/Interaction/EntityInteractionComponent.cpp
  53. +37 −12 Entities/Interaction/EntityInteractionComponent.h
  54. +0 −118 Entities/Interaction/IEntityAwarenessComponent.h
  55. +1 −25 Entities/Interaction/{IEntityInteractionComponent.h → IEntityInteraction.h}
  56. +0 −182 Entities/Lights/EnvironmentProbe.cpp
  57. +0 −66 Entities/Lights/EnvironmentProbe.h
  58. +0 −167 Entities/Lights/LightEntity.cpp
  59. +0 −69 Entities/Lights/LightEntity.h
  60. +0 −8 Entities/Lockable/ILockableComponent.h
  61. +0 −8 Entities/Lockable/Keyring/IKeyringComponent.h
  62. +31 −23 Entities/Lockable/Keyring/KeyringComponent.cpp
  63. +22 −22 Entities/Lockable/Keyring/KeyringComponent.h
  64. +29 −41 Entities/Lockable/LockableComponent.cpp
  65. +20 −22 Entities/Lockable/LockableComponent.h
  66. +30 −14 Entities/Openable/Containers/ContainerComponent.cpp
  67. +33 −14 Entities/Openable/Containers/ContainerComponent.h
  68. +0 −8 Entities/Openable/Containers/IContainerComponent.h
  69. +0 −8 Entities/Openable/IOpenableComponent.h
  70. +0 −55 Entities/Physics/RigidBody.cpp
  71. +0 −29 Entities/Physics/RigidBody.h
  72. +0 −10 Entities/Switchable/ISwitchComponent.h
  73. +0 −29 Entities/Switchable/ISwitchableComponent.h
  74. +0 −64 Entities/Switchable/SwitchComponent.cpp
  75. +0 −58 Entities/Switchable/SwitchComponent.h
  76. +0 −64 Entities/Switchable/SwitchableComponent.cpp
  77. +0 −51 Entities/Switchable/SwitchableComponent.h
  78. +0 −202 FlowNodes/Helpers/FlowBaseNode.h
  79. +0 −273 FlowNodes/Helpers/FlowGameEntityNode.cpp
  80. +0 −125 FlowNodes/Helpers/FlowGameEntityNode.h
  81. +0 −206 Game/Game.cpp
  82. +0 −146 Game/Game.h
  83. +0 −69 Game/GameFactory.cpp
  84. +0 −313 Game/GameFactory.h
  85. +27 −21 Game/GameRules.cpp
  86. +1 −3 Game/GameRules.h
  87. +48 −28 Item/Flashlight/FlashlightComponent.cpp
  88. +32 −22 Item/Flashlight/FlashlightComponent.h
  89. +0 −2 Item/ISimpleItem.h
  90. +4 −6 Item/Item.cpp
  91. +0 −1 Item/Item.h
  92. +4 −4 Item/ItemAccessory.cpp
  93. +0 −1 Item/Parameters/ItemBaseParameter.cpp
  94. +0 −1 Item/Parameters/ItemGeometryParameter.cpp
  95. +5 −7 Player/Animations/PlayerAnimations.cpp
  96. +2 −1 Player/Animations/PlayerAnimations.h
  97. +42 −23 Player/Camera/ActionRPGCameraComponent.cpp
  98. +21 −11 Player/Camera/ActionRPGCameraComponent.h
  99. +45 −19 Player/Camera/CameraManagerComponent.cpp
  100. +25 −24 Player/Camera/CameraManagerComponent.h
  101. +39 −19 Player/Camera/FirstPersonCameraComponent.cpp
  102. +19 −8 Player/Camera/FirstPersonCameraComponent.h
  103. +2 −1 Player/Camera/ICameraComponent.cpp
  104. +5 −1 Player/Camera/ICameraComponent.h
  105. +0 −73 Player/Camera/ICameraManagerComponent.h
  106. +3 −0 Player/Input/IPlayerInputComponent.h
  107. +52 −31 Player/Input/PlayerInputComponent.cpp
  108. +26 −20 Player/Input/PlayerInputComponent.h
  109. +44 −99 Player/Player.cpp
  110. +33 −19 Player/Player.h
  111. +122 −0 Plugin/ChrysalisCore.cpp
  112. +70 −0 Plugin/ChrysalisCore.h
  113. +74 −0 Plugin/ChrysalisCorePlugin.cpp
  114. +109 −0 Plugin/ChrysalisCorePlugin.h
  115. +1 −1 SharedParameters/SharedParameters.h
  116. +0 −311 Startup/GameStartup.cpp
  117. +0 −53 Startup/GameStartup.h
  118. +5 −5 StateMachine/StateMachine.h
  119. +2 −2 StdAfx.h
  120. +14 −9 Utility/CryWatch.cpp
  121. +0 −82 Utility/Proxy.h

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -8,14 +8,16 @@
#include <Actor/ActorStance.h>
#include <Actor/IActorEventListener.h>
#include <CryAISystem/IAgent.h>
#include <CryEntitySystem/IEntityComponent.h>
#include <CryEntitySystem/IEntitySystem.h>
//#include <Actor/Character/Movement/CharacterRotation.h>

class CPlayer;
class CActorMovementController;
class IActionController;
struct SAnimationContext;
struct SActorMovementRequest;
struct IEntityAwarenessComponent;
class CEntityAwarenessComponent;


/** Represents all of the available actor class types. */
@@ -53,6 +55,13 @@ class CActor : public CGameObjectExtensionHelper<CActor, ISimpleActor, 40>, publ
{
public:

// IEntityComponent
void Initialize() override;
void ProcessEvent(SEntityEvent& event) override;
uint64 GetEventMask() const { return BIT64(ENTITY_EVENT_UPDATE) | BIT64(ENTITY_EVENT_PREPHYSICSUPDATE); }
//struct IEntityPropertyGroup* GetPropertyGroup() override { return this; }
// ~IEntityComponent

enum EProperties
{
// Animation.
@@ -74,17 +83,13 @@ class CActor : public CGameObjectExtensionHelper<CActor, ISimpleActor, 40>, publ
// ISimpleActor
bool Init(IGameObject * pGameObject) override;
void PostInit(IGameObject * pGameObject) override;
bool ReloadExtension(IGameObject * pGameObject, const SEntitySpawnParams &params) override;
void PostReloadExtension(IGameObject * pGameObject, const SEntitySpawnParams &params) override;
void FullSerialize(TSerialize ser) override;
void PostSerialize() override {};
void SerializeSpawnInfo(TSerialize ser) override {};
void Update(SEntityUpdateContext& ctx, int updateSlot) override;
void HandleEvent(const SGameObjectEvent& event) override;
void ProcessEvent(SEntityEvent& event) override;

// It is critical we override the event priority to ensure we handle the event before CAnimatedCharacter.
virtual IComponent::ComponentEventPriority GetEventPriority(const int eventID) const override;
virtual IEntityComponent::ComponentEventPriority GetEventPriority(const int eventID) const override;

int GetTeamId() const override { return m_teamId; };

@@ -362,6 +367,12 @@ class CActor : public CGameObjectExtensionHelper<CActor, ISimpleActor, 40>, publ

protected:

string m_geometry { "objects/default/primitive_box.cgf" };
float m_mass { 82.0f };
string m_controllerDefinition { "sdk_tutorial3controllerdefs.xml" };
string m_scopeContext { "MainCharacter" };
string m_animationDatabase { "sdk_tutorial3database.adb" };

/** Called to indicate the entity must reset itself. This is often done during PostInit() and
additionally by the editor when you both enter and leave game mode. */
virtual void Reset();
@@ -390,7 +401,6 @@ class CActor : public CGameObjectExtensionHelper<CActor, ISimpleActor, 40>, publ


private:

/** Specifies whether this instance is the client actor. */
bool m_isClient { false };

@@ -407,10 +417,10 @@ class CActor : public CGameObjectExtensionHelper<CActor, ISimpleActor, 40>, publ
SAnimationContext* m_pAnimationContext { nullptr };

/** An component which is used to discover entities near the actor. */
IEntityAwarenessComponent* m_pAwareness { nullptr };
CEntityAwarenessComponent* m_pAwareness { nullptr };

/** A dynamic response proxy. **/
IEntityDynamicResponseProxyPtr m_pDrsProxy { nullptr };
IEntityDynamicResponseComponent* m_pDrsComponent;

// HACK: to test switching movement and idle fragments. Should query physics instead.
// Keeping the actions here allows me to stop them, which is good for testing, but wrong in
@@ -2,6 +2,7 @@

#include <CryNetwork/ISerialize.h>
#include <CryMath/Cry_Vector3.h>
#include <CryCore/CryFlags.h>
#include <IGameObject.h>


@@ -31,7 +32,7 @@ struct SActorPhysics
, groundColliderId(0)*/
{}

void Serialize(TSerialize ser, EEntityAspects aspects);
void Serialize(TSerialize ser, EEntityAspects aspects) {};

CCryFlags<uint32> flags;

@@ -10,6 +10,7 @@ Provides a place to store the present state of an actor.
#include <ICryMannequin.h>
#include <CryAISystem/IAgent.h>
#include <Utility/AutoEnum.h>
#include <IAnimationGraph.h>


typedef TBitfield TActorStatusFlags;
@@ -1,12 +1,15 @@
#include <StdAfx.h>

#include "Character.h"
#include "Plugin/ChrysalisCorePlugin.h"
#include <Actor/Movement/ActorMovementController.h>
#include <Actor/Character/Movement/StateMachine/CharacterStateEvents.h>
#include <Actor/Movement/StateMachine/ActorStateUtility.h>
#include <Game/GameFactory.h>
#include <CrySerialization/Decorators/Resources.h>


//CRYREGISTER_CLASS(CCharacter)

// Definition of the state machine that controls character movement.
DEFINE_STATE_MACHINE(CCharacter, Movement);

@@ -17,62 +20,69 @@ class CCharacterRegistrator : public IEntityRegistrator
{
CCharacter::Register();
}

void Unregister() override {};
};

CCharacterRegistrator g_CharacterRegistrator;


void CCharacter::Register()
{
auto properties = new SNativeEntityPropertyInfo [eNumProperties];
memset(properties, 0, sizeof(SNativeEntityPropertyInfo) * eNumProperties);

RegisterEntityPropertyObject(properties, eProperty_Model, "Model", "", "Actor model");
RegisterEntityProperty<float>(properties, eProperty_Mass, "Mass", "82", "Actor mass", 0, 10000);
RegisterEntityProperty<string>(properties, eProperty_Controller_Definition, "ControllerDefinition", "sdk_tutorial3controllerdefs.xml", "Controller Definition", 0, 0);
RegisterEntityProperty<string>(properties, eProperty_Scope_Context, "ScopeContext", "MainCharacter", "Scope Context", 0, 0);
RegisterEntityProperty<string>(properties, eProperty_Animation_Database, "AnimationDatabase", "sdk_tutorial3database.adb", "Animation Database", 0, 0);

// Finally, register the entity class so that instances can be created later on either via Launcher or Editor
CGameFactory::RegisterNativeEntity<CCharacter>("Character", "Actors", "Light.bmp", 0u, properties, eNumProperties);
// Register the entity class so that instances can be created later on either via Launcher or Editor.
CChrysalisCorePlugin::RegisterEntityWithDefaultComponent<CCharacter>("Character");
//RegisterEntityWithDefaultComponent<CCharacter>("Character", "Actors", "Light.bmp");
}

// Create flownode
CGameEntityNodeFactory &nodeFactory = CGameFactory::RegisterEntityFlowNode("Character");

// Define input ports, and the callback function for when they are triggered
std::vector<SInputPortConfig> inputs;
inputs.push_back(InputPortConfig_Void("Open", "Open the door"));
inputs.push_back(InputPortConfig_Void("Close", "Close the door"));
nodeFactory.AddInputs(inputs, OnFlowgraphActivation);
void CCharacter::Initialize()
{
CActor::Initialize();

// Mark the factory as complete, indicating that there will be no additional ports
nodeFactory.Close();
//// TODO: Move the PostInit into here once we are free of GameObjects.
//PostInit(gEnv->pGameFramework->GetGameObject(GetEntityId()));
}


void CCharacter::OnFlowgraphActivation(EntityId entityId, IFlowNode::SActivationInfo *pActInfo, const class CFlowGameEntityNode *pNode)
void CCharacter::ProcessEvent(SEntityEvent& event)
{
if (auto pExtension = static_cast<CCharacter *>(QueryExtension(entityId)))
switch (event.event)
{
if (IsPortActive(pActInfo, eInputPort_Open))
{
// pExtension->SetPropertyBool(eProperty_IsOpen, true);
}
else if (IsPortActive(pActInfo, eInputPort_Close))
{
// pExtension->SetPropertyBool(eProperty_IsOpen, false);
}
}
}
// Physicalize on level start for Launcher
case ENTITY_EVENT_START_LEVEL:

// Editor specific, physicalize on reset, property change or transform change
case ENTITY_EVENT_RESET:
case ENTITY_EVENT_EDITOR_PROPERTY_CHANGED:
case ENTITY_EVENT_XFORM_FINISHED_EDITOR:
Reset();
break;

case ENTITY_EVENT_UPDATE:
// TODO: HACK: We don't have an update with ctx, updateslot - figure out how to do it the new way then switch
// this on.
//Update();
break;

CCharacter::CCharacter()
{
case ENTITY_EVENT_PREPHYSICSUPDATE:
PrePhysicsUpdate();
break;
}
}


CCharacter::~CCharacter()
void CCharacter::SerializeProperties(Serialization::IArchive& archive)
{
archive(Serialization::ModelFilename(m_geometry), "Geometry", "Geometry");
archive(m_mass, "Mass", "Mass");
archive(Serialization::CharacterAnimationPicker(m_controllerDefinition), "ControllerDefinition", "Controller Definition");
archive(Serialization::CharacterAnimationPicker(m_scopeContext), "ScopeContext", "Scope Context");
archive(Serialization::CharacterAnimationPicker(m_animationDatabase), "AnimationDatabase", "Animation Database");

if (!archive.isInput())
{
Reset();
}
}


@@ -93,23 +103,6 @@ void CCharacter::PostInit(IGameObject * pGameObject)
}


bool CCharacter::ReloadExtension(IGameObject * pGameObject, const SEntitySpawnParams &params)
{
CActor::ReloadExtension(pGameObject, params);

// Register for game object events again.
RegisterEvents();

return true;
}


void CCharacter::PostReloadExtension(IGameObject * pGameObject, const SEntitySpawnParams &params)
{
CActor::PostReloadExtension(pGameObject, params);
}


void CCharacter::Update(SEntityUpdateContext& ctx, int updateSlot)
{
CActor::Update(ctx, updateSlot);
@@ -122,28 +115,7 @@ void CCharacter::HandleEvent(const SGameObjectEvent& event)
}


void CCharacter::ProcessEvent(SEntityEvent& event)
{
switch (event.event)
{
// Physicalize on level start for Launcher
case ENTITY_EVENT_START_LEVEL:

// Editor specific, physicalize on reset, property change or transform change
case ENTITY_EVENT_RESET:
case ENTITY_EVENT_EDITOR_PROPERTY_CHANGED:
case ENTITY_EVENT_XFORM_FINISHED_EDITOR:
Reset();
break;

case ENTITY_EVENT_PREPHYSICSUPDATE:
PrePhysicsUpdate();
break;
}
}


IComponent::ComponentEventPriority CCharacter::GetEventPriority(const int eventID) const
IEntityComponent::ComponentEventPriority CCharacter::GetEventPriority(const int eventID) const
{
switch (eventID)
{
@@ -263,7 +235,6 @@ void CCharacter::RegisterEvents()
const int EventsToRegister [] =
{
eGFE_OnCollision, // Collision events.
eGFE_BecomeLocalPlayer, // Become client actor events.
eGFE_OnPostStep, // Not sure if it's needed for character animation here...but it is required for us to trap that event in this code.
};

@@ -3,7 +3,8 @@
#include <Actor/Actor.h>
#include <Actor/Character/Movement/CharacterRotation.h>
#include <StateMachine/StateMachine.h>
#include <Entities/Helpers/NativeEntityBase.h>
#include <CryEntitySystem/IEntityComponent.h>
#include <CryEntitySystem/IEntitySystem.h>


/**
@@ -17,39 +18,42 @@ Characters may have inventory.

// TODO: probably needs to also implement IInventoryListener to listen for inventory changes.

class CCharacter : public CActor
class CCharacter : public CGameObjectExtensionHelper<CCharacter, CActor>, public IEntityPropertyGroup
//class CCharacter : public CActor, public IEntityPropertyGroup
{
private:
//CRY_ENTITY_COMPONENT_INTERFACE_AND_CLASS(CCharacter, "Character", 0xE03CE1AB90954702, 0xBFECD3E9E39F408B)

// Declaration of the state machine that controls character movement.
DECLARE_STATE_MACHINE(CCharacter, Movement);

public:
enum EInputPorts
{
eInputPort_Open = 0,
eInputPort_Close
};

// IGameObjectExtension
// IEntityComponent
void Initialize() override;
void ProcessEvent(SEntityEvent& event) override;
uint64 GetEventMask() const { return BIT64(ENTITY_EVENT_UPDATE) | BIT64(ENTITY_EVENT_PREPHYSICSUPDATE); }
struct IEntityPropertyGroup* GetPropertyGroup() override { return this; }
// ~IEntityComponent

// IEntityPropertyGroup
const char* GetLabel() const { return "Character"; };
void SerializeProperties(Serialization::IArchive& archive);
// ~IEntityPropertyGroup

// ISimpleActor
void PostInit(IGameObject * pGameObject) override;
bool ReloadExtension(IGameObject * pGameObject, const SEntitySpawnParams &params) override;
void PostReloadExtension(IGameObject * pGameObject, const SEntitySpawnParams &params) override;
void PostSerialize() override {};
void SerializeSpawnInfo(TSerialize ser) override {};
void Update(SEntityUpdateContext& ctx, int updateSlot) override;
void HandleEvent(const SGameObjectEvent& event) override;
void ProcessEvent(SEntityEvent& event) override;

// It is critical we override the event priority to ensure we handle the event before CAnimatedCharacter.
virtual IComponent::ComponentEventPriority GetEventPriority(const int eventID) const override;
virtual IEntityComponent::ComponentEventPriority GetEventPriority(const int eventID) const override;
// ~IGameObjectExtension

// Called to register the entity class and its properties
static void Register();

// Called when one of the input Flowgraph ports are activated in one of the entity instances tied to this class
static void OnFlowgraphActivation(EntityId entityId, IFlowNode::SActivationInfo* pActInfo, const class CFlowGameEntityNode *pNode);

// IActor

/* You must override CActor for correct behaviour. */
@@ -66,8 +70,8 @@ class CCharacter : public CActor

public:

CCharacter();
virtual ~CCharacter();
CCharacter() {};
virtual ~CCharacter() {};

protected:

@@ -91,8 +95,6 @@ class CCharacter : public CActor
void RegisterEvents();


private:

// ***
// *** Life-cycle
// ***
Oops, something went wrong.

0 comments on commit 6dbf1ff

Please sign in to comment.