Fade in/out should now work with models and sprites
This commit is contained in:
@@ -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& cFade, double dt) = 0;
|
||||
};
|
||||
|
||||
class ImpureSystem : public virtual System
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
#ifndef FadeOutSystem_h__
|
||||
#define FadeOutSystem_h__
|
||||
#ifndef FadeSystem_h__
|
||||
#define FadeSystem_h__
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "GLM.h"
|
||||
|
||||
class FadeOutSystem : public PureSystem
|
||||
class FadeSystem : public PureSystem
|
||||
{
|
||||
public:
|
||||
FadeOutSystem(SystemParams params)
|
||||
FadeSystem(SystemParams params)
|
||||
: System(params)
|
||||
, PureSystem("FadeOut")
|
||||
, PureSystem("Fade")
|
||||
{
|
||||
|
||||
}
|
||||
@@ -69,5 +69,5 @@
|
||||
<xs:include schemaLocation="Components/ServerIdentity.xsd"/>
|
||||
<xs:include schemaLocation="Components/ServerList.xsd"/>
|
||||
<xs:include schemaLocation="Components/EndScreen.xsd"/>
|
||||
<xs:include schemaLocation="Components/FadeOut.xsd"/>
|
||||
<xs:include schemaLocation="Components/Fade.xsd"/>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Fade xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Fade.xsd">
|
||||
<FadeTime>1</FadeTime>
|
||||
<Time>0</Time>
|
||||
<Out>true</Out>
|
||||
</Fade>
|
||||
@@ -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="Fade">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="FadeTime" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="Time" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="Out" type="t:bool" minOccurs="0">
|
||||
<xs:annotation><xs:documentation>If the entity should fade out or in.</xs:documentation></xs:annotation>
|
||||
</xs:element>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<FadeOut xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FadeOut.xsd">
|
||||
<FadeOut>0</FadeOut>
|
||||
</FadeOut>
|
||||
@@ -1,13 +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="FadeOut">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="FadeOut" type="t:double" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -72,7 +72,7 @@
|
||||
<xs:element ref="c:ServerIdentity" minOccurs="0"/>
|
||||
<xs:element ref="c:ServerList" minOccurs="0"/>
|
||||
<xs:element ref="c:EndScreen" minOccurs="0"/>
|
||||
<xs:element ref="c:FadeOut" minOccurs="0"/>
|
||||
<xs:element ref="c:Fade" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
+2
-1
@@ -41,7 +41,7 @@
|
||||
#include "Game/Systems/ServerListSystem.h"
|
||||
#include "Game/Systems/StartSystem.h"
|
||||
#include "Game/Systems/EndScreenSystem.h"
|
||||
#include "Game/Systems/FadeOutSystem.h"
|
||||
#include "Game/Systems/FadeSystem.h"
|
||||
#include "Rendering/TextureSprite.h"
|
||||
|
||||
|
||||
@@ -160,6 +160,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<ServerListSystem>(updateOrderLevel, m_Renderer);
|
||||
m_SystemPipeline->AddSystem<StartSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<EndScreenSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<FadeSystem>(updateOrderLevel);
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#include "Systems/FadeOutSystem.h"
|
||||
|
||||
void FadeOutSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cFadeOut, double dt)
|
||||
{
|
||||
//if (dt == 0.0) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
//if (!entity.Valid()) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
//double& lifetime = cLifetime["Lifetime"];
|
||||
//lifetime -= dt;
|
||||
|
||||
//if (lifetime <= 0.0) {
|
||||
// m_Deletions.push_back(entity);
|
||||
//}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
#include "Systems/FadeSystem.h"
|
||||
|
||||
void FadeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& cFade, double dt)
|
||||
{
|
||||
double dTime = dt;
|
||||
if (dTime == 0.0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entity.Valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(bool)cFade["Out"]) {
|
||||
dTime *= -1;
|
||||
}
|
||||
|
||||
double fadeTime = cFade["FadeTime"];
|
||||
double& currentTime = cFade["Time"];
|
||||
currentTime += dTime;
|
||||
|
||||
if(currentTime > fadeTime) {
|
||||
currentTime = 0.0;
|
||||
}
|
||||
if(currentTime < 0.0) {
|
||||
currentTime = fadeTime;
|
||||
}
|
||||
double ratio = currentTime/fadeTime;
|
||||
|
||||
if(entity.HasComponent("Model")){
|
||||
((glm::vec4&)entity["Model"]["Color"]).a = ratio;
|
||||
}
|
||||
if (entity.HasComponent("Sprite")) {
|
||||
((glm::vec4&)entity["Sprite"]["Color"]).a = ratio;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user