Protected inheritance, not even once.
This commit is contained in:
@@ -34,7 +34,7 @@ protected:
|
||||
, IsServer(params.IsServer)
|
||||
{
|
||||
if (IsClient) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &System::OnPlayerSpawned);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &System::setLocalPlayer);
|
||||
}
|
||||
}
|
||||
virtual ~System() = default;
|
||||
@@ -47,7 +47,7 @@ protected:
|
||||
|
||||
private:
|
||||
EventRelay<System, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
virtual bool setLocalPlayer(Events::PlayerSpawned& e)
|
||||
{
|
||||
if (e.PlayerID == -1) {
|
||||
LocalPlayer = e.Player;
|
||||
|
||||
@@ -52,8 +52,6 @@ private:
|
||||
bool OnDashAbility(const Events::DashAbility &e);
|
||||
EventRelay<SoundSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||
bool OnTriggerTouch(const Events::TriggerTouch &e);
|
||||
EventRelay<SoundSystem, Events::Shoot> m_EShoot;
|
||||
bool OnShoot(const Events::Shoot &e);
|
||||
EventRelay<SoundSystem, Events::Captured> m_ECaptured;
|
||||
bool OnCaptured(const Events::Captured &e);
|
||||
EventRelay<SoundSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "Core/Octree.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
#include "Systems/SpawnerSystem.h"
|
||||
#include "Sound/EPlaySoundOnEntity.h"
|
||||
|
||||
class WeaponBehaviour;
|
||||
|
||||
@@ -45,7 +46,7 @@ private:
|
||||
void selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot);
|
||||
};
|
||||
|
||||
class WeaponBehaviour : protected System
|
||||
class WeaponBehaviour : public System
|
||||
{
|
||||
public:
|
||||
WeaponBehaviour(SystemParams systemParams, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity)
|
||||
@@ -73,10 +74,7 @@ class AssaultWeaponBehaviour : public WeaponBehaviour
|
||||
public:
|
||||
AssaultWeaponBehaviour(SystemParams systemParams, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity)
|
||||
: WeaponBehaviour(systemParams, collisionOctree, weaponEntity)
|
||||
{
|
||||
m_RayRed = ResourceManager::Load<EntityFile>("Schema/Entities/RayRed.xml");
|
||||
m_RayBlue = ResourceManager::Load<EntityFile>("Schema/Entities/RayBlue.xml");
|
||||
}
|
||||
{ }
|
||||
|
||||
virtual void Fire() override
|
||||
{
|
||||
@@ -145,12 +143,17 @@ private:
|
||||
// Fire
|
||||
magAmmo -= 1;
|
||||
spawnTracer();
|
||||
playSound();
|
||||
|
||||
m_TimeSinceLastFire = 0.0;
|
||||
}
|
||||
|
||||
void spawnTracer()
|
||||
{
|
||||
if (!IsClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
EntityWrapper spawner;
|
||||
if (m_Entity == LocalPlayer) {
|
||||
spawner = m_Entity.FirstChildByName("WeaponMuzzle");
|
||||
@@ -165,60 +168,6 @@ private:
|
||||
Events::SpawnerSpawn e;
|
||||
e.Spawner = spawner;
|
||||
m_EventBroker->Publish(e);
|
||||
|
||||
//ComponentWrapper cTeam = m_Entity["Team"];
|
||||
//ComponentInfo::EnumType team = cTeam["Team"];
|
||||
|
||||
//// Select the right color of effect
|
||||
//EntityFile* rayFile = nullptr;
|
||||
//if (team == cTeam["Team"].Enum("Red")) {
|
||||
// rayFile = m_RayRed;
|
||||
//}
|
||||
//if (team == cTeam["Team"].Enum("Blue")) {
|
||||
// rayFile = m_RayBlue;
|
||||
//}
|
||||
//if (rayFile == nullptr) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
//// Create the entity
|
||||
//EntityFileParser parser(rayFile);
|
||||
//EntityID rayID = parser.MergeEntities(m_World);
|
||||
//EntityWrapper ray(m_World, rayID);
|
||||
|
||||
//// Figure out where to put it
|
||||
//EntityWrapper attachment;
|
||||
//if (m_Entity == LocalPlayer || true) {
|
||||
// // Spawn the effect from the weapon view model for the local player
|
||||
// attachment = m_Entity.FirstChildByName("WeaponMuzzle");
|
||||
//}
|
||||
//// TODO: Spawn the effect from the weapon world model once it exists
|
||||
|
||||
//glm::mat4 transformation = Transform::AbsoluteTransformation(attachment);
|
||||
//glm::vec3 _scale;
|
||||
//glm::vec3 translation;
|
||||
//glm::quat _orientation;
|
||||
//glm::vec3 _skew;
|
||||
//glm::vec4 _perspective;
|
||||
//glm::decompose(transformation, _scale, _orientation, translation, _skew, _perspective);
|
||||
//
|
||||
//// Matrix to euler angles
|
||||
//glm::vec3 euler;
|
||||
//euler.y = glm::asin(-transformation[0][2]);
|
||||
//if (cos(euler.y) != 0) {
|
||||
// euler.x = atan2(transformation[1][2], transformation[2][2]);
|
||||
// euler.z = atan2(transformation[0][1], transformation[0][0]);
|
||||
//} else {
|
||||
// euler.x = atan2(-transformation[2][0], transformation[1][1]);
|
||||
// euler.z = 0;
|
||||
//}
|
||||
|
||||
//// TODO: Spread?
|
||||
|
||||
//(glm::vec3&)ray["Transform"]["Position"] = translation;
|
||||
//(glm::vec3&)ray["Transform"]["Orientation"] = euler;
|
||||
//glm::vec3& scale = ray["Transform"]["Scale"];
|
||||
//scale.z = traceRayDistance(translation, glm::quat(euler) * glm::vec3(0.f, 0.f, -1.f));
|
||||
}
|
||||
|
||||
float traceRayDistance(glm::vec3 origin, glm::vec3 direction)
|
||||
@@ -226,6 +175,18 @@ private:
|
||||
// TODO: Cast a ray and size tracer appropriately
|
||||
return 100.f;
|
||||
}
|
||||
|
||||
void playSound()
|
||||
{
|
||||
if (!IsClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
Events::PlaySoundOnEntity e;
|
||||
e.EmitterID = m_Entity.ID;
|
||||
e.FilePath = "Audio/laser/laser1.wav";
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -107,7 +107,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>0.24743387388836702</Time1>
|
||||
<Time1>0.52743271827223559</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -126,8 +126,8 @@
|
||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.120747976" Y="-0.229536116" Z="-0.151475713"/>
|
||||
<Orientation X="0.0104047507" Y="-0.00268173264" Z="0.0428441092"/>
|
||||
<Position X="0.120747946" Y="-0.232330009" Z="-0.151475713"/>
|
||||
<Orientation X="0.0104046576" Y="-0.00268170447" Z="0.0428439789"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -137,7 +137,7 @@
|
||||
<EntityFile>Schema/Entities/RayBlue.xml</EntityFile>
|
||||
</c:Spawner>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.0480000004" Z="-0.807000041"/>
|
||||
<Position X="0.00325386273" Y="0.0970000029" Z="-0.843000054"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -166,6 +166,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>0.69666320633760392</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:AnimationOffset>
|
||||
@@ -189,8 +190,8 @@
|
||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.156722724" Y="1.03299165" Z="-0.216208369"/>
|
||||
<Orientation X="-0.062651813" Y="-0.0297243949" Z="0.120719783"/>
|
||||
<Position X="0.162715688" Y="1.02479136" Z="-0.215626657"/>
|
||||
<Orientation X="-0.0629899353" Y="-0.0542047173" Z="0.11849726"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
|
||||
@@ -67,7 +67,7 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
|
||||
|
||||
// Hide things parented to local player if they have the HiddenFromLocalPlayer component
|
||||
if ((entity.HasComponent("HiddenForLocalPlayer") || entity.FirstParentWithComponent("HiddenForLocalPlayer").Valid()) && (entity == m_LocalPlayer || entity.IsChildOf(m_LocalPlayer))) {
|
||||
//continue;
|
||||
continue;
|
||||
}
|
||||
|
||||
Model* model;
|
||||
|
||||
@@ -91,7 +91,7 @@ bool PlayerSpawnSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
if (cameraEntity.Valid()) {
|
||||
Events::SetCamera e;
|
||||
e.CameraEntity = cameraEntity;
|
||||
//m_EventBroker->Publish(e);
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
// HACK: Set the player model color to team color
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
SoundSystem::SoundSystem(SystemParams params)
|
||||
: System(params)
|
||||
, PureSystem("SoundEmitter")
|
||||
//, ImpureSystem()
|
||||
{
|
||||
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
m_Announcer = ResourceManager::Load<ConfigFile>("Config.ini")->Get<std::string>("Sound.Announcer", "female");
|
||||
@@ -11,7 +10,6 @@ SoundSystem::SoundSystem(SystemParams params)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_InputCommand, &SoundSystem::OnInputCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &SoundSystem::OnDoubleJump);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDashAbility, &SoundSystem::OnDashAbility);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EShoot, &SoundSystem::OnShoot);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch);
|
||||
@@ -90,15 +88,6 @@ bool SoundSystem::drumTimer(double dt)
|
||||
}
|
||||
}
|
||||
|
||||
bool SoundSystem::OnShoot(const Events::Shoot & e)
|
||||
{
|
||||
Events::PlaySoundOnEntity ev;
|
||||
ev.EmitterID = LocalPlayer.ID;
|
||||
ev.FilePath = "Audio/laser/laser1.wav";
|
||||
m_EventBroker->Publish(ev);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SoundSystem::OnCaptured(const Events::Captured & e)
|
||||
{
|
||||
int homeTeam = (int)m_World->GetComponent(e.CapturePointID, "Team")["Team"];
|
||||
|
||||
@@ -21,13 +21,11 @@ void WeaponSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPla
|
||||
{
|
||||
// Update potential weapon behaviour for player
|
||||
auto it = m_ActiveWeapons.find(entity);
|
||||
if (it != m_ActiveWeapons.end()) {
|
||||
if (it->first.Valid()) {
|
||||
it->second->Update(dt);
|
||||
} else {
|
||||
m_ActiveWeapons.erase(it);
|
||||
}
|
||||
if (it == m_ActiveWeapons.end()) {
|
||||
selectWeapon(entity, 1);
|
||||
}
|
||||
|
||||
m_ActiveWeapons.at(entity)->Update(dt);
|
||||
}
|
||||
|
||||
bool WeaponSystem::OnInputCommand(Events::InputCommand& e)
|
||||
@@ -45,7 +43,7 @@ bool WeaponSystem::OnInputCommand(Events::InputCommand& e)
|
||||
// Weapon selection
|
||||
if (e.Command == "SelectWeapon") {
|
||||
if (e.Value != 0) {
|
||||
selectWeapon(player, static_cast<ComponentInfo::EnumType>(e.Value));
|
||||
//selectWeapon(player, static_cast<ComponentInfo::EnumType>(e.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +70,7 @@ void WeaponSystem::selectWeapon(EntityWrapper player, ComponentInfo::EnumType sl
|
||||
if (m_ActiveWeapons.count(player) == 0) {
|
||||
m_ActiveWeapons.insert(std::make_pair(player, std::make_shared<AssaultWeaponBehaviour>(m_SystemParams, m_CollisionOctree, player)));
|
||||
} else {
|
||||
m_ActiveWeapons.erase(player);
|
||||
//m_ActiveWeapons.erase(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +84,6 @@ bool WeaponSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
{
|
||||
// Select primary weapon on player spawn
|
||||
// TODO: Select the active one specified by player component
|
||||
selectWeapon(e.Player, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -137,4 +134,4 @@ bool WeaponSystem::OnShoot(Events::Shoot& eShoot)
|
||||
m_EventBroker->Publish(ePlayerDamage);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user