Hacked in serverside effects
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#define Events_InputCommand_h__
|
#define Events_InputCommand_h__
|
||||||
|
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
|
#include "Core/EntityWrapper.h"
|
||||||
|
|
||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
@@ -10,6 +11,7 @@ struct InputCommand : Event
|
|||||||
{
|
{
|
||||||
/** Numerical ID of the player. */
|
/** Numerical ID of the player. */
|
||||||
int PlayerID;
|
int PlayerID;
|
||||||
|
EntityWrapper Player;
|
||||||
/** The command that was sent. */
|
/** The command that was sent. */
|
||||||
std::string Command;
|
std::string Command;
|
||||||
/** The value of the command. */
|
/** The value of the command. */
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
</Team>
|
</Team>
|
||||||
</c:Team>
|
</c:Team>
|
||||||
<c:Transform>
|
<c:Transform>
|
||||||
<Position X="-7.12165165" Y="0.0265000015" Z="6.04289007"/>
|
<Position X="-7.12165165" Y="0" Z="6.04289007"/>
|
||||||
<Orientation X="0" Y="2.24449515" Z="0"/>
|
<Orientation X="0" Y="2.24449515" Z="0"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
@@ -120,20 +120,7 @@
|
|||||||
<Position X="0.215000004" Y="-0.153000012" Z="-0.266000003"/>
|
<Position X="0.215000004" Y="-0.153000012" Z="-0.266000003"/>
|
||||||
</c:Transform>
|
</c:Transform>
|
||||||
</Components>
|
</Components>
|
||||||
<Children>
|
<Children/>
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/CylinderBullet.mesh</Resource>
|
|
||||||
<Color A="1" B="0" G="0.525490224" R="39.2156868"/>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Scale X="0.0110000009" Y="0.029000001" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
</Children>
|
||||||
</Entity>
|
</Entity>
|
||||||
@@ -157,7 +144,7 @@
|
|||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Hold Pos</Name>
|
<Name>Hold Pos</Name>
|
||||||
<Time>0.86791076003269829</Time>
|
<Time>0.23794697999039638</Time>
|
||||||
<Speed>1</Speed>
|
<Speed>1</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
|
|||||||
@@ -99,6 +99,10 @@ EntityWrapper::operator bool()
|
|||||||
|
|
||||||
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
|
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
|
||||||
{
|
{
|
||||||
|
if (!this->World->ValidEntity(parent)) {
|
||||||
|
return EntityWrapper::Invalid;
|
||||||
|
}
|
||||||
|
|
||||||
auto itPair = this->World->GetChildren(parent);
|
auto itPair = this->World->GetChildren(parent);
|
||||||
if (itPair.first == itPair.second) {
|
if (itPair.first == itPair.second) {
|
||||||
return EntityWrapper::Invalid;
|
return EntityWrapper::Invalid;
|
||||||
|
|||||||
@@ -269,6 +269,7 @@ void Server::parseOnInputCommand(Packet& packet)
|
|||||||
Events::InputCommand e;
|
Events::InputCommand e;
|
||||||
e.Command = packet.ReadString();
|
e.Command = packet.ReadString();
|
||||||
e.PlayerID = player; // Set correct player id
|
e.PlayerID = player; // Set correct player id
|
||||||
|
e.Player = EntityWrapper(m_World, m_ConnectedPlayers.at(player).EntityID);
|
||||||
e.Value = packet.ReadPrimitive<float>();
|
e.Value = packet.ReadPrimitive<float>();
|
||||||
m_EventBroker->Publish(e);
|
m_EventBroker->Publish(e);
|
||||||
//LOG_INFO("Server::parseOnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
//LOG_INFO("Server::parseOnInputCommand: Command is %s. Value is %f. PlayerID is %i.", e.Command.c_str(), e.Value, e.PlayerID);
|
||||||
|
|||||||
@@ -25,14 +25,13 @@ bool WeaponSystem::OnPlayerSpawned(const Events::PlayerSpawned& e)
|
|||||||
|
|
||||||
bool WeaponSystem::OnInputCommand(const Events::InputCommand& e)
|
bool WeaponSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
{
|
{
|
||||||
// Only shoot if the player is alive
|
|
||||||
if (!m_LocalPlayer.Valid()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.Command == "PrimaryFire" && e.Value > 0) {
|
if (e.Command == "PrimaryFire" && e.Value > 0) {
|
||||||
Events::Shoot eShoot;
|
Events::Shoot eShoot;
|
||||||
eShoot.Player = m_LocalPlayer;
|
if (e.PlayerID == -1) {
|
||||||
|
eShoot.Player = m_LocalPlayer;
|
||||||
|
} else {
|
||||||
|
eShoot.Player = e.Player;
|
||||||
|
}
|
||||||
m_EventBroker->Publish(eShoot);
|
m_EventBroker->Publish(eShoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,6 +40,10 @@ bool WeaponSystem::OnInputCommand(const Events::InputCommand& e)
|
|||||||
|
|
||||||
bool WeaponSystem::OnShoot(Events::Shoot& eShoot)
|
bool WeaponSystem::OnShoot(Events::Shoot& eShoot)
|
||||||
{
|
{
|
||||||
|
if (!eShoot.Player.Valid()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Weapon firing effects here
|
// TODO: Weapon firing effects here
|
||||||
|
|
||||||
auto rayRed = ResourceManager::Load<EntityFile>("Schema/Entities/RayRed.xml");
|
auto rayRed = ResourceManager::Load<EntityFile>("Schema/Entities/RayRed.xml");
|
||||||
|
|||||||
Reference in New Issue
Block a user