mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 06:33:49 +00:00
Merge branch 'GameObjectExamples' of https://github.com/Areloch/Torque3D into development
This commit is contained in:
commit
471254ac0c
20 changed files with 709 additions and 0 deletions
42
Engine/source/T3D/gameObjects/aiPlayerObject.cpp
Normal file
42
Engine/source/T3D/gameObjects/aiPlayerObject.cpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#include "aiPlayerObject.h"
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(AIPlayerObject);
|
||||
|
||||
AIPlayerObject::AIPlayerObject()
|
||||
: mAIControllerComponent(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
AIPlayerObject::~AIPlayerObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool AIPlayerObject::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
//If we don't delinate from the template, just spawn as apropos here
|
||||
if (!mDirtyGameObject)
|
||||
{
|
||||
//AI Controller
|
||||
mAIControllerComponent = new AIControllerComponent();
|
||||
if (!mAIControllerComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add mAIControllerComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mAIControllerComponent->setInternalName("aiControllerComponent");
|
||||
|
||||
addComponent(mAIControllerComponent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AIPlayerObject::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
}
|
||||
20
Engine/source/T3D/gameObjects/aiPlayerObject.h
Normal file
20
Engine/source/T3D/gameObjects/aiPlayerObject.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include "playerObject.h"
|
||||
|
||||
#include "T3D/components/ai/aiControllerComponent.h"
|
||||
|
||||
class AIPlayerObject : public PlayerObject
|
||||
{
|
||||
typedef PlayerObject Parent;
|
||||
|
||||
AIControllerComponent* mAIControllerComponent;
|
||||
|
||||
public:
|
||||
AIPlayerObject();
|
||||
~AIPlayerObject();
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
|
||||
DECLARE_CONOBJECT(AIPlayerObject);
|
||||
};
|
||||
165
Engine/source/T3D/gameObjects/playerObject.cpp
Normal file
165
Engine/source/T3D/gameObjects/playerObject.cpp
Normal file
|
|
@ -0,0 +1,165 @@
|
|||
#include "playerObject.h"
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(PlayerObject);
|
||||
|
||||
PlayerObject::PlayerObject()
|
||||
: mMeshComponent(nullptr),
|
||||
mCollisionComponent(nullptr),
|
||||
mAnimationComponent(nullptr),
|
||||
mPhysicsComponent(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
PlayerObject::~PlayerObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool PlayerObject::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
//If we don't delinate from the template, just spawn as apropos here
|
||||
if (!mDirtyGameObject)
|
||||
{
|
||||
//Mesh
|
||||
mMeshComponent = new MeshComponent();
|
||||
if (!mMeshComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add MeshComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mMeshComponent->setInternalName("meshComponent");
|
||||
|
||||
addComponent(mMeshComponent);
|
||||
|
||||
//Collision
|
||||
mCollisionComponent = new ShapeCollisionComponent();
|
||||
if (!mCollisionComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add ShapeCollisionComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mCollisionComponent->setInternalName("collisionComponent");
|
||||
|
||||
addComponent(mCollisionComponent);
|
||||
|
||||
//Animation
|
||||
mAnimationComponent = new ActionAnimationComponent();
|
||||
if (!mAnimationComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add ActionAnimationComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mAnimationComponent->setInternalName("animationComponent");
|
||||
|
||||
addComponent(mAnimationComponent);
|
||||
|
||||
//Arm Animation
|
||||
mArmAnimationComponent = new ArmAnimationComponent();
|
||||
if (!mArmAnimationComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add ArmAnimationComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mArmAnimationComponent->setInternalName("armAnimationComponent");
|
||||
|
||||
addComponent(mArmAnimationComponent);
|
||||
|
||||
//Physics control
|
||||
mPhysicsComponent = new PlayerControllerComponent();
|
||||
if (!mPhysicsComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add PhysicsComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mPhysicsComponent->setInternalName("physicsComponent");
|
||||
|
||||
addComponent(mPhysicsComponent);
|
||||
|
||||
//State Machine
|
||||
mStateMachineComponent = new StateMachineComponent();
|
||||
if (!mStateMachineComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add StateMachineComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mStateMachineComponent->setInternalName("stateMachineComponent");
|
||||
|
||||
addComponent(mStateMachineComponent);
|
||||
|
||||
//Camera
|
||||
mCameraComponent = new CameraComponent();
|
||||
if (!mCameraComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add CameraComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mCameraComponent->setInternalName("cameraComponent");
|
||||
|
||||
addComponent(mCameraComponent);
|
||||
|
||||
//Camera Orbiter
|
||||
mCameraOrbiterComponent = new CameraOrbiterComponent();
|
||||
if (!mCameraOrbiterComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add CameraOrbiterComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mCameraOrbiterComponent->setInternalName("cameraOrbiterComponent");
|
||||
|
||||
addComponent(mCameraOrbiterComponent);
|
||||
|
||||
//Control Object
|
||||
mControlObjectComponent = new ControlObjectComponent();
|
||||
if (!mControlObjectComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add ControlObjectComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mControlObjectComponent->setInternalName("controlObjectComponent");
|
||||
|
||||
addComponent(mControlObjectComponent);
|
||||
|
||||
//Sound
|
||||
mSoundComponent = new SoundComponent();
|
||||
if (!mSoundComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add SoundComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mSoundComponent->setInternalName("soundComponent");
|
||||
|
||||
addComponent(mSoundComponent);
|
||||
|
||||
//Interaction
|
||||
mInteractComponent = new InteractComponent();
|
||||
if (!mInteractComponent->registerObject())
|
||||
{
|
||||
Con::errorf("PlayerObject::onAdd - unable to add InteractComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mInteractComponent->setInternalName("interactComponent");
|
||||
|
||||
addComponent(mInteractComponent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void PlayerObject::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
}
|
||||
40
Engine/source/T3D/gameObjects/playerObject.h
Normal file
40
Engine/source/T3D/gameObjects/playerObject.h
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#pragma once
|
||||
|
||||
#include "T3D/entity.h"
|
||||
#include "T3D/components/render/meshComponent.h"
|
||||
#include "T3D/components/collision/shapeCollisionComponent.h"
|
||||
#include "T3D/components/animation/actionAnimationComponent.h"
|
||||
#include "T3D/components/animation/armAnimationComponent.h"
|
||||
#include "T3D/components/physics/playerControllerComponent.h"
|
||||
#include "T3D/components/game/stateMachineComponent.h"
|
||||
#include "T3D/components/camera/cameraComponent.h"
|
||||
#include "T3D/components/camera/cameraOrbiterComponent.h"
|
||||
#include "T3D/components/game/controlObjectComponent.h"
|
||||
#include "T3D/components/audio/soundComponent.h"
|
||||
#include "T3D/components/game/interactComponent.h"
|
||||
|
||||
class PlayerObject : public Entity
|
||||
{
|
||||
typedef Entity Parent;
|
||||
|
||||
MeshComponent* mMeshComponent;
|
||||
ShapeCollisionComponent* mCollisionComponent;
|
||||
ActionAnimationComponent* mAnimationComponent;
|
||||
ArmAnimationComponent* mArmAnimationComponent;
|
||||
PlayerControllerComponent* mPhysicsComponent;
|
||||
StateMachineComponent* mStateMachineComponent;
|
||||
CameraComponent* mCameraComponent;
|
||||
CameraOrbiterComponent* mCameraOrbiterComponent;
|
||||
ControlObjectComponent* mControlObjectComponent;
|
||||
SoundComponent* mSoundComponent;
|
||||
InteractComponent* mInteractComponent;
|
||||
|
||||
public:
|
||||
PlayerObject();
|
||||
~PlayerObject();
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
|
||||
DECLARE_CONOBJECT(PlayerObject);
|
||||
};
|
||||
38
Engine/source/T3D/gameObjects/soundEmitterObject.cpp
Normal file
38
Engine/source/T3D/gameObjects/soundEmitterObject.cpp
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
#include "SoundEmitterObject.h"
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(SoundEmitterObject);
|
||||
|
||||
SoundEmitterObject::SoundEmitterObject()
|
||||
: mSoundComponent(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
SoundEmitterObject::~SoundEmitterObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool SoundEmitterObject::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
//Sound
|
||||
mSoundComponent = new SoundComponent();
|
||||
if (!mSoundComponent->registerObject())
|
||||
{
|
||||
Con::errorf("SoundEmitterObject::onAdd - unable to add soundComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mSoundComponent->setInternalName("soundComponent");
|
||||
|
||||
addComponent(mSoundComponent);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void SoundEmitterObject::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
}
|
||||
20
Engine/source/T3D/gameObjects/soundEmitterObject.h
Normal file
20
Engine/source/T3D/gameObjects/soundEmitterObject.h
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
|
||||
#include "T3D/entity.h"
|
||||
#include "T3D/components/audio/soundComponent.h"
|
||||
|
||||
class SoundEmitterObject : public Entity
|
||||
{
|
||||
typedef Entity Parent;
|
||||
|
||||
SoundComponent* mSoundComponent;
|
||||
|
||||
public:
|
||||
SoundEmitterObject();
|
||||
~SoundEmitterObject();
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
|
||||
DECLARE_CONOBJECT(SoundEmitterObject);
|
||||
};
|
||||
68
Engine/source/T3D/gameObjects/staticShapeObject.cpp
Normal file
68
Engine/source/T3D/gameObjects/staticShapeObject.cpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#include "staticShapeObject.h"
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(StaticShapeObject);
|
||||
|
||||
StaticShapeObject::StaticShapeObject()
|
||||
: mMeshComponent(nullptr),
|
||||
mCollisionComponent(nullptr),
|
||||
mAnimationComponent(nullptr)
|
||||
{
|
||||
|
||||
}
|
||||
StaticShapeObject::~StaticShapeObject()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool StaticShapeObject::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
//If we don't delinate from the template, just spawn as apropos here
|
||||
if (!mDirtyGameObject)
|
||||
{
|
||||
//Mesh
|
||||
mMeshComponent = new MeshComponent();
|
||||
if (!mMeshComponent->registerObject())
|
||||
{
|
||||
Con::errorf("StaticShapeObject::onAdd - unable to add MeshComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mMeshComponent->setInternalName("meshComponent");
|
||||
|
||||
addComponent(mMeshComponent);
|
||||
|
||||
//Collision
|
||||
mCollisionComponent = new ShapeCollisionComponent();
|
||||
if (!mCollisionComponent->registerObject())
|
||||
{
|
||||
Con::errorf("StaticShapeObject::onAdd - unable to add ShapeCollisionComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mCollisionComponent->setInternalName("collisionComponent");
|
||||
|
||||
addComponent(mCollisionComponent);
|
||||
|
||||
//Animation
|
||||
mAnimationComponent = new AnimationComponent();
|
||||
if (!mAnimationComponent->registerObject())
|
||||
{
|
||||
Con::errorf("StaticShapeObject::onAdd - unable to add AnimationComponent!");
|
||||
return false;
|
||||
}
|
||||
|
||||
mAnimationComponent->setInternalName("animationComponent");
|
||||
|
||||
addComponent(mAnimationComponent);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void StaticShapeObject::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
}
|
||||
28
Engine/source/T3D/gameObjects/staticShapeObject.h
Normal file
28
Engine/source/T3D/gameObjects/staticShapeObject.h
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include "T3D/entity.h"
|
||||
#include "T3D/components/render/meshComponent.h"
|
||||
#include "T3D/components/collision/shapeCollisionComponent.h"
|
||||
#include "T3D/components/animation/animationComponent.h"
|
||||
|
||||
class StaticShapeObject : public Entity
|
||||
{
|
||||
typedef Entity Parent;
|
||||
|
||||
MeshComponent* mMeshComponent;
|
||||
ShapeCollisionComponent* mCollisionComponent;
|
||||
AnimationComponent* mAnimationComponent;
|
||||
|
||||
public:
|
||||
StaticShapeObject();
|
||||
~StaticShapeObject();
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
|
||||
MeshComponent* getMeshComponent() { return mMeshComponent; }
|
||||
ShapeCollisionComponent* getCollisionComponent() { return mCollisionComponent; }
|
||||
AnimationComponent* getAnimationComponent() { return mAnimationComponent; }
|
||||
|
||||
DECLARE_CONOBJECT(StaticShapeObject);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue