Hacked in serverside effects

This commit is contained in:
2016-01-25 11:56:40 +01:00
parent 4245264029
commit b6fd18baed
5 changed files with 19 additions and 22 deletions
+4
View File
@@ -99,6 +99,10 @@ EntityWrapper::operator bool()
EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name, EntityID parent)
{
if (!this->World->ValidEntity(parent)) {
return EntityWrapper::Invalid;
}
auto itPair = this->World->GetChildren(parent);
if (itPair.first == itPair.second) {
return EntityWrapper::Invalid;
+1
View File
@@ -269,6 +269,7 @@ void Server::parseOnInputCommand(Packet& packet)
Events::InputCommand e;
e.Command = packet.ReadString();
e.PlayerID = player; // Set correct player id
e.Player = EntityWrapper(m_World, m_ConnectedPlayers.at(player).EntityID);
e.Value = packet.ReadPrimitive<float>();
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);
+9 -6
View File
@@ -25,14 +25,13 @@ bool WeaponSystem::OnPlayerSpawned(const Events::PlayerSpawned& 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) {
Events::Shoot eShoot;
eShoot.Player = m_LocalPlayer;
if (e.PlayerID == -1) {
eShoot.Player = m_LocalPlayer;
} else {
eShoot.Player = e.Player;
}
m_EventBroker->Publish(eShoot);
}
@@ -41,6 +40,10 @@ bool WeaponSystem::OnInputCommand(const Events::InputCommand& e)
bool WeaponSystem::OnShoot(Events::Shoot& eShoot)
{
if (!eShoot.Player.Valid()) {
return false;
}
// TODO: Weapon firing effects here
auto rayRed = ResourceManager::Load<EntityFile>("Schema/Entities/RayRed.xml");