Compare commits

..

4 Commits

Author SHA1 Message Date
William Moberg 8a8c375d3a Merge remote-tracking branch 'origin/master' into BoxModelCollision 2016-03-10 09:57:33 +01:00
William Moberg 8936b3d6c3 Probably fixed all the jittering, won't need the jitter guard anymore. 2016-03-09 19:45:26 +01:00
William Moberg 8a3564ad49 Merge remote-tracking branch 'origin/master' into BoxModelCollision 2016-03-09 18:03:39 +01:00
William Moberg 9581e9ac84 Don't set the player to previous position when uncrouching. 2016-03-09 17:51:26 +01:00
27 changed files with 34 additions and 186 deletions
+2 -2
View File
@@ -2,14 +2,14 @@
#define EEntityDeleted_h__
#include "Event.h"
#include "EntityWrapper.h"
#include "Entity.h"
namespace Events
{
struct EntityDeleted : Event
{
EntityWrapper DeletedEntity;
EntityID DeletedEntity;
// True if the entity deletion was triggered because the entity's parent was deleted before it
bool Cascaded;
};
-28
View File
@@ -1,28 +0,0 @@
#ifndef RespawnSystem_h__
#define RespawnSystem_h__
#include "System.h"
#include "SpawnerSystem.h"
#include "EEntityDeleted.h"
#include "EPause.h"
class RespawnSystem : public PureSystem
{
public:
RespawnSystem(SystemParams params);
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cRespawn, double dt) override;
private:
std::unordered_map<EntityWrapper, EntityWrapper> m_LastRespawnedEntity;
bool m_Paused = false;
EventRelay<RespawnSystem, Events::EntityDeleted> m_EEntityDeleted;
bool OnEntityDeleted(const Events::EntityDeleted& e);
EventRelay<RespawnSystem, Events::Pause> m_EPause;
bool OnPause(const Events::Pause& e);
EventRelay<RespawnSystem, Events::Resume> m_EResume;
bool OnResume(const Events::Resume& e);
};
#endif
+1 -1
View File
@@ -68,7 +68,7 @@ protected:
const std::string m_ComponentType;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cComponent, double dt) = 0;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) = 0;
};
class ImpureSystem : public virtual System
+1 -1
View File
@@ -22,7 +22,7 @@
#include "../Core/ELockMouse.h"
#include "../Core/EFileDropped.h"
#include "../Rendering/Texture.h"
#include "../Core/ESpawnerSpawn.h"
#include "Game/Events/ESpawnerSpawn.h"
class EditorGUI
{
@@ -19,6 +19,7 @@ public:
virtual const glm::vec3 Rotation() const { return m_Rotation; }
virtual bool Jumping() const { return m_Jumping; }
virtual bool Crouching() const { return m_Crouching; }
virtual bool CrouchingLastFrame() const { return m_CrouchingLastFrame; }
virtual bool DoubleJumping() const { return m_DoubleJumping; }
virtual void SetDoubleJumping(bool isDoubleJumping) {
m_DoubleJumping = isDoubleJumping;
@@ -44,6 +45,7 @@ protected:
bool m_Jumping = false;
bool m_DoubleJumping = false;
bool m_Crouching = false;
bool m_CrouchingLastFrame = false;
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
double m_AssaultDashDoubleTapDeltaTime = 0.0;
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
@@ -82,6 +84,7 @@ void FirstPersonInputController<EventContext>::Reset()
{
m_Rotation = glm::vec3(0.f, 0.f, 0.f);
m_Jumping = false;
m_CrouchingLastFrame = m_Crouching;
}
template <typename EventContext>
+1 -1
View File
@@ -5,7 +5,7 @@
#include "Rendering/IRenderer.h"
#include "Core/ResourceManager.h"
#include "Core/Event.h"
#include "Core/SpawnerSystem.h"
#include "Systems/SpawnerSystem.h"
#include "GUI/EButtonClicked.h"
+2 -2
View File
@@ -1,7 +1,7 @@
#include "Core/System.h"
#include "Input/EInputCommand.h"
#include "Core/SpawnerSystem.h"
#include "Core/ESpawnerSpawn.h"
#include "Systems/SpawnerSystem.h"
#include "Events/ESpawnerSpawn.h"
#include "Core/EPlayerSpawned.h"
#include "Core/EPlayerDeath.h"
#include "Rendering/ESetCamera.h"
+1 -1
View File
@@ -5,7 +5,7 @@
#include "Rendering/IRenderer.h"
#include "Core/ResourceManager.h"
#include "Core/Event.h"
#include "Core/SpawnerSystem.h"
#include "Systems/SpawnerSystem.h"
#include "Core/EventBroker.h"
#include "Network/ESearchForServers.h"
@@ -5,7 +5,7 @@
#include "Common.h"
#include "GLM.h"
#include "Core/System.h"
#include "Core/ESpawnerSpawn.h"
#include "Events/ESpawnerSpawn.h"
#include "Core/Transform.h"
#include "Core/EntityFile.h"
@@ -6,7 +6,7 @@
#include "Core/Octree.h"
#include "Collision/EntityAABB.h"
#include "Input/EInputCommand.h"
#include "Core/SpawnerSystem.h"
#include "Systems/SpawnerSystem.h"
#include "Rendering/ESetCamera.h"
#include "Core/ConfigFile.h"
#include "Rendering/EAutoAnimationBlend.h"
-1
View File
@@ -68,5 +68,4 @@
<xs:include schemaLocation="Components/NetworkComponent.xsd"/>
<xs:include schemaLocation="Components/ServerIdentity.xsd"/>
<xs:include schemaLocation="Components/ServerList.xsd"/>
<xs:include schemaLocation="Components/Respawn.xsd"/>
</xs:schema>
-5
View File
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Respawn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Respawn.xsd">
<Delay>0</Delay>
<_RespawnCountdown>0</_RespawnCountdown>
</Respawn>
-17
View File
@@ -1,17 +0,0 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
<xs:element name="Respawn">
<xs:annotation>
<xs:documentation>Triggers a Spawner component after its last spawned entity is destroyed with an optional delay.</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Delay" type="t:double" minOccurs="0"/>
<xs:element name="_RespawnCountdown" type="t:double" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
+8 -2
View File
@@ -2,13 +2,19 @@
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:NetworkComponent/>
<c:HealthPickup/>
<c:Model>
<Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource>
</c:Model>
<c:NetworkComponent/>
<c:RaptorCopter>
<Speed>8</Speed>
<Axis X="0" Y="0.100000001" Z="0"/>
</c:RaptorCopter>
<c:Transform>
<Scale X="0.25" Y="0.25" Z="0.25"/>
<Position X="0" Y="2.36784196" Z="0"/>
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
<Orientation X="0" Y="18767.0273" Z="0"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -1,58 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="0" Y="-0.871185362" Z="1.77631724"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Model>
<Resource>Models/Props/PickUps/PickUpHolder.mesh</Resource>
<Shadow>false</Shadow>
</c:Model>
<c:Transform>
<Scale X="0.479999989" Y="0.479999989" Z="0.479999989"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="0" Y="1.41138339" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Respawn>
<Delay>3</Delay>
</c:Respawn>
<c:RaptorCopter>
<Speed>1</Speed>
<Axis X="0" Y="1" Z="0"/>
</c:RaptorCopter>
<c:FloatingEffect>
<Period>2</Period>
<Time>75.797556530109119</Time>
<Axis X="0" Y="0.200000003" Z="0"/>
</c:FloatingEffect>
<c:Spawner>
<EntityFile>Schema/Entities/HealthPickup.xml</EntityFile>
</c:Spawner>
<c:Transform>
<Position X="-0" Y="-0.118795805" Z="-0"/>
<Orientation X="0" Y="13.0735149" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
-1
View File
@@ -71,7 +71,6 @@
<xs:element ref="c:NetworkComponent" minOccurs="0"/>
<xs:element ref="c:ServerIdentity" minOccurs="0"/>
<xs:element ref="c:ServerList" minOccurs="0"/>
<xs:element ref="c:Respawn" minOccurs="0"/>
</xs:all>
</xs:complexType>
</xs:element>
+1
View File
@@ -470,6 +470,7 @@ bool AABBvsTriangle(const AABB& box,
}
glm::vec3 cornerResolution = (1+t) * diagonal;
cornerResolution = glm::dot(cornerResolution, triNormal) * triNormal;
//Overwrite the smallest resolution if cornerResolution is smaller.
float lenSq = glm::length2(cornerResolution);
if (lenSq < resolveShortest.DistanceSq) {
+1 -2
View File
@@ -88,12 +88,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
bool isOnGround = (bool)cPhysics["IsOnGround"];
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
(glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) {
-54
View File
@@ -1,54 +0,0 @@
#include "Core/RespawnSystem.h"
RespawnSystem::RespawnSystem(SystemParams params)
: System(params)
, PureSystem("Respawn")
{
EVENT_SUBSCRIBE_MEMBER(m_EEntityDeleted, &RespawnSystem::OnEntityDeleted);
EVENT_SUBSCRIBE_MEMBER(m_EPause, &RespawnSystem::OnPause);
EVENT_SUBSCRIBE_MEMBER(m_EResume, &RespawnSystem::OnResume);
}
void RespawnSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cRespawn, double dt)
{
if (m_Paused) {
return;
}
if (!entity.HasComponent("Spawner")) {
return;
}
EntityWrapper& lastRespawnedEntity = m_LastRespawnedEntity[entity];
if (!lastRespawnedEntity.Valid()) {
double& _respawnCountdown = cRespawn["_RespawnCountdown"];
_respawnCountdown -= dt;
if (_respawnCountdown <= 0) {
lastRespawnedEntity = SpawnerSystem::Spawn(entity, entity);
_respawnCountdown = cRespawn["Delay"];
}
}
}
bool RespawnSystem::OnEntityDeleted(const Events::EntityDeleted& e)
{
m_LastRespawnedEntity.erase(e.DeletedEntity);
return true;
}
bool RespawnSystem::OnPause(const Events::Pause& e)
{
if (e.World == m_World) {
m_Paused = true;
}
return true;
}
bool RespawnSystem::OnResume(const Events::Resume& e)
{
if (e.World == m_World) {
m_Paused = false;
}
return true;
}
+1 -1
View File
@@ -223,7 +223,7 @@ void World::deleteEntityRecursive(EntityID entity, bool cascaded /*= false*/)
if (m_EventBroker != nullptr) {
Events::EntityDeleted e;
e.DeletedEntity = EntityWrapper(this, entity);
e.DeletedEntity = entity;
e.Cascaded = cascaded;
m_EventBroker->Publish(e);
}
+1 -1
View File
@@ -494,7 +494,7 @@ bool Server::OnEntityDeleted(const Events::EntityDeleted & e)
{
if (!e.Cascaded) {
Packet packet = Packet(MessageType::EntityDeleted);
packet.WritePrimitive<EntityID>(e.DeletedEntity.ID);
packet.WritePrimitive<EntityID>(e.DeletedEntity);
reliableBroadcast(packet);
}
return false;
+1 -1
View File
@@ -283,7 +283,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
bool AnimationSystem::OnEntityDeleted(Events::EntityDeleted& e)
{
EntityWrapper entity = e.DeletedEntity;
EntityWrapper entity = EntityWrapper(m_World, e.DeletedEntity);
if (entity.HasComponent("Model")) {
Model* model;
+1 -3
View File
@@ -7,7 +7,7 @@
#include "Systems/RaptorCopterSystem.h"
#include "Systems/HealthSystem.h"
#include "Systems/PlayerMovementSystem.h"
#include "Core/SpawnerSystem.h"
#include "Systems/SpawnerSystem.h"
#include "Systems/PlayerSpawnSystem.h"
#include "Systems/PlayerDeathSystem.h"
#include "Systems/FloatingEffectSystem.h"
@@ -40,7 +40,6 @@
#include "Game/Systems/MainMenuSystem.h"
#include "Game/Systems/ServerListSystem.h"
#include "Game/Systems/StartSystem.h"
#include "Core/RespawnSystem.h"
#include "Rendering/TextureSprite.h"
@@ -136,7 +135,6 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<RespawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<AssaultWeaponBehaviour>(updateOrderLevel, m_Renderer, m_OctreeCollision);
m_SystemPipeline->AddSystem<DefenderWeaponBehaviour>(updateOrderLevel, m_Renderer, m_OctreeCollision);
+1 -1
View File
@@ -67,7 +67,7 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player)
bool PlayerDeathSystem::OnEntityDeleted(Events::EntityDeleted& e)
{
// We only care about when the local players death effect is removed.
if (m_LocalPlayerDeathEffect != e.DeletedEntity) {
if (m_LocalPlayerDeathEffect.ID != e.DeletedEntity) {
return false;
}
@@ -264,6 +264,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
size = glm::vec3(1.f, 1.f, 1.f);
} else {
size = glm::vec3(1.f, 1.6f, 1.f);
if (controller->CrouchingLastFrame() && isOnGround) {
// The collision should resolve this anyway, but
// this is more reliable, since the box gets larger.
((glm::vec3&)cTransform["Position"]).y += 0.3f;
}
}
}
@@ -1,4 +1,4 @@
#include "Core/SpawnerSystem.h"
#include "Systems/SpawnerSystem.h"
#include "Collision/Collision.h"
SpawnerSystem::SpawnerSystem(SystemParams params)