Compare commits

..

5 Commits

34 changed files with 336 additions and 255 deletions
+2 -2
View File
@@ -2,14 +2,14 @@
#define EEntityDeleted_h__
#include "Event.h"
#include "Entity.h"
#include "EntityWrapper.h"
namespace Events
{
struct EntityDeleted : Event
{
EntityID DeletedEntity;
EntityWrapper DeletedEntity;
// True if the entity deletion was triggered because the entity's parent was deleted before it
bool Cascaded;
};
+28
View File
@@ -0,0 +1,28 @@
#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
@@ -5,7 +5,7 @@
#include "Common.h"
#include "GLM.h"
#include "Core/System.h"
#include "Events/ESpawnerSpawn.h"
#include "Core/ESpawnerSpawn.h"
#include "Core/Transform.h"
#include "Core/EntityFile.h"
+1 -1
View File
@@ -68,7 +68,7 @@ protected:
const std::string m_ComponentType;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& scoreScreen, double dt) = 0;
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cComponent, 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 "Game/Events/ESpawnerSpawn.h"
#include "../Core/ESpawnerSpawn.h"
class EditorGUI
{
@@ -27,8 +27,6 @@ struct ExplosionEffectJob : ModelJob
Velocity = (glm::vec2)explosionEffectComponent["Velocity"];
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
Reverse = (bool)explosionEffectComponent["Reverse"];
ColorDistanceScalar = (double)explosionEffectComponent["ColorDistanceScalar"];
};
glm::vec3 ExplosionOrigin;
@@ -40,14 +38,12 @@ struct ExplosionEffectJob : ModelJob
glm::vec4 EndColor;
bool Randomness = false;
double RandomnessScalar = 1.f;
float RandomnessScalar = 1.f;
glm::vec2 Velocity;
bool ColorByDistance = false;
//bool ReverseAnimation = false;
//bool Wireframe = false;
bool ExponentialAccelaration = false;
bool Reverse = false;
double ColorDistanceScalar = 1.f;
std::array<float, 50> RandomNumbers = {
0.3257552917701f,
+1 -2
View File
@@ -63,8 +63,7 @@ private:
GLuint m_DepthMap;
FrameBuffer m_DepthBuffer;
ShaderProgram* m_ShadowProgram;
ShaderProgram* m_ShadowProgramSkinned;
ShaderProgram* m_ShadowProgram;
std::array<glm::mat4, MAX_SPLITS> m_LightProjection;
std::array<glm::mat4, MAX_SPLITS> m_LightView;
@@ -3,7 +3,6 @@
#include "Common.h"
#include "Core/System.h"
#include "Engine/GLM.h"
class ExplosionEffectSystem : public PureSystem
{
+1 -1
View File
@@ -5,7 +5,7 @@
#include "Rendering/IRenderer.h"
#include "Core/ResourceManager.h"
#include "Core/Event.h"
#include "Systems/SpawnerSystem.h"
#include "Core/SpawnerSystem.h"
#include "GUI/EButtonClicked.h"
+2 -2
View File
@@ -1,7 +1,7 @@
#include "Core/System.h"
#include "Input/EInputCommand.h"
#include "Systems/SpawnerSystem.h"
#include "Events/ESpawnerSpawn.h"
#include "Core/SpawnerSystem.h"
#include "Core/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 "Systems/SpawnerSystem.h"
#include "Core/SpawnerSystem.h"
#include "Core/EventBroker.h"
#include "Network/ESearchForServers.h"
@@ -6,7 +6,7 @@
#include "Core/Octree.h"
#include "Collision/EntityAABB.h"
#include "Input/EInputCommand.h"
#include "Systems/SpawnerSystem.h"
#include "Core/SpawnerSystem.h"
#include "Rendering/ESetCamera.h"
#include "Core/ConfigFile.h"
#include "Rendering/EAutoAnimationBlend.h"
+1
View File
@@ -68,4 +68,5 @@
<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>
@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd">
<ExplosionOrigin X="0" Y="0" Z="0"/>
<TimeSinceDeath>0.0</TimeSinceDeath>
<ExplosionDuration>2.0</ExplosionDuration>
<TimeSinceDeath>0</TimeSinceDeath>
<ExplosionDuration>2</ExplosionDuration>
<Speed>1</Speed>
<Delay>0</Delay>
<!--<Gravity>1</Gravity>-->
<!--<GravityForce>1</GravityForce>-->
<!--<ObjectRadius>2</ObjectRadius>-->
<EndColor R="0" G="0" B="0" A="0"/>
<Randomness>false</Randomness>
<RandomnessScalar>1.0</RandomnessScalar>
<Randomness>0</Randomness>
<RandomnessScalar>1</RandomnessScalar>
<Velocity X="2" Y="2"/>
<ColorByDistance>false</ColorByDistance>
<ColorByDistance>0</ColorByDistance>
<!--<ReverseAnimation>0</ReverseAnimation>-->
<!--<Wireframe>0</Wireframe>-->
<ExponentialAccelaration>false</ExponentialAccelaration>
<Pulsate>false</Pulsate>
<Reverse>false</Reverse>
<ColorDistanceScalar>1.0</ColorDistanceScalar>
<ExponentialAccelaration>0</ExponentialAccelaration>
</ExplosionEffect>
@@ -44,21 +44,15 @@
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
</xs:element>
<!--<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Implosions are cooler</xs:documentation></xs:annotation>
</xs:element>-->
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
</xs:element>-->
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Pulsate" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Pulsate the effect</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Reverse" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Reverse the effect</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ColorDistanceScalar" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Scale the distance of the color change</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
+5
View File
@@ -0,0 +1,5 @@
<?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
@@ -0,0 +1,17 @@
<?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>
+2 -8
View File
@@ -2,19 +2,13 @@
<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:RaptorCopter>
<Speed>8</Speed>
<Axis X="0" Y="0.100000001" Z="0"/>
</c:RaptorCopter>
<c:NetworkComponent/>
<c:Transform>
<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"/>
<Scale X="0.25" Y="0.25" Z="0.25"/>
</c:Transform>
<c:Trigger/>
</Components>
@@ -0,0 +1,58 @@
<?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,6 +71,7 @@
<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>
+125 -97
View File
@@ -15,11 +15,6 @@ uniform float RandomnessScalar;
uniform vec2 Velocity;
uniform bool ColorByDistance;
uniform bool ExponentialAccelaration;
uniform bool Reverse;
uniform float ColorDistanceScalar;
//uniform bool Gravity;
//uniform bool Rotation;
//uniform bool MaxRadius;
in VertexData{
vec3 Position;
@@ -46,136 +41,169 @@ out VertexData{
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
float EqualTo(float x, float y) {
return 1.0 - abs(sign(x - y));
}
float NotEqualTo(float x, float y) {
return abs(sign(x - y));
}
float GreaterThan(float x, float y) {
return max(sign(x - y), 0.0);
}
float LessThan(float x, float y) {
return max(sign(y - x), 0.0);
}
float GreaterEqualTo(float x, float y) {
return 1.0 - LessThan(x, y);
}
float LessEqualTo(float x, float y) {
return 1.0 - GreaterThan(x, y);
}
// returns a "random" number based on input parameter
float GetRandomNumber(int polygon_index)
{
return RandomNumbers[int(mod(polygon_index, 50))];
int randomIndex = int(mod(polygon_index, 50));
return RandomNumbers[randomIndex];
}
vec3 CalcCenterOfTriangle(vec3 vertex0, vec3 vertex1, vec3 vertex2)
float randomNumber = 0.0;
float randomDistance = 0.0;
void main()
{
// calculate middle of vectors
vec3 dir1 = normalize(vertex1 - vertex0);
vec3 dir2 = normalize(vertex2 - vertex0);
vec3 v1 = Input[1].Position - Input[0].Position;
vec3 v2 = Input[2].Position - Input[0].Position;
vec3 v3 = Input[2].Position - (v1 / 2);
vec3 v4 = Input[1].Position - (v2 / 2);
vec3 vecA = vertex2 - vertex1; //o2 - o1
// calculate intersection
// normalize direction
vec3 dir1 = normalize(v1);
vec3 dir2 = normalize(v2);
vec3 vecA = Input[2].Position - Input[1].Position; //o2 - o1
vec3 vecB = cross(dir1, dir2);
mat3 matrisA = mat3(vecA, dir2, vecB);
float lengthA = length(vecB);
lengthA = lengthA * lengthA;
float s = determinant(matrisA) / lengthA;
// center position of triangle
return vertex1 + (s * dir1);
}
void PassThingsThrough(int index)
{
// pass through vertex data
Output.Normal = Input[index].Normal;
Output.Position = Input[index].Position;
Output.TextureCoordinate = Input[index].TextureCoordinate;
Output.Tangent = Input[index].Tangent;
Output.BiTangent = Input[index].BiTangent;
Output.ExplosionColor = EndColor;
}
void main()
{
vec3 centerOfTriangle = CalcCenterOfTriangle(Input[0].Position, Input[1].Position, Input[2].Position);
vec3 centerOfTriangle = Input[1].Position + (s * dir1);
// center position of triangle to origin vector
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
// distance between origin and the center of the current triangle
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
// time percentage until end of explosion (0.0-1.0)
float timePercetage = TimeSinceDeath / ExplosionDuration;
// get a random number if randomness is enabled, otherwise the random distance will be zero and won't affect the other algorithms
float randomDistance = float(Randomness) * GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
// get a random number if randomness is enabled, otherwise the random number will be zero and won't affect the other algorithms
if (Randomness == true)
{
randomDistance = GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
}
vec2 randomVelocity = Velocity * (randomDistance + 1.0);
// accelaration to use on current frame. is a interpolation between start and end value
float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage);
// if the accelaration should be exponential
currentVelocity = currentVelocity * max(currentVelocity * float(ExponentialAccelaration), 1.0);
if (ExponentialAccelaration == true)
{
currentVelocity = pow(currentVelocity, 2) / 2.0;
}
// the distance the blast has moved since the beginning, i.e. its radius
float blastWave = TimeSinceDeath * currentVelocity;
// distance between origin and the center of the current triangle
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
// the distance from origin to the triangle center with eventual randomness added
float origin2TriangleCenterDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * blastWave) - (normalizedOrigin2TriangleCenterVector * origin2TriangleCenterDistanceWithRandomness);
float fullDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
// if the triangle is inside the blast's radius...
float isInsideBlastRadius = LessEqualTo(origin2TriangleCenterDistanceWithRandomness, blastWave);
// vector from the triangle center to the explosion's shockwave
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * (TimeSinceDeath * currentVelocity)) - (normalizedOrigin2TriangleCenterVector * fullDistanceWithRandomness);
// calculate the max distance (s) the triangle will move
float accelaration = (randomVelocity.y - randomVelocity.x) / ExplosionDuration;
float maxDistance = (randomVelocity.x * ExplosionDuration) + (0.5 * accelaration * ExplosionDuration * ExplosionDuration);
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
// if the triangle is inside the blast radius...
if (fullDistanceWithRandomness <= (TimeSinceDeath * currentVelocity))
{
Output.ExplosionPercentageElapsed = (length(triangleCenter2ExplosionRadius) / maxDistance) * isInsideBlastRadius * ColorDistanceScalar;
float maxRadius = max(TimeSinceDeath * currentVelocity, (ExplosionDuration * currentVelocity));
float a = (randomVelocity.y - randomVelocity.x) / ExplosionDuration;
//float t = sqrt((2 * origin2TriangleCenterDistance) / a);
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
// calculate the max distance (s) the triangle will move
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
float te = (length(triangleCenter2ExplosionRadius) / s);
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = te;
}
else
{
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = timePercetage;
}
// for every vertex on the triangle...
for (int i = 0; i < gl_in.length(); i++)
{
// move the triangle to the blast radius
vec3 ExplodedPosition = Input[i].Position + triangleCenter2ExplosionRadius;
// pass through vertex data
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
Output.Tangent = Input[i].Tangent;
Output.BiTangent = Input[i].BiTangent;
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
// convert to model space for the gravity to always be in -y
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
// if there is gravity, apply it
//if (Gravity == true)
//{
// // ---DO THIS----> //ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - TimeSinceHit;
//
// ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - pow(TimeSinceDeath, 2);
//}
// convert to screen space
gl_Position = P*V * ExplodedPositionInModelSpace;
EmitVertex();
}
}
else
{
Output.ExplosionPercentageElapsed = timePercetage;
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = 0.0;
}
else
{
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = timePercetage;
}
// for every vertex on the triangle...
for(int i = 0; i < gl_in.length(); i++)
{
// pass through vertex data
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
Output.Tangent = Input[i].Tangent;
Output.BiTangent = Input[i].BiTangent;
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
// no change in position, pass through vertex
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
}
vec3 ExplodedPosition;
for (int i = 0; i < gl_in.length(); i++)
{
// move the triangle to the blast radius
ExplodedPosition = Input[i].Position + (triangleCenter2ExplosionRadius * isInsideBlastRadius);
// pass through vertex data
PassThingsThrough(i);
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
// convert to window space
gl_Position = P * V * M * vec4(ExplodedPosition, 1.0);
EmitVertex();
}
}
//EndPrimitive();
}
-29
View File
@@ -1,29 +0,0 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 Bones[100];
layout (location = 0) in vec3 Position;
layout (location = 4) in vec2 TextureCoords;
layout(location = 5) in vec4 BoneIndices;
layout(location = 6) in vec4 BoneWeights;
out VertexData{
vec2 TextureCoordinate;
}Output;
void main()
{
mat4 boneTransform = mat4(1);
if(BoneWeights[0] > 0.0f){
boneTransform = BoneWeights[0] * Bones[int(BoneIndices[0])]
+ BoneWeights[1] * Bones[int(BoneIndices[1])]
+ BoneWeights[2] * Bones[int(BoneIndices[2])]
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
}
gl_Position = P * V * M * boneTransform * vec4(Position, 1.0);
Output.TextureCoordinate = TextureCoords;
}
+54
View File
@@ -0,0 +1,54 @@
#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,4 +1,4 @@
#include "Systems/SpawnerSystem.h"
#include "Core/SpawnerSystem.h"
#include "Collision/Collision.h"
SpawnerSystem::SpawnerSystem(SystemParams params)
+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 = entity;
e.DeletedEntity = EntityWrapper(this, 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);
packet.WritePrimitive<EntityID>(e.DeletedEntity.ID);
reliableBroadcast(packet);
}
return false;
+4 -4
View File
@@ -127,12 +127,12 @@ void AnimationSystem::UpdateAnimations(double dt)
void AnimationSystem::UpdateWeights(double dt)
{
for (auto it = m_AutoBlendQueues.begin(); it != m_AutoBlendQueues.end(); ) {
/* LOG_INFO("%s", it->first.Name().c_str());
it->second.PrintQueue();*/
LOG_INFO("%s", it->first.Name().c_str());
it->second.PrintQueue();
if(it->second.HasActiveBlendJob()) {
AutoBlendQueue::AutoBlendJob& blendJob = it->second.GetActiveBlendJob();
//LOG_INFO("%s", blendJob.RootNode.Name().c_str());
LOG_INFO("%s", blendJob.RootNode.Name().c_str());
std::shared_ptr<BlendTree> blendTree = it->second.GetBlendTree();
if (blendTree != nullptr) {
if (blendJob.Duration != 0.0) {
@@ -283,7 +283,7 @@ bool AnimationSystem::OnAutoAnimationBlend(Events::AutoAnimationBlend& e)
bool AnimationSystem::OnEntityDeleted(Events::EntityDeleted& e)
{
EntityWrapper entity = EntityWrapper(m_World, e.DeletedEntity);
EntityWrapper entity = e.DeletedEntity;
if (entity.HasComponent("Model")) {
Model* model;
+1 -10
View File
@@ -1319,12 +1319,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
GLERROR("Bind 6 uniform");
if (job->Reverse == false) {
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
}
else {
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), (job->ExplosionDuration - job->TimeSinceDeath));
}
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
GLERROR("Bind 7 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
GLERROR("Bind 8 uniform");
@@ -1342,10 +1337,6 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
GLERROR("Bind 14 uniform");
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
GLERROR("Bind 15 uniform");
glUniform1i(glGetUniformLocation(shaderHandle, "Reverse"), job->Reverse);
GLERROR("Bind 15-2 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "ColorDistanceScalar"), job->ColorDistanceScalar);
GLERROR("Bind 15-3 uniform");
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
GLERROR("Bind 16 uniform");
+1 -1
View File
@@ -219,7 +219,7 @@ void PickingPass::Draw(RenderScene& scene)
m_PickingSkinnedProgram->Bind();
lastShader = m_PickingSkinnedProgram->GetHandle();
}
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
std::vector<glm::mat4> frameBones;
+3 -55
View File
@@ -156,12 +156,7 @@ void ShadowPass::InitializeShaderPrograms()
m_ShadowProgram->BindFragDataLocation(0, "ShadowMap");
m_ShadowProgram->Link();
m_ShadowProgramSkinned = ResourceManager::Load<ShaderProgram>("#ShadowProgramSkinned");
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShadowSkinned.vert.glsl")));
m_ShadowProgramSkinned->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Shadow.frag.glsl")));
m_ShadowProgramSkinned->Compile();
m_ShadowProgramSkinned->BindFragDataLocation(0, "ShadowMap");
m_ShadowProgramSkinned->Link();
}
void ShadowPass::ClearBuffer()
@@ -217,7 +212,8 @@ void ShadowPass::Draw(RenderScene & scene)
ShadowPassState* state = new ShadowPassState(m_DepthBuffer.GetHandle());
m_ShadowProgram->Bind();
GLuint shaderHandle = m_ShadowProgram->GetHandle();
glViewport(0, 0, m_ResolutionSizeWidth, m_ResolutionSizeHeight);
for (int i = 0; i < m_CurrentNrOfSplits; i++) {
@@ -225,11 +221,7 @@ void ShadowPass::Draw(RenderScene & scene)
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_DepthMap, 0, i);
GLuint shaderHandle;
for (auto &job : scene.Jobs.DirectionalLight) {
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
if (directionalLightJob) {
@@ -240,19 +232,9 @@ void ShadowPass::Draw(RenderScene & scene)
//RadiusToLightspace(m_shadowFrusta[i]);
m_LightProjection[i] = glm::ortho(m_shadowFrusta[i].LRBT[LEFT], m_shadowFrusta[i].LRBT[RIGHT], m_shadowFrusta[i].LRBT[BOTTOM], m_shadowFrusta[i].LRBT[TOP], m_NearFarPlane[NEAR], m_NearFarPlane[FAR]);
m_ShadowProgram->Bind();
shaderHandle = m_ShadowProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
m_ShadowProgramSkinned->Bind();
shaderHandle = m_ShadowProgramSkinned->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_LightProjection[i]));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_LightView[i]));
GLERROR("ShadowLight ERROR");
for (auto &objectJob : scene.Jobs.OpaqueObjects) {
@@ -263,23 +245,6 @@ void ShadowPass::Draw(RenderScene & scene)
continue;
}
if(modelJob->Model->IsSkinned()) {
m_ShadowProgramSkinned->Bind();
shaderHandle = m_ShadowProgramSkinned->GetHandle();
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else {
m_ShadowProgram->Bind();
shaderHandle = m_ShadowProgram->GetHandle();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), 1.f);
@@ -300,23 +265,6 @@ void ShadowPass::Draw(RenderScene & scene)
continue;
}
if (modelJob->Model->IsSkinned()) {
m_ShadowProgramSkinned->Bind();
shaderHandle = m_ShadowProgramSkinned->GetHandle();
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
frameBones = modelJob->BlendTree->GetFinalPose();
} else {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else {
m_ShadowProgram->Bind();
shaderHandle = m_ShadowProgram->GetHandle();
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniform1f(glGetUniformLocation(shaderHandle, "Alpha"), modelJob->Color.a);
+3 -1
View File
@@ -7,7 +7,7 @@
#include "Systems/RaptorCopterSystem.h"
#include "Systems/HealthSystem.h"
#include "Systems/PlayerMovementSystem.h"
#include "Systems/SpawnerSystem.h"
#include "Core/SpawnerSystem.h"
#include "Systems/PlayerSpawnSystem.h"
#include "Systems/PlayerDeathSystem.h"
#include "Systems/FloatingEffectSystem.h"
@@ -40,6 +40,7 @@
#include "Game/Systems/MainMenuSystem.h"
#include "Game/Systems/ServerListSystem.h"
#include "Game/Systems/StartSystem.h"
#include "Core/RespawnSystem.h"
#include "Rendering/TextureSprite.h"
@@ -135,6 +136,7 @@ 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);
+7 -10
View File
@@ -7,15 +7,12 @@ void ExplosionEffectSystem::UpdateComponent(EntityWrapper& entity, ComponentWrap
delay = std::max(0.0, delay - dt);
}
if (delay <= 0) {
double& timeSinceDeath = component["TimeSinceDeath"];
timeSinceDeath += (double)component["Speed"] * dt;
if (timeSinceDeath < 0) {
timeSinceDeath = 0.0;
}
else if (timeSinceDeath >(double)component["ExplosionDuration"]) {
timeSinceDeath = (double)component["ExplosionDuration"];
}
}
if (delay <= 0) {
double& timeSinceDeath = component["TimeSinceDeath"];
timeSinceDeath += (double)component["Speed"] * dt;
if (timeSinceDeath < 0 || timeSinceDeath > (double)component["ExplosionDuration"]) {
timeSinceDeath = 0.0;
}
}
}
+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.ID != e.DeletedEntity) {
if (m_LocalPlayerDeathEffect != e.DeletedEntity) {
return false;
}