Compare commits
225 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6465fe6ed6 | |||
| 2c18068059 | |||
| 09aec08d0e | |||
| 4cf8c3d8d7 | |||
| 37414ce124 | |||
| adceccf402 | |||
| 201480b17f | |||
| bac23f6e8c | |||
| 68f2d5327d | |||
| 2263fd2ad6 | |||
| 8cc928b5f4 | |||
| 881ce7b02f | |||
| c130fdda5e | |||
| 4c87ca10b9 | |||
| 22664848dc | |||
| d135ea2da6 | |||
| 844825813b | |||
| 722b795d37 | |||
| cf2bf4e14d | |||
| 2ac584bafb | |||
| 6e5335a266 | |||
| fc5d054cb2 | |||
| 8c9f4bb84b | |||
| e15a7b9485 | |||
| a141da3d8c | |||
| ca907b912e | |||
| 97499f1c28 | |||
| 64610e3c03 | |||
| 5dd85d2748 | |||
| 261c2e021e | |||
| 581a7b470c | |||
| 3e7936ef00 | |||
| 8845054965 | |||
| 7dfd68467e | |||
| 52355a63e2 | |||
| 72db672dbf | |||
| 0d665c10fe | |||
| 23bb1a6405 | |||
| b8222c7b2e | |||
| 43bbc063cf | |||
| 3e4b87da7c | |||
| ac9ce8ea83 | |||
| 99643fd748 | |||
| a6c30100af | |||
| 833015f45e | |||
| 657125b469 | |||
| 8f28c760dd | |||
| b13362360a | |||
| 0af9edc6e5 | |||
| ec10ef3ffc | |||
| b2a437731e | |||
| 42b49f9dba | |||
| 4b8f1d95a3 | |||
| 8f84a5ddd6 | |||
| 6bc7131290 | |||
| 4214bf10a1 | |||
| 969e7cb0d5 | |||
| 47a365a8fc | |||
| 71c03326aa | |||
| ba69c79821 | |||
| 0a31fa3dfd | |||
| ca457d9c00 | |||
| a08e54a147 | |||
| 2c3122bbdb | |||
| 10846be820 | |||
| 9df7b32ca1 | |||
| 3d4a7de59d | |||
| 1cdcbf9b32 | |||
| 9e8d2b99df | |||
| ba4877c3f7 | |||
| af39b892cd | |||
| 1ed5107d9b | |||
| 2ce7179d19 | |||
| eb7b22c757 | |||
| b48d491ad7 | |||
| 7d732c75ca | |||
| 47f4711b85 | |||
| 78e318c032 | |||
| bb66f95d43 | |||
| cc422cf73a | |||
| 2e5ee633ce | |||
| 1e04244590 | |||
| f146971db0 | |||
| 60b2c9bc9b | |||
| d357e365cb | |||
| a8a3366e8a | |||
| 7de76376cf | |||
| 422bedb844 | |||
| 1da432ba23 | |||
| 787eecce26 | |||
| 215b1b1aa4 | |||
| f49cacf167 | |||
| a15e01596a | |||
| a5168bd1c2 | |||
| 784e1eb69b | |||
| b5e372896f | |||
| a54156fab3 | |||
| a20707739e | |||
| 4f7a17ff62 | |||
| 987dafb44a | |||
| 47053285c8 | |||
| bee0630a26 | |||
| 1dc3756533 | |||
| 196469299f | |||
| e1196204eb | |||
| b9ea314232 | |||
| 71533b52ae | |||
| 6442254575 | |||
| 9f8b0f7aa9 | |||
| 021c4e36d7 | |||
| 02253ea6e1 | |||
| 2417175914 | |||
| fb5164221f | |||
| 88c7c57671 | |||
| 5295133311 | |||
| baff8301b3 | |||
| 3e42c067ab | |||
| 3b42f5dbf4 | |||
| 40ae2b8cbb | |||
| f1c2413cf9 | |||
| 11af6a3078 | |||
| 0370775820 | |||
| a36ed76a4e | |||
| af30e51564 | |||
| e24a84c52d | |||
| 04f77da6f1 | |||
| 30f454e6a4 | |||
| 648d864d6e | |||
| e473194671 | |||
| b761439c84 | |||
| 44a73ef883 | |||
| c1860ae383 | |||
| c4c53944d9 | |||
| bdec4f9d16 | |||
| 7cae84d4ee | |||
| 4964e732ca | |||
| 1bb1a1445e | |||
| d1213f9f59 | |||
| dd131e7652 | |||
| 70f4002d70 | |||
| b66e3d3630 | |||
| 06f614b3bb | |||
| 4a17e3c8f3 | |||
| 22e35489d7 | |||
| 055f6517a1 | |||
| afd9e24df6 | |||
| 851418b1de | |||
| fee50ba3b6 | |||
| 5bcadd5b1a | |||
| 42d810b198 | |||
| 3a15550b57 | |||
| 8f500965d4 | |||
| bd385a0d59 | |||
| 5e05e51309 | |||
| fee1ed6d6d | |||
| f79649cf9a | |||
| 2096779eb6 | |||
| 99747c518e | |||
| f088aa1d85 | |||
| 0af337bf39 | |||
| 6caa7e94a4 | |||
| e2a8605101 | |||
| c8c4879554 | |||
| 14054ad898 | |||
| e47201ff61 | |||
| 1d14094e90 | |||
| 3301f66ad1 | |||
| 49d4a45ef8 | |||
| e0c3a32e66 | |||
| 97b915f130 | |||
| c9f815fd42 | |||
| 8eea0c8395 | |||
| 38a3e88999 | |||
| 89cbc70177 | |||
| 51e0b852d2 | |||
| 7ccaf5b040 | |||
| 66e20c3fd9 | |||
| 6ba1e95da7 | |||
| bef50ef96a | |||
| 9f657ada4e | |||
| f0ae365401 | |||
| 7d4a4ed7cf | |||
| fa2e556ab2 | |||
| 97de31be65 | |||
| 2f640d224c | |||
| f11bd24d53 | |||
| 350effd8eb | |||
| 607150189c | |||
| ecc473d520 | |||
| 35e4935497 | |||
| 73f59b89cc | |||
| 92e7d3ecf7 | |||
| 4b8f4981a3 | |||
| 447f41dbff | |||
| eb244f87c4 | |||
| 64a2354b24 | |||
| 675a80e905 | |||
| ec54b1298d | |||
| f5de267f25 | |||
| 95fa1f4bbd | |||
| 2cae4e3fb2 | |||
| 53265bbc90 | |||
| 7cbdc33f84 | |||
| 9645169797 | |||
| 02cd822cf1 | |||
| f7756ff60f | |||
| 2d5f71e442 | |||
| 4f2ad3ad00 | |||
| 04c23be136 | |||
| 2ec30fd2b2 | |||
| d2ed293183 | |||
| e9f5a3d263 | |||
| 8bdf87da12 | |||
| 971fee4a0c | |||
| fccd8c64e7 | |||
| 0e9fb16399 | |||
| db5301ff2c | |||
| ba9419b342 | |||
| 503613907e | |||
| 88d7b79cd3 | |||
| 8034b42c87 | |||
| 9232b24a7b | |||
| 774e17ffc9 | |||
| 7bf4f5c30e | |||
| e133791369 |
+1
-1
Submodule assets updated: c56f6380ab...1e7adc749e
@@ -20,6 +20,9 @@
|
|||||||
class World;
|
class World;
|
||||||
struct ComponentWrapper;
|
struct ComponentWrapper;
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
class Octree;
|
||||||
|
|
||||||
namespace Collision
|
namespace Collision
|
||||||
{
|
{
|
||||||
//Return true if the ray hits the box.
|
//Return true if the ray hits the box.
|
||||||
@@ -44,21 +47,24 @@ bool RayVsTriangle(const Ray& ray,
|
|||||||
float& outVCoord,
|
float& outVCoord,
|
||||||
bool trueOnNegativeDistance = false);
|
bool trueOnNegativeDistance = false);
|
||||||
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
|
//Return true if the ray hits any of the triangles in the model. Stops checking when a hit is detected.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices);
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix);
|
||||||
//Return true if the ray hits any of the triangles in the model.
|
//Return true if the ray hits any of the triangles in the model.
|
||||||
//Also returns the position of the intersection point. Will loop through all the whole model indices.
|
//Also returns the position of the intersection point. Will loop through all the whole model indices.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix,
|
||||||
glm::vec3& outHitPosition);
|
glm::vec3& outHitPosition);
|
||||||
//Return true if the ray hits any of the triangles in the model.
|
//Return true if the ray hits any of the triangles in the model.
|
||||||
//Also returns the distance from the ray origin to the closest
|
//Also returns the distance from the ray origin to the closest
|
||||||
//intersection point, and the barycentric u,v-coordinates. Will loop through all the whole model indices.
|
//intersection point, and the barycentric u,v-coordinates. Will loop through all the whole model indices.
|
||||||
bool RayVsModel(const Ray& ray,
|
bool RayVsModel(const Ray& ray,
|
||||||
const std::vector<RawModel::Vertex>& modelVertices,
|
const RawModel::Vertex* modelVertices,
|
||||||
const std::vector<unsigned int>& modelIndices,
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix,
|
||||||
float& outDistance,
|
float& outDistance,
|
||||||
float& outUCoord,
|
float& outUCoord,
|
||||||
float& outVCoord);
|
float& outVCoord);
|
||||||
@@ -72,15 +78,30 @@ bool AABBvsTriangles(const AABB& box,
|
|||||||
bool& isOnGround,
|
bool& isOnGround,
|
||||||
glm::vec3& outResolutionVector);
|
glm::vec3& outResolutionVector);
|
||||||
|
|
||||||
|
//Detects collision, but does not resolve.
|
||||||
|
bool AABBvsTriangles(const AABB& box,
|
||||||
|
const RawModel::Vertex* modelVertices,
|
||||||
|
const std::vector<unsigned int>& modelIndices,
|
||||||
|
const glm::mat4& modelMatrix);
|
||||||
|
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
bool AABBVsAABB(const AABB& a, const AABB& b);
|
bool AABBVsAABB(const AABB& a, const AABB& b);
|
||||||
//Return true if the boxes are intersecting.
|
//Return true if the boxes are intersecting.
|
||||||
//Also outputs the minimum translation that box [a] would need in order to resolve collision.
|
//Also outputs the minimum translation that box [a] would need in order to resolve collision.
|
||||||
bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation);
|
bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation);
|
||||||
|
|
||||||
// Calculates an absolute AABB from an entity AABB component
|
// Calculates an absolute AABB from an entity AABB component or Model component.
|
||||||
|
// if takeModelBox is true, the AABB component will be ignored and box is calculated from Model.
|
||||||
|
// if takeModelBox is false, the AABB component will be prefered, if it exists.
|
||||||
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeModelBox = false);
|
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity, bool takeModelBox = false);
|
||||||
boost::optional<EntityAABB> AbsoluteAABBExplosionEffect(EntityWrapper& entity);
|
boost::optional<EntityAABB> AbsoluteAABBExplosionEffect(EntityWrapper& entity);
|
||||||
|
//Returns the first entity hit by the input ray. entitiesPotentiallyHitSorted needs to be sorted
|
||||||
|
//by their distance to the ray, e.g. result from Octree<EntityAABB>::ObjectsPossiblyHitByRay.
|
||||||
|
//Returns boost::none if none was hit. outDistance will be the distance to the intersection point if the ray intersects.
|
||||||
|
boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, std::vector<EntityAABB> entitiesPotentiallyHitSorted, float& outDistance, glm::vec3& outIntersectPos);
|
||||||
|
//Returns the first entity hit by the input ray that exists in the octree.
|
||||||
|
//outDistance will be the distance to the intersection point if the ray intersects.
|
||||||
|
boost::optional<EntityAABB> EntityFirstHitByRay(const Ray& ray, Octree<EntityAABB>* octree, float& outDistance, glm::vec3& outIntersectPos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,11 @@ class CollisionSystem : public PureSystem
|
|||||||
public:
|
public:
|
||||||
CollisionSystem(SystemParams params, Octree<EntityAABB>* octree)
|
CollisionSystem(SystemParams params, Octree<EntityAABB>* octree)
|
||||||
: System(params)
|
: System(params)
|
||||||
, PureSystem("Collidable")
|
, PureSystem("Physics")
|
||||||
, m_Octree(octree)
|
, m_Octree(octree)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPhysics, double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Octree<EntityAABB>* m_Octree;
|
Octree<EntityAABB>* m_Octree;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define ComponentInfo_h__
|
#define ComponentInfo_h__
|
||||||
|
|
||||||
#include "../Common.h"
|
#include "../Common.h"
|
||||||
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
struct ComponentInfo
|
struct ComponentInfo
|
||||||
{
|
{
|
||||||
@@ -27,8 +28,9 @@ struct ComponentInfo
|
|||||||
std::string Name;
|
std::string Name;
|
||||||
std::unordered_map<std::string, Field_t> Fields;
|
std::unordered_map<std::string, Field_t> Fields;
|
||||||
std::vector<std::string> FieldsInOrder;
|
std::vector<std::string> FieldsInOrder;
|
||||||
|
std::vector<std::string> StringFields;
|
||||||
unsigned int Stride = 0;
|
unsigned int Stride = 0;
|
||||||
std::shared_ptr<char> Defaults = nullptr;
|
boost::shared_array<char> Defaults = nullptr;
|
||||||
std::shared_ptr<Meta_t> Meta = nullptr;
|
std::shared_ptr<Meta_t> Meta = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef ComponentPool_h__
|
#ifndef ComponentPool_h__
|
||||||
#define ComponentPool_h__
|
#define ComponentPool_h__
|
||||||
|
|
||||||
|
#include <set>
|
||||||
#include "MemoryPool.h"
|
#include "MemoryPool.h"
|
||||||
#include "ComponentInfo.h"
|
#include "ComponentInfo.h"
|
||||||
#include "ComponentWrapper.h"
|
#include "ComponentWrapper.h"
|
||||||
@@ -45,7 +46,8 @@ public:
|
|||||||
: m_ComponentInfo(ci)
|
: m_ComponentInfo(ci)
|
||||||
, m_Pool(ci.Meta->Allocation, sizeof(EntityID) + ci.Stride)
|
, m_Pool(ci.Meta->Allocation, sizeof(EntityID) + ci.Stride)
|
||||||
{ }
|
{ }
|
||||||
ComponentPool(const ComponentPool& other) = delete;
|
~ComponentPool();
|
||||||
|
ComponentPool(const ComponentPool& other);
|
||||||
ComponentPool(const ComponentPool&& other) = delete;
|
ComponentPool(const ComponentPool&& other) = delete;
|
||||||
|
|
||||||
const ::ComponentInfo& ComponentInfo() const { return m_ComponentInfo; }
|
const ::ComponentInfo& ComponentInfo() const { return m_ComponentInfo; }
|
||||||
|
|||||||
@@ -2,11 +2,29 @@
|
|||||||
#define ComponentWrapper_h__
|
#define ComponentWrapper_h__
|
||||||
|
|
||||||
#include <boost/shared_array.hpp>
|
#include <boost/shared_array.hpp>
|
||||||
|
#include <boost/any.hpp>
|
||||||
#include "../Common.h"
|
#include "../Common.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "ComponentInfo.h"
|
#include "ComponentInfo.h"
|
||||||
#include "Util/Any.h"
|
#include "Util/Any.h"
|
||||||
|
|
||||||
|
template <typename T, typename Enable = void>
|
||||||
|
struct ComponentField { };
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct ComponentField<T, typename std::enable_if<std::is_trivially_copyable<T>::value>::type>
|
||||||
|
{
|
||||||
|
static T& Get(const ComponentInfo::Field_t& info, char* data) { return *reinterpret_cast<T*>(data); }
|
||||||
|
static void Set(const ComponentInfo::Field_t& info, char* data, const T& value) { Get(data) = value; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
struct ComponentField<std::string, void>
|
||||||
|
{
|
||||||
|
static std::string& Get(const ComponentInfo::Field_t& info, char* data) { return **reinterpret_cast<std::string**>(data); }
|
||||||
|
static void Set(const ComponentInfo::Field_t& info, char* data, const std::string& value) { Get(info, data) = value; }
|
||||||
|
};
|
||||||
|
|
||||||
struct ComponentWrapper
|
struct ComponentWrapper
|
||||||
{
|
{
|
||||||
ComponentWrapper(const ComponentInfo& componentInfo, char* data)
|
ComponentWrapper(const ComponentInfo& componentInfo, char* data)
|
||||||
@@ -47,7 +65,31 @@ struct ComponentWrapper
|
|||||||
|
|
||||||
void Copy(ComponentWrapper& destination)
|
void Copy(ComponentWrapper& destination)
|
||||||
{
|
{
|
||||||
memcpy(destination.Data, this->Data, Info.Stride);
|
// Copy trivial data
|
||||||
|
memcpy(destination.Data, Data, Info.Stride);
|
||||||
|
// Duplicate strings
|
||||||
|
SolidifyStrings(destination);
|
||||||
|
}
|
||||||
|
|
||||||
|
// When component data has been copied, strings need to be reconstructed or they'll refer to the same data!
|
||||||
|
static void SolidifyStrings(ComponentWrapper& component)
|
||||||
|
{
|
||||||
|
for (auto& name : component.Info.StringFields) {
|
||||||
|
std::size_t offset = component.Info.Fields.at(name).Offset;
|
||||||
|
std::string value = *reinterpret_cast<const std::string*>(component.Data + offset);
|
||||||
|
new (component.Data + offset) std::string(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This needs to be called to properly free component data, because strings.
|
||||||
|
static void Destroy(ComponentInfo info, char* data)
|
||||||
|
{
|
||||||
|
// Call std::string destructors
|
||||||
|
for (auto& name : info.StringFields) {
|
||||||
|
std::size_t offset = info.Fields.at(name).Offset;
|
||||||
|
auto field = reinterpret_cast<std::string*>(data + offset);
|
||||||
|
field->~basic_string();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct SubscriptProxy
|
struct SubscriptProxy
|
||||||
@@ -102,26 +144,38 @@ public:
|
|||||||
ComponentWrapperFactory(std::string componentTypeName, unsigned int allocation = 0)
|
ComponentWrapperFactory(std::string componentTypeName, unsigned int allocation = 0)
|
||||||
{
|
{
|
||||||
m_ComponentInfo.Name = componentTypeName;
|
m_ComponentInfo.Name = componentTypeName;
|
||||||
|
m_ComponentInfo.Meta = std::make_shared<ComponentInfo::Meta_t>();
|
||||||
m_ComponentInfo.Meta->Allocation = allocation;
|
m_ComponentInfo.Meta->Allocation = allocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void AddProperty(std::string fieldName, T defaultValue)
|
void AddProperty(std::string fieldName, T defaultValue)
|
||||||
{
|
{
|
||||||
m_DefaultValues.push_back(defaultValue);
|
auto& field = m_ComponentInfo.Fields[fieldName];
|
||||||
m_ComponentInfo.Fields[fieldName].Type = typeid(T).name();
|
field.Name = fieldName;
|
||||||
m_ComponentInfo.Fields[fieldName].Offset = m_ComponentInfo.Stride;
|
field.Type = typeid(T).name();
|
||||||
m_ComponentInfo.Fields[fieldName].Stride = sizeof(T);
|
field.Offset = m_ComponentInfo.Stride;
|
||||||
|
field.Stride = sizeof(T);
|
||||||
|
m_ComponentInfo.FieldsInOrder.push_back(field.Name);
|
||||||
|
if (field.Type == typeid(std::string).name()) {
|
||||||
|
field.Type = "string";
|
||||||
|
m_ComponentInfo.StringFields.push_back(field.Name);
|
||||||
|
}
|
||||||
m_ComponentInfo.Stride += sizeof(T);
|
m_ComponentInfo.Stride += sizeof(T);
|
||||||
|
m_DefaultValues.push_back(std::make_pair(field, defaultValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
ComponentInfo& Finalize()
|
ComponentInfo& Finalize()
|
||||||
{
|
{
|
||||||
m_ComponentInfo.Defaults = std::shared_ptr<char>(new char[m_ComponentInfo.Stride]);
|
m_ComponentInfo.Defaults = boost::shared_array<char>(new char[m_ComponentInfo.Stride]);
|
||||||
std::size_t offset = 0;
|
std::size_t offset = 0;
|
||||||
for (auto& val : m_DefaultValues) {
|
for (auto& pair : m_DefaultValues) {
|
||||||
memcpy(m_ComponentInfo.Defaults.get() + offset, val.Data.get(), val.Size);
|
if (pair.first.Type == "string") {
|
||||||
offset += val.Size;
|
new (m_ComponentInfo.Defaults.get() + offset) std::string(*reinterpret_cast<std::string*>(pair.second.Data.get()));
|
||||||
|
} else {
|
||||||
|
memcpy(m_ComponentInfo.Defaults.get() + offset, pair.second.Data.get(), pair.second.Size);
|
||||||
|
}
|
||||||
|
offset += pair.second.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_ComponentInfo;
|
return m_ComponentInfo;
|
||||||
@@ -131,7 +185,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ComponentInfo m_ComponentInfo;
|
ComponentInfo m_ComponentInfo;
|
||||||
std::vector<Any> m_DefaultValues;
|
std::vector<std::pair<ComponentInfo::Field_t, Any>> m_DefaultValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef EAmmoPickup_h__
|
||||||
|
#define EAmmoPickup_h__
|
||||||
|
|
||||||
|
#include "EventBroker.h"
|
||||||
|
#include "../Core/EntityWrapper.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct AmmoPickup : Event
|
||||||
|
{
|
||||||
|
EntityWrapper Player;
|
||||||
|
int AmmoGain;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,8 +9,8 @@ namespace Events
|
|||||||
|
|
||||||
struct PlayerDamage : Event
|
struct PlayerDamage : Event
|
||||||
{
|
{
|
||||||
//NOTE: this struct is missing information on what the damageSource is
|
EntityWrapper Inflictor;
|
||||||
EntityWrapper Player;
|
EntityWrapper Victim;
|
||||||
double Damage;
|
double Damage;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ namespace Events
|
|||||||
|
|
||||||
struct Shoot : Event
|
struct Shoot : Event
|
||||||
{
|
{
|
||||||
EntityWrapper Player;
|
EntityWrapper Inflictor;
|
||||||
|
double Damage;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,9 +66,25 @@ public:
|
|||||||
, m_LowestAllocatedSlot(m_NumSlots)
|
, m_LowestAllocatedSlot(m_NumSlots)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
//We may get problems with memory being released
|
MemoryPool(const MemoryPool<T>& other)
|
||||||
//prematurely, etc. if we allow copies.
|
: m_StartAddress(new char[other.m_NumSlots*other.m_Stride])
|
||||||
MemoryPool(const MemoryPool<T>& other) = delete;
|
, m_SlotIsAllocated(other.m_SlotIsAllocated)
|
||||||
|
, m_ExtraMemory()
|
||||||
|
, m_NumSlots(other.m_NumSlots)
|
||||||
|
, m_LowestAllocatedSlot(other.m_LowestAllocatedSlot)
|
||||||
|
, m_NumAllocatedSlots(other.m_NumAllocatedSlots)
|
||||||
|
, m_Stride(other.m_Stride)
|
||||||
|
, m_CurrentAllocSlot(other.m_CurrentAllocSlot)
|
||||||
|
{
|
||||||
|
// Copy statically allocated pool
|
||||||
|
memcpy(m_StartAddress, other.m_StartAddress, m_NumSlots*m_Stride);
|
||||||
|
// Copy dynamically allocated memory
|
||||||
|
for (char* otherAddr : other.m_ExtraMemory) {
|
||||||
|
char* addr = (char*)malloc(m_Stride);
|
||||||
|
memcpy(addr, otherAddr, m_Stride);
|
||||||
|
m_ExtraMemory.push_back(addr);
|
||||||
|
}
|
||||||
|
}
|
||||||
MemoryPool(const MemoryPool<T>&& other) = delete;
|
MemoryPool(const MemoryPool<T>&& other) = delete;
|
||||||
|
|
||||||
//Free all memory that has been allocated.
|
//Free all memory that has been allocated.
|
||||||
@@ -78,8 +94,9 @@ public:
|
|||||||
delete[] m_StartAddress;
|
delete[] m_StartAddress;
|
||||||
m_StartAddress = nullptr;
|
m_StartAddress = nullptr;
|
||||||
}
|
}
|
||||||
for (char* addr : m_ExtraMemory)
|
for (char* addr : m_ExtraMemory) {
|
||||||
free(addr);
|
free(addr);
|
||||||
|
}
|
||||||
m_ExtraMemory.clear();
|
m_ExtraMemory.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ public:
|
|||||||
void ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects);
|
void ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects);
|
||||||
//Get the objects that are inside the frustum, the objects are put in outObjects.
|
//Get the objects that are inside the frustum, the objects are put in outObjects.
|
||||||
void ObjectsInFrustum(const Frustum& frustum, std::vector<T>& outObjects);
|
void ObjectsInFrustum(const Frustum& frustum, std::vector<T>& outObjects);
|
||||||
|
//Get objects, which AABB the input ray intersects, the objects are put in outObjects.
|
||||||
|
void ObjectsPossiblyHitByRay(const Ray& ray, std::vector<T>& outObjects);
|
||||||
//Empty the tree of all objects, static and dynamic.
|
//Empty the tree of all objects, static and dynamic.
|
||||||
void ClearObjects();
|
void ClearObjects();
|
||||||
//Empty the tree of all dynamic objects. Static objects remain in the tree.
|
//Empty the tree of all dynamic objects. Static objects remain in the tree.
|
||||||
@@ -100,6 +102,8 @@ struct Child
|
|||||||
void ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects) const;
|
void ObjectsInSameRegion(const Box& box, std::vector<T>& outObjects) const;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void ObjectsInFrustum(const Frustum& frustum, std::vector<T>& outObjects, bool takeAllDontTest) const;
|
void ObjectsInFrustum(const Frustum& frustum, std::vector<T>& outObjects, bool takeAllDontTest) const;
|
||||||
|
template<typename T>
|
||||||
|
void ObjectsPossiblyHitByRay(const Ray& ray, std::vector<T>& outObjects) const;
|
||||||
void ClearObjects();
|
void ClearObjects();
|
||||||
void ClearDynamicObjects();
|
void ClearDynamicObjects();
|
||||||
bool RayCollides(const Ray& ray, Output& data) const;
|
bool RayCollides(const Ray& ray, Output& data) const;
|
||||||
@@ -119,6 +123,15 @@ struct Child
|
|||||||
std::vector<int> childIndicesContainingBox(const AABB& box) const;
|
std::vector<int> childIndicesContainingBox(const AABB& box) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//To be able to sort child nodes and contained objects based on distance to ray origin.
|
||||||
|
struct RaySorterInfo
|
||||||
|
{
|
||||||
|
int Index;
|
||||||
|
float Distance;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool isFirstLower(const RaySorterInfo& first, const RaySorterInfo& second);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
@@ -164,6 +177,13 @@ void Octree<T>::ObjectsInFrustum(const Frustum& frustum, std::vector<T>& outObje
|
|||||||
m_Root->ObjectsInFrustum(frustum, outObjects, false);
|
m_Root->ObjectsInFrustum(frustum, outObjects, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void Octree<T>::ObjectsPossiblyHitByRay(const Ray& ray, std::vector<T>& outObjects)
|
||||||
|
{
|
||||||
|
falsifyObjectChecks();
|
||||||
|
m_Root->ObjectsPossiblyHitByRay(ray, outObjects);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Octree<T>::ClearObjects()
|
void Octree<T>::ClearObjects()
|
||||||
{
|
{
|
||||||
@@ -282,4 +302,59 @@ void OctSpace::Child::ObjectsInFrustum(const Frustum& frustum, std::vector<T>& o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void OctSpace::Child::ObjectsPossiblyHitByRay(const Ray& ray, std::vector<T>& outObjects) const
|
||||||
|
{
|
||||||
|
//If the node AABB is missed, everything it contains is missed.
|
||||||
|
if (Collision::RayAABBIntr(ray, m_Box)) {
|
||||||
|
//If the ray shoots the tree, and it is a parent.
|
||||||
|
if (hasChildren()) {
|
||||||
|
//Sort children according to their distance from the ray origin.
|
||||||
|
std::vector<RaySorterInfo> childInfos;
|
||||||
|
childInfos.resize(8);
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
childInfos[i] = { i, glm::distance(ray.Origin(), m_Children[i]->m_Box.Origin()) };
|
||||||
|
}
|
||||||
|
std::sort(childInfos.begin(), childInfos.end(), isFirstLower);
|
||||||
|
//Loop through the children, starting with the one closest to the ray origin. I.e the first to be hit.
|
||||||
|
for (const RaySorterInfo& info : childInfos) {
|
||||||
|
m_Children[info.Index]->ObjectsPossiblyHitByRay(ray, outObjects);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Check against boxes in the node.
|
||||||
|
bool intersected = false;
|
||||||
|
float dist;
|
||||||
|
//Sort all contained objects according to the distance from the ray origin to
|
||||||
|
//the intersection, if they are intersecting.
|
||||||
|
std::vector<RaySorterInfo> objectHitInfos;
|
||||||
|
objectHitInfos.reserve(m_StaticObjIndices.size() + m_DynamicObjIndices.size());
|
||||||
|
for (int i : m_StaticObjIndices) {
|
||||||
|
//If we haven't tested against this object before, and the ray hits.
|
||||||
|
if (!m_StaticObjectsRef[i].Checked &&
|
||||||
|
Collision::RayVsAABB(ray, *m_StaticObjectsRef[i].Box, dist)) {
|
||||||
|
objectHitInfos.push_back({ i, dist });
|
||||||
|
}
|
||||||
|
m_StaticObjectsRef[i].Checked = true;
|
||||||
|
}
|
||||||
|
for (int i : m_DynamicObjIndices) {
|
||||||
|
//If we haven't tested against this object before, and the ray hits.
|
||||||
|
if (!m_DynamicObjectsRef[i].Checked &&
|
||||||
|
Collision::RayVsAABB(ray, *m_DynamicObjectsRef[i].Box, dist)) {
|
||||||
|
objectHitInfos.push_back({ i + (int)m_StaticObjIndices.size(), dist });
|
||||||
|
}
|
||||||
|
m_DynamicObjectsRef[i].Checked = true;
|
||||||
|
}
|
||||||
|
std::sort(objectHitInfos.begin(), objectHitInfos.end(), isFirstLower);
|
||||||
|
int startSize = (int)outObjects.size();
|
||||||
|
outObjects.resize(startSize + objectHitInfos.size());
|
||||||
|
for (int i = 0; i < objectHitInfos.size(); ++i) {
|
||||||
|
outObjects[startSize + i] = (objectHitInfos[i].Index < m_StaticObjIndices.size()) ?
|
||||||
|
*static_cast<T*>(m_StaticObjectsRef[objectHitInfos[i].Index].Box.get()) :
|
||||||
|
*static_cast<T*>(m_DynamicObjectsRef[objectHitInfos[i].Index - m_StaticObjIndices.size()].Box.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef PerformanceTimer_h__
|
||||||
|
#define PerformanceTimer_h__
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
|
#include <boost/timer/timer.hpp>
|
||||||
|
using boost::timer::cpu_timer;
|
||||||
|
|
||||||
|
class PerformanceTimer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void StartTimer(std::string nameOfTimer);
|
||||||
|
static void StartTimerAndStopPrevious(std::string nameOfTimer);
|
||||||
|
static void StopTimer(std::string nameOfTimer);
|
||||||
|
static void SetFrameNumber(int frameNumber);
|
||||||
|
|
||||||
|
static void ResetAllTimers();
|
||||||
|
static void CreateExcelData();
|
||||||
|
|
||||||
|
private:
|
||||||
|
static std::map<std::string, cpu_timer> timers;
|
||||||
|
static cpu_timer m_Timer;
|
||||||
|
static std::string currentTimerRunning;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "System.h"
|
#include "System.h"
|
||||||
#include "World.h"
|
#include "World.h"
|
||||||
#include "EPause.h"
|
#include "EPause.h"
|
||||||
|
#include "PerformanceTimer.h"
|
||||||
|
|
||||||
class SystemPipeline
|
class SystemPipeline
|
||||||
{
|
{
|
||||||
@@ -72,7 +73,10 @@ public:
|
|||||||
|
|
||||||
// Update
|
// Update
|
||||||
for (auto& system : group.ImpureSystems) {
|
for (auto& system : group.ImpureSystems) {
|
||||||
|
auto className = (std::string)typeid(*system).name();
|
||||||
|
PerformanceTimer::StartTimer(className);
|
||||||
system->Update(dt);
|
system->Update(dt);
|
||||||
|
PerformanceTimer::StopTimer(className);
|
||||||
}
|
}
|
||||||
for (auto& pair : group.PureSystems) {
|
for (auto& pair : group.PureSystems) {
|
||||||
const std::string& componentName = pair.first;
|
const std::string& componentName = pair.first;
|
||||||
@@ -83,7 +87,10 @@ public:
|
|||||||
}
|
}
|
||||||
for (auto& component : *pool) {
|
for (auto& component : *pool) {
|
||||||
for (auto& system : systems) {
|
for (auto& system : systems) {
|
||||||
|
auto className = (std::string)typeid(*system).name();
|
||||||
|
PerformanceTimer::StartTimer(className);
|
||||||
system->UpdateComponent(EntityWrapper(m_World, component.EntityID), component, dt);
|
system->UpdateComponent(EntityWrapper(m_World, component.EntityID), component, dt);
|
||||||
|
PerformanceTimer::StopTimer(className);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,9 +113,9 @@ private:
|
|||||||
std::vector<UnorderedSystems> m_OrderedSystemGroups;
|
std::vector<UnorderedSystems> m_OrderedSystemGroups;
|
||||||
|
|
||||||
EventRelay<SystemPipeline, Events::Pause> m_EPause;
|
EventRelay<SystemPipeline, Events::Pause> m_EPause;
|
||||||
bool OnPause(const Events::Pause& e) {
|
bool OnPause(const Events::Pause& e) {
|
||||||
if (e.World == m_World) {
|
if (e.World == m_World) {
|
||||||
m_Paused = true;
|
m_Paused = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define Util_Any_h__
|
#define Util_Any_h__
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <boost/shared_array.hpp>
|
||||||
|
|
||||||
struct Any
|
struct Any
|
||||||
{
|
{
|
||||||
@@ -10,7 +11,7 @@ struct Any
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
Any(const T& value)
|
Any(const T& value)
|
||||||
{
|
{
|
||||||
Data = std::shared_ptr<char>(new char[sizeof(T)]);
|
Data = boost::shared_array<char>(new char[sizeof(T)]);
|
||||||
Size = sizeof(T);
|
Size = sizeof(T);
|
||||||
memcpy(Data.get(), &value, Size);
|
memcpy(Data.get(), &value, Size);
|
||||||
}
|
}
|
||||||
@@ -18,7 +19,7 @@ struct Any
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
Any(T&& value)
|
Any(T&& value)
|
||||||
{
|
{
|
||||||
Data = std::shared_ptr<char>(new char[sizeof(T)]);
|
Data = boost::shared_array<char>(new char[sizeof(T)]);
|
||||||
Size = sizeof(T);
|
Size = sizeof(T);
|
||||||
memcpy(Data.get(), &value, Size);
|
memcpy(Data.get(), &value, Size);
|
||||||
}
|
}
|
||||||
@@ -35,7 +36,7 @@ struct Any
|
|||||||
return Any(value);
|
return Any(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<char> Data = nullptr;
|
boost::shared_array<char> Data = nullptr;
|
||||||
std::size_t Size = 0;
|
std::size_t Size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public:
|
|||||||
: m_EventBroker(eventBroker)
|
: m_EventBroker(eventBroker)
|
||||||
{ }
|
{ }
|
||||||
~World();
|
~World();
|
||||||
|
World(const World& other);
|
||||||
|
|
||||||
// Create empty entity
|
// Create empty entity
|
||||||
EntityID CreateEntity(EntityID parent = 0);
|
EntityID CreateEntity(EntityID parent = 0);
|
||||||
|
|||||||
@@ -1,165 +0,0 @@
|
|||||||
#ifndef GUI_BUTTON_H__
|
|
||||||
#define GUI_BUTTON_H__
|
|
||||||
|
|
||||||
#include "GUI/TextureFrame.h"
|
|
||||||
#include "GUI/EButtonEnter.h"
|
|
||||||
#include "GUI/EButtonLeave.h"
|
|
||||||
#include "GUI/EButtonPress.h"
|
|
||||||
#include "GUI/EButtonRelease.h"
|
|
||||||
#include "Core/EMouseMove.h"
|
|
||||||
#include "Core/EMousePress.h"
|
|
||||||
#include "Core/EMouseRelease.h"
|
|
||||||
|
|
||||||
namespace dd
|
|
||||||
{
|
|
||||||
namespace GUI
|
|
||||||
{
|
|
||||||
|
|
||||||
class Button : public TextureFrame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Button(Frame* parent, std::string name)
|
|
||||||
: TextureFrame(parent, name)
|
|
||||||
{
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseMove, &Button::OnMouseMove);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMousePress, &Button::OnMousePress);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EMouseRelease, &Button::OnMouseRelease);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SetTextureHover(std::string resourceName)
|
|
||||||
{
|
|
||||||
m_TextureHover = resourceName;
|
|
||||||
}
|
|
||||||
void SetTextureReleased(std::string resourceName)
|
|
||||||
{
|
|
||||||
m_TextureReleased = resourceName;
|
|
||||||
SetTexture(resourceName);
|
|
||||||
}
|
|
||||||
void SetTexturePressed(std::string resourceName)
|
|
||||||
{
|
|
||||||
m_TexturePressed = resourceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Draw(RenderScene& rq) override
|
|
||||||
{
|
|
||||||
if (m_Texture == nullptr && !m_TextureReleased.empty()) {
|
|
||||||
SetTexture(m_TextureReleased);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextureFrame::Draw(rq);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void OnEnter() { }
|
|
||||||
virtual void OnLeave() { }
|
|
||||||
virtual void OnPress() { }
|
|
||||||
virtual void OnRelease() { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool m_MouseIsOver = false;
|
|
||||||
bool m_IsDown = false;
|
|
||||||
|
|
||||||
virtual bool OnMouseMove(const Events::MouseMove& event)
|
|
||||||
{
|
|
||||||
if (Hidden()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
|
|
||||||
if (isOver && !m_MouseIsOver) { // Enter
|
|
||||||
if (!m_IsDown) {
|
|
||||||
if (!m_TextureHover.empty()) {
|
|
||||||
SetTexture(m_TextureHover);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OnEnter();
|
|
||||||
Events::ButtonEnter e;
|
|
||||||
e.FrameName = m_Name;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
Events::PlaySound soundEvent;
|
|
||||||
soundEvent.FilePath = "Sounds/GUI/hover-n.wav";
|
|
||||||
EventBroker->Publish(soundEvent);
|
|
||||||
|
|
||||||
} else if (!isOver && m_MouseIsOver) { // Leave
|
|
||||||
if (!m_IsDown) {
|
|
||||||
if (!m_TextureReleased.empty()) {
|
|
||||||
SetTexture(m_TextureReleased);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
OnLeave();
|
|
||||||
Events::ButtonLeave e;
|
|
||||||
e.FrameName = m_Name;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
}
|
|
||||||
m_MouseIsOver = isOver;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual bool OnMousePress(const Events::MousePress& event)
|
|
||||||
{
|
|
||||||
if (Hidden()) {
|
|
||||||
//LOG_DEBUG("Pressed hidden button");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1))) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!m_TexturePressed.empty()) {
|
|
||||||
SetTexture(m_TexturePressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_IsDown = true;
|
|
||||||
OnPress();
|
|
||||||
Events::ButtonPress e;
|
|
||||||
e.FrameName = m_Name;
|
|
||||||
e.Button = this;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
virtual bool OnMouseRelease(const Events::MouseRelease& event)
|
|
||||||
{
|
|
||||||
if (Hidden()) {
|
|
||||||
//LOG_DEBUG("Released hidden button");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isOver = Rectangle::Intersects(AbsoluteRectangle(), Rectangle(event.X, event.Y, 1, 1));
|
|
||||||
if (!isOver && !m_IsDown) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_MouseIsOver) {
|
|
||||||
if (!m_TextureHover.empty()) {
|
|
||||||
SetTexture(m_TextureHover);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!m_TextureReleased.empty()) {
|
|
||||||
SetTexture(m_TextureReleased);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m_IsDown = false;
|
|
||||||
OnRelease();
|
|
||||||
Events::ButtonRelease e;
|
|
||||||
e.FrameName = m_Name;
|
|
||||||
e.Button = this;
|
|
||||||
EventBroker->Publish(e);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
EventRelay<Frame, Events::MouseMove> m_EMouseMove;
|
|
||||||
EventRelay<Frame, Events::MousePress> m_EMousePress;
|
|
||||||
EventRelay<Frame, Events::MouseRelease> m_EMouseRelease;
|
|
||||||
|
|
||||||
std::string m_TextureHover;
|
|
||||||
std::string m_TexturePressed;
|
|
||||||
std::string m_TextureReleased;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef ButtonSystem_h__
|
||||||
|
#define ButtonSystem_h__
|
||||||
|
|
||||||
|
#include "../Rendering/IRenderer.h"
|
||||||
|
#include "../Core/ConfigFile.h"
|
||||||
|
#include "../Rendering/PickingPass.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
|
#include "../Core/System.h"
|
||||||
|
#include "../Core/Event.h"
|
||||||
|
#include "../Core/EMousePress.h"
|
||||||
|
#include "../Core/EMouseRelease.h"
|
||||||
|
#include "../Core/ELockMouse.h"
|
||||||
|
|
||||||
|
#include "EButtonPressed.h"
|
||||||
|
#include "EButtonReleased.h"
|
||||||
|
#include "EButtonClicked.h"
|
||||||
|
|
||||||
|
|
||||||
|
class ButtonSystem : public PureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ButtonSystem(SystemParams params, IRenderer* renderer);
|
||||||
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
||||||
|
private:
|
||||||
|
IRenderer* m_Renderer;
|
||||||
|
bool m_MouseIsLocked = false;
|
||||||
|
|
||||||
|
EntityWrapper m_PickEntity = EntityWrapper::Invalid;
|
||||||
|
PickData m_PickData;
|
||||||
|
|
||||||
|
EventRelay<ButtonSystem, Events::LockMouse> m_EMouseLock;
|
||||||
|
bool OnMouseLock(const Events::LockMouse& e);
|
||||||
|
EventRelay<ButtonSystem, Events::UnlockMouse> m_EMouseUnlock;
|
||||||
|
bool OnMouseUnlock(const Events::UnlockMouse& e);
|
||||||
|
|
||||||
|
EventRelay<ButtonSystem, Events::MousePress> m_EMousePress;
|
||||||
|
bool OnMousePress(const Events::MousePress& e);
|
||||||
|
EventRelay<ButtonSystem, Events::MouseRelease> m_EMouseRelease;
|
||||||
|
bool OnMouseRelease(const Events::MouseRelease& e);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef Events_ButtonClicked_h__
|
||||||
|
#define Events_ButtonClicked_h__
|
||||||
|
|
||||||
|
#include "Core/Event.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ButtonClicked : public Event {
|
||||||
|
std::string EntityName;
|
||||||
|
EntityWrapper Entity;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#ifndef Events_ButtonEnter_h__
|
|
||||||
#define Events_ButtonEnter_h__
|
|
||||||
|
|
||||||
#include "../Core/EventBroker.h"
|
|
||||||
|
|
||||||
namespace Events
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Thrown on GUI button hover. */
|
|
||||||
struct ButtonEnter : Event
|
|
||||||
{
|
|
||||||
std::string FrameName;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#ifndef Events_ButtonLeave_h__
|
|
||||||
#define Events_ButtonLeave_h__
|
|
||||||
|
|
||||||
#include "../Core/EventBroker.h"
|
|
||||||
|
|
||||||
namespace Events
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Thrown on GUI button hover. */
|
|
||||||
struct ButtonLeave : Event
|
|
||||||
{
|
|
||||||
std::string FrameName;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#ifndef Events_ButtonPress_h__
|
|
||||||
#define Events_ButtonPress_h__
|
|
||||||
|
|
||||||
#include "../Core/EventBroker.h"
|
|
||||||
|
|
||||||
namespace GUI { class Button; }
|
|
||||||
|
|
||||||
namespace Events
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Thrown on GUI button press. */
|
|
||||||
struct ButtonPress : Event
|
|
||||||
{
|
|
||||||
std::string FrameName;
|
|
||||||
GUI::Button* Button;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef Events_ButtonPressed_h__
|
||||||
|
#define Events_ButtonPressed_h__
|
||||||
|
|
||||||
|
#include "Core/Event.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ButtonPressed : public Event {
|
||||||
|
std::string EntityName;
|
||||||
|
EntityWrapper Entity;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
#ifndef Events_ButtonRelease_h__
|
|
||||||
#define Events_ButtonRelease_h__
|
|
||||||
|
|
||||||
#include "../Core/EventBroker.h"
|
|
||||||
|
|
||||||
namespace GUI { class Button; }
|
|
||||||
|
|
||||||
namespace Events
|
|
||||||
{
|
|
||||||
|
|
||||||
/** Thrown on GUI button release. */
|
|
||||||
struct ButtonRelease : Event
|
|
||||||
{
|
|
||||||
std::string FrameName;
|
|
||||||
GUI::Button* Button;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef Events_ButtonReleased_h__
|
||||||
|
#define Events_ButtonReleased_h__
|
||||||
|
|
||||||
|
#include "Core/Event.h"
|
||||||
|
|
||||||
|
namespace Events
|
||||||
|
{
|
||||||
|
|
||||||
|
struct ButtonReleased : public Event {
|
||||||
|
std::string EntityName;
|
||||||
|
EntityWrapper Entity;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,261 +0,0 @@
|
|||||||
#ifndef GUI_Frame_h__
|
|
||||||
#define GUI_Frame_h__
|
|
||||||
|
|
||||||
#include "../Common.h"
|
|
||||||
#include "../Core/Util/Rectangle.h"
|
|
||||||
#include "../Core/EventBroker.h"
|
|
||||||
#include "../Core/EKeyDown.h"
|
|
||||||
#include "../Core/EKeyUp.h"
|
|
||||||
#include "../Core/ResourceManager.h"
|
|
||||||
#include "../Rendering/RenderQueue.h"
|
|
||||||
#include "../Rendering/Texture.h"
|
|
||||||
#include "../Input/EInputCommand.h"
|
|
||||||
|
|
||||||
namespace GUI
|
|
||||||
{
|
|
||||||
|
|
||||||
class Frame : public Rectangle
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
enum class Anchor
|
|
||||||
{
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Top,
|
|
||||||
Bottom
|
|
||||||
};
|
|
||||||
|
|
||||||
static const int BaseWidth = 1280;
|
|
||||||
static const int BaseHeight = 720;
|
|
||||||
|
|
||||||
// Set up a base frame with an event broker
|
|
||||||
Frame(EventBroker* eventBroker)
|
|
||||||
: m_EventBroker(eventBroker)
|
|
||||||
, BaseFrame(this)
|
|
||||||
, m_Name("UIParent")
|
|
||||||
, Rectangle() { }
|
|
||||||
|
|
||||||
// Create a frame as a child
|
|
||||||
Frame(Frame* parent, std::string name)
|
|
||||||
: m_Name(name)
|
|
||||||
{
|
|
||||||
SetParent(parent);
|
|
||||||
Width = parent->Width;
|
|
||||||
Height = parent->Height;
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyDown, &Frame::OnKeyDown);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EKeyUp, &Frame::OnKeyUp);
|
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Frame::OnCommand);
|
|
||||||
}
|
|
||||||
|
|
||||||
~Frame()
|
|
||||||
{
|
|
||||||
/*for (auto layer : m_Children)
|
|
||||||
{
|
|
||||||
for (auto child : layer.second)
|
|
||||||
{
|
|
||||||
delete child.second;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Parent)
|
|
||||||
{
|
|
||||||
m_Parent->RemoveChild(this);
|
|
||||||
}*/
|
|
||||||
}
|
|
||||||
|
|
||||||
Frame* Parent() const { return m_Parent; }
|
|
||||||
|
|
||||||
void SetParent(Frame* parent)
|
|
||||||
{
|
|
||||||
if (parent == nullptr) {
|
|
||||||
LOG_ERROR("Failed to parent frame \"%s\": Invalid parent", m_Name.c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Layer = parent->Layer() + 1;
|
|
||||||
parent->AddChild(this);
|
|
||||||
m_Parent = parent;
|
|
||||||
m_EventBroker = parent->m_EventBroker;
|
|
||||||
BaseFrame = parent->BaseFrame;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AddChild(Frame* child)
|
|
||||||
{
|
|
||||||
m_Children[child->m_Layer].insert(std::make_pair(child->Name(), child));
|
|
||||||
if (m_Parent) {
|
|
||||||
m_Parent->AddChild(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RemoveChild(Frame* child)
|
|
||||||
{
|
|
||||||
auto it = m_Children.find(child->m_Layer);
|
|
||||||
if (it != m_Children.end()) {
|
|
||||||
m_Children.erase(it);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_Parent) {
|
|
||||||
m_Parent->RemoveChild(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Name() const { return m_Name; }
|
|
||||||
void SetName(std::string val) { m_Name = val; }
|
|
||||||
|
|
||||||
int Layer() const { return m_Layer; }
|
|
||||||
|
|
||||||
bool Hidden() const
|
|
||||||
{
|
|
||||||
if (m_Parent)
|
|
||||||
return m_Parent->Hidden() || m_Hidden;
|
|
||||||
else
|
|
||||||
return m_Hidden;
|
|
||||||
}
|
|
||||||
bool Visible() const
|
|
||||||
{
|
|
||||||
return !Hidden();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Hide() { m_Hidden = true; }
|
|
||||||
virtual void Show() { m_Hidden = false; }
|
|
||||||
|
|
||||||
int Left() const override
|
|
||||||
{
|
|
||||||
if (m_Parent)
|
|
||||||
return m_Parent->Left() + X;
|
|
||||||
else
|
|
||||||
return X;
|
|
||||||
}
|
|
||||||
void SetLeft(int absLeft) override
|
|
||||||
{
|
|
||||||
if (m_Parent) {
|
|
||||||
X = absLeft - m_Parent->Left();
|
|
||||||
} else {
|
|
||||||
X = absLeft;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int Right() const override
|
|
||||||
{
|
|
||||||
return Left() + Width;
|
|
||||||
}
|
|
||||||
void SetRight(int absRight) override
|
|
||||||
{
|
|
||||||
if (m_Parent) {
|
|
||||||
X = absRight - Width - m_Parent->Left();
|
|
||||||
} else {
|
|
||||||
X = absRight - Width;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int Top() const override
|
|
||||||
{
|
|
||||||
if (m_Parent)
|
|
||||||
return m_Parent->Top() + Y;
|
|
||||||
else
|
|
||||||
return Y;
|
|
||||||
}
|
|
||||||
void SetTop(int absTop) override
|
|
||||||
{
|
|
||||||
if (m_Parent) {
|
|
||||||
Y = absTop - m_Parent->Top();
|
|
||||||
} else {
|
|
||||||
Y = absTop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
int Bottom() const override
|
|
||||||
{
|
|
||||||
return Top() + Height;
|
|
||||||
}
|
|
||||||
void SetBottom(int absBottom) override
|
|
||||||
{
|
|
||||||
if (m_Parent) {
|
|
||||||
Y = absBottom - Height - m_Parent->Top();
|
|
||||||
} else {
|
|
||||||
Y = absBottom - Height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec2 Scale()
|
|
||||||
{
|
|
||||||
if (m_Parent)
|
|
||||||
return m_Parent->Scale();
|
|
||||||
else
|
|
||||||
return glm::vec2(Width, Height) / glm::vec2(BaseWidth, BaseHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
Rectangle AbsoluteRectangle()
|
|
||||||
{
|
|
||||||
int left = Left();
|
|
||||||
if (m_Parent)
|
|
||||||
left = std::max(left, m_Parent->Left());
|
|
||||||
int top = Top();
|
|
||||||
if (m_Parent)
|
|
||||||
top = std::max(top, m_Parent->Top());
|
|
||||||
int width = Right() - left;
|
|
||||||
int height = Bottom() - top;
|
|
||||||
return Rectangle(left, top, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateLayered(double dt)
|
|
||||||
{
|
|
||||||
// Update ourselves
|
|
||||||
this->Update(dt);
|
|
||||||
|
|
||||||
// Update children
|
|
||||||
for (auto& pairLayer : m_Children) {
|
|
||||||
auto children = pairLayer.second;
|
|
||||||
for (auto& pairChild : children) {
|
|
||||||
auto child = pairChild.second;
|
|
||||||
child->Update(dt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Update(double dt) { }
|
|
||||||
|
|
||||||
void DrawLayered(RenderScene& rq)
|
|
||||||
{
|
|
||||||
if (this->Hidden())
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Draw ourselves
|
|
||||||
this->Draw(rq);
|
|
||||||
|
|
||||||
// Draw children
|
|
||||||
for (auto& pairLayer : m_Children) {
|
|
||||||
auto children = pairLayer.second;
|
|
||||||
for (auto& pairChild : children) {
|
|
||||||
auto child = pairChild.second;
|
|
||||||
if (child->Hidden())
|
|
||||||
continue;
|
|
||||||
child->Draw(rq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Draw(RenderScene& rq) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
::EventBroker* m_EventBroker;
|
|
||||||
Frame* BaseFrame = nullptr;
|
|
||||||
|
|
||||||
std::string m_Name = "Unnamed";
|
|
||||||
int m_Layer = 0;
|
|
||||||
bool m_Hidden = false;
|
|
||||||
|
|
||||||
Frame* m_Parent = nullptr;
|
|
||||||
typedef std::multimap<std::string, Frame*> Children_t; // name -> frame
|
|
||||||
std::map<int, Children_t> m_Children; // layer -> Children_t
|
|
||||||
|
|
||||||
virtual bool OnKeyDown(const Events::KeyDown& event) { return false; }
|
|
||||||
virtual bool OnKeyUp(const Events::KeyUp& event) { return false; }
|
|
||||||
virtual bool OnCommand(const Events::InputCommand& event) { return false; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
EventRelay<Frame, Events::KeyDown> m_EKeyDown;
|
|
||||||
EventRelay<Frame, Events::KeyUp> m_EKeyUp;
|
|
||||||
EventRelay<Frame, Events::InputCommand> m_EInputCommand;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef MainMenuSystem_h__
|
||||||
|
#define MainMenuSystem_h__
|
||||||
|
|
||||||
|
#include "../Core/System.h"
|
||||||
|
#include "../Rendering/IRenderer.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
|
#include "../Core/Event.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include "EButtonClicked.h"
|
||||||
|
#include "EButtonPressed.h"
|
||||||
|
#include "EButtonReleased.h"
|
||||||
|
|
||||||
|
|
||||||
|
class MainMenuSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MainMenuSystem(SystemParams params, IRenderer* renderer);
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
IRenderer* m_Renderer;
|
||||||
|
|
||||||
|
EventRelay<MainMenuSystem, Events::ButtonClicked> m_EClicked;
|
||||||
|
bool OnButtonClick(const Events::ButtonClicked& e);
|
||||||
|
EventRelay<MainMenuSystem, Events::ButtonReleased> m_EReleased;
|
||||||
|
bool OnButtonRelease(const Events::ButtonReleased& e);
|
||||||
|
EventRelay<MainMenuSystem, Events::ButtonPressed> m_EPressed;
|
||||||
|
bool OnButtonPress(const Events::ButtonPressed& e);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,111 +0,0 @@
|
|||||||
#ifndef GUI_TextureFrame_h__
|
|
||||||
#define GUI_TextureFrame_h__
|
|
||||||
|
|
||||||
#include "Frame.h"
|
|
||||||
#include "../Rendering/Texture.h"
|
|
||||||
|
|
||||||
namespace GUI
|
|
||||||
{
|
|
||||||
|
|
||||||
class TextureFrame : public Frame
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextureFrame(Frame* parent, std::string name)
|
|
||||||
: Frame(parent, name) { }
|
|
||||||
|
|
||||||
void EnableScissor() { m_ScissorEnabled = true; }
|
|
||||||
void DisableScissor() { m_ScissorEnabled = false; }
|
|
||||||
|
|
||||||
void Draw(RenderScene& rq) override
|
|
||||||
{
|
|
||||||
if (m_Texture == nullptr)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Texture while fading
|
|
||||||
if (m_FadeTexture && m_CurrentFade < 1) {
|
|
||||||
FrameJob job;
|
|
||||||
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
|
|
||||||
job.Viewport = Rectangle(Left(), Top(), Width, Height);
|
|
||||||
job.TextureID = m_FadeTexture->ResourceID;
|
|
||||||
job.DiffuseTexture = m_FadeTexture;
|
|
||||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a);
|
|
||||||
job.Name = Name();
|
|
||||||
rq.GUI.Add(job);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Main texture
|
|
||||||
{
|
|
||||||
FrameJob job;
|
|
||||||
job.Scissor = (m_ScissorEnabled) ? m_Parent->AbsoluteRectangle() : Rectangle();
|
|
||||||
job.Viewport = Rectangle(Left(), Top(), Width, Height);
|
|
||||||
job.TextureID = m_Texture->ResourceID;
|
|
||||||
job.DiffuseTexture = m_Texture;
|
|
||||||
job.Color = glm::vec4(m_Color.r, m_Color.g, m_Color.b, m_Color.a * m_CurrentFade);
|
|
||||||
job.Name = Name();
|
|
||||||
rq.GUI.Add(job);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Texture() const { return m_TextureName; }
|
|
||||||
|
|
||||||
void SetTexture(std::string resourceName)
|
|
||||||
{
|
|
||||||
if (resourceName.empty()) {
|
|
||||||
m_Texture = nullptr;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_Texture = ResourceManager::Load<Texture>(resourceName);
|
|
||||||
m_TextureName = resourceName;
|
|
||||||
if (m_Texture == nullptr) {
|
|
||||||
m_Texture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
SizeToTexture();
|
|
||||||
}
|
|
||||||
|
|
||||||
void SizeToTexture()
|
|
||||||
{
|
|
||||||
if (m_Texture != nullptr) {
|
|
||||||
this->Width = m_Texture->Width;
|
|
||||||
this->Height = m_Texture->Height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FadeToTexture(std::string resourceName, double duration)
|
|
||||||
{
|
|
||||||
m_FadeTexture = m_Texture;
|
|
||||||
SetTexture(resourceName);
|
|
||||||
m_FadeDuration = duration;
|
|
||||||
m_CurrentFade = 0.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Update(double dt) override
|
|
||||||
{
|
|
||||||
if (m_CurrentFade < 1) {
|
|
||||||
m_CurrentFade += dt / m_FadeDuration;
|
|
||||||
if (m_CurrentFade > 1) {
|
|
||||||
m_FadeTexture = nullptr;
|
|
||||||
m_CurrentFade = 1;
|
|
||||||
m_FadeDuration = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::vec4 Color() const { return m_Color; }
|
|
||||||
void SetColor(glm::vec4 val) { m_Color = val; }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
bool m_ScissorEnabled = true;
|
|
||||||
Texture* m_Texture = nullptr;
|
|
||||||
std::string m_TextureName;
|
|
||||||
Texture* m_FadeTexture = nullptr;
|
|
||||||
glm::vec4 m_Color = glm::vec4(1.f, 1.f, 1.f, 1.f);
|
|
||||||
float m_FadeDuration = 0.f;
|
|
||||||
float m_CurrentFade = 1.f;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -202,7 +202,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
//dashing with shift
|
//dashing with shift
|
||||||
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f && !isJumping) {
|
if (m_ShiftDashing && m_AssaultDashCoolDownTimer <= 0.0f) {
|
||||||
//player is dashing with shift
|
//player is dashing with shift
|
||||||
//the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in!
|
//the wanted-direction is set in playermovement already so we dont need to check what direction we want to dash in!
|
||||||
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
m_AssaultDashCoolDownTimer = assaultDashCoolDownMaxTimer;
|
||||||
@@ -227,7 +227,7 @@ void FirstPersonInputController<EventContext>::AssaultDashCheck(double dt, bool
|
|||||||
}
|
}
|
||||||
m_ValidDoubleTap = false;
|
m_ValidDoubleTap = false;
|
||||||
|
|
||||||
if (!(m_AssaultDashCoolDownTimer <= 0.0f && !isJumping)) {
|
if (!(m_AssaultDashCoolDownTimer <= 0.0f)) {
|
||||||
//if we cant dash at the moment, then just reset the tap-sensitivity-timer
|
//if we cant dash at the moment, then just reset the tap-sensitivity-timer
|
||||||
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
m_AssaultDashDoubleTapDeltaTime = 0.f;
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include "Network/Network.h"
|
#include "Network/Network.h"
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
|
#include "Network/UDPClient.h"
|
||||||
|
#include "Network/TCPClient.h"
|
||||||
#include "Network/SnapshotDefinitions.h"
|
#include "Network/SnapshotDefinitions.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
@@ -33,17 +35,15 @@ public:
|
|||||||
void Connect(std::string address, int port);
|
void Connect(std::string address, int port);
|
||||||
void Update() override;
|
void Update() override;
|
||||||
|
|
||||||
private:
|
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
||||||
|
void parseSpawnEvents();
|
||||||
|
// Save for children
|
||||||
std::unique_ptr<SnapshotFilter> m_SnapshotFilter = nullptr;
|
std::unique_ptr<SnapshotFilter> m_SnapshotFilter = nullptr;
|
||||||
|
|
||||||
// Assio UDP logic
|
std::string m_Address;
|
||||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
int m_Port = 0;
|
||||||
boost::asio::io_service m_IOService;
|
|
||||||
boost::asio::ip::udp::socket m_Socket;
|
|
||||||
|
|
||||||
// Sending message to server logic
|
// Sending message to server logic
|
||||||
size_t bytesRead = 0;
|
size_t bytesRead = 0;
|
||||||
char readBuf[INPUTSIZE] = { 0 };
|
|
||||||
|
|
||||||
// Packet loss logic
|
// Packet loss logic
|
||||||
PacketID m_PacketID = 0;
|
PacketID m_PacketID = 0;
|
||||||
@@ -72,16 +72,14 @@ private:
|
|||||||
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
std::vector<Events::InputCommand> m_InputCommandBuffer;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
void readFromServer();
|
|
||||||
size_t receive(char* data);
|
size_t receive(char* data);
|
||||||
void send(Packet& packet);
|
|
||||||
void connect();
|
|
||||||
void disconnect();
|
void disconnect();
|
||||||
void parseMessageType(Packet& packet);
|
void parseMessageType(Packet& packet);
|
||||||
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
void updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID);
|
||||||
SharedComponentWrapper createSharedComponent(Packet& packet, EntityID entityID, const ComponentInfo& componentInfo);
|
SharedComponentWrapper createSharedComponent(Packet& packet, EntityID entityID, const ComponentInfo& componentInfo);
|
||||||
void ignoreFields(Packet& packet, const ComponentInfo& componentInfo);
|
void ignoreFields(Packet& packet, const ComponentInfo& componentInfo);
|
||||||
void parseConnect(Packet& packet);
|
void parseUDPConnect(Packet& packet);
|
||||||
|
void parseTCPConnect(Packet& packet);
|
||||||
void parsePlayerConnected(Packet& packet);
|
void parsePlayerConnected(Packet& packet);
|
||||||
void parsePing();
|
void parsePing();
|
||||||
void parseKick();
|
void parseKick();
|
||||||
@@ -91,7 +89,7 @@ private:
|
|||||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||||
void parseSnapshot(Packet& packet);
|
void parseSnapshot(Packet& packet);
|
||||||
void identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
bool hasServerTimedOut();
|
void hasServerTimedOut();
|
||||||
EntityID createPlayer();
|
EntityID createPlayer();
|
||||||
void sendInputCommands();
|
void sendInputCommands();
|
||||||
void sendLocalPlayerTransform();
|
void sendLocalPlayerTransform();
|
||||||
@@ -111,6 +109,10 @@ private:
|
|||||||
bool OnPlayerDamage(const Events::PlayerDamage& e);
|
bool OnPlayerDamage(const Events::PlayerDamage& e);
|
||||||
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
||||||
|
void parsePlayerDamage(Packet& packet);
|
||||||
|
private:
|
||||||
|
UDPClient m_Unreliable;
|
||||||
|
TCPClient m_Reliable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
#ifndef HybridClient_h__
|
||||||
|
#define HybridClient_h__
|
||||||
|
|
||||||
|
class HybridClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HybridClient();
|
||||||
|
~HybridClient();
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#ifndef HybridServer_h__
|
||||||
|
#define HybridServer_h__
|
||||||
|
|
||||||
|
class HybridServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HybridServer();
|
||||||
|
~HybridServer();
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -18,7 +18,8 @@ enum class MessageType
|
|||||||
OnPlayerSpawned,
|
OnPlayerSpawned,
|
||||||
EntityDeleted,
|
EntityDeleted,
|
||||||
ComponentDeleted,
|
ComponentDeleted,
|
||||||
PlayerTransform
|
PlayerTransform,
|
||||||
|
Invalid
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define INPUTSIZE 32000
|
#define BUFFERSIZE 32000
|
||||||
typedef unsigned int PlayerID;
|
typedef unsigned int PlayerID;
|
||||||
typedef unsigned int PacketID;
|
typedef unsigned int PacketID;
|
||||||
|
|
||||||
@@ -35,6 +35,8 @@ protected:
|
|||||||
std::clock_t m_SaveDataTimer;
|
std::clock_t m_SaveDataTimer;
|
||||||
unsigned int m_MaxConnections;
|
unsigned int m_MaxConnections;
|
||||||
double m_TimeoutMs;
|
double m_TimeoutMs;
|
||||||
|
void logSentData(int bytesSent);
|
||||||
|
void logReceivedData(int bytesReceived);
|
||||||
void saveToFile();
|
void saveToFile();
|
||||||
void updateNetworkData();
|
void updateNetworkData();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef NetworkClient_h__
|
||||||
|
#define NetworkClient_h__
|
||||||
|
|
||||||
|
#include "Network/Packet.h"
|
||||||
|
#define BUFFERSIZE 64000
|
||||||
|
typedef unsigned int PlayerID;
|
||||||
|
typedef unsigned int PacketID;
|
||||||
|
|
||||||
|
class NetworkClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void Connect(std::string playerName, std::string address, int port) = 0;
|
||||||
|
virtual void Disconnect() = 0;
|
||||||
|
virtual void Receive(Packet& packet) = 0;
|
||||||
|
virtual void Send(Packet & packet) = 0;
|
||||||
|
virtual bool IsSocketAvailable() = 0;
|
||||||
|
protected:
|
||||||
|
char m_ReadBuffer[BUFFERSIZE] = { 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#ifndef NetworkServer_h__
|
||||||
|
#define NetworkServer_h__
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
#include "Network/Packet.h"
|
||||||
|
#include "Network/PlayerDefinition.h"
|
||||||
|
#define BUFFERSIZE 64000
|
||||||
|
typedef unsigned int PlayerID;
|
||||||
|
typedef unsigned int PacketID;
|
||||||
|
|
||||||
|
class NetworkServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers) = 0;
|
||||||
|
virtual void Receive(Packet & packet, PlayerDefinition & playerDefinition) = 0;
|
||||||
|
virtual void Send(Packet & packet, PlayerDefinition & playerDefinition) = 0;
|
||||||
|
virtual void Send(Packet & packet) = 0;
|
||||||
|
protected:
|
||||||
|
char m_ReadBuffer[BUFFERSIZE] = { 0 };
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -49,10 +49,15 @@ public:
|
|||||||
void WriteData(char* data, int sizeOfData);
|
void WriteData(char* data, int sizeOfData);
|
||||||
// Pops the first element as if it was a string.
|
// Pops the first element as if it was a string.
|
||||||
std::string ReadString();
|
std::string ReadString();
|
||||||
|
// Construct a packet
|
||||||
|
void ReconstructFromData(char* data, size_t SizeOfData);
|
||||||
|
// Update size of packet variable in header
|
||||||
|
void UpdateSize();
|
||||||
char* ReadData(int SizeOfData);
|
char* ReadData(int SizeOfData);
|
||||||
void ChangePacketID(unsigned int& packetID);
|
void ChangePacketID(unsigned int& packetID);
|
||||||
size_t Size() { return m_Offset; };
|
size_t Size() { return m_Offset; };
|
||||||
char* Data() { return m_Data; };
|
char* Data() { return m_Data; };
|
||||||
|
MessageType GetMessageType();
|
||||||
size_t DataReadSize() { return m_ReturnDataOffset; }
|
size_t DataReadSize() { return m_ReturnDataOffset; }
|
||||||
size_t MaxSize() { return m_MaxPacketSize; }
|
size_t MaxSize() { return m_MaxPacketSize; }
|
||||||
size_t HeaderSize() { return m_HeaderSize; }
|
size_t HeaderSize() { return m_HeaderSize; }
|
||||||
@@ -64,6 +69,7 @@ private:
|
|||||||
size_t m_MaxPacketSize = 512;
|
size_t m_MaxPacketSize = 512;
|
||||||
size_t m_HeaderSize = 0;
|
size_t m_HeaderSize = 0;
|
||||||
void resizeData();
|
void resizeData();
|
||||||
|
void resizeData(int size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
#define PlayerDefinition_h__
|
#define PlayerDefinition_h__
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "../Core/Entity.h"
|
#include "../Core/Entity.h"
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
|
||||||
struct PlayerDefinition {
|
struct PlayerDefinition {
|
||||||
::EntityID EntityID = EntityID_Invalid;
|
::EntityID EntityID = EntityID_Invalid;
|
||||||
@@ -9,6 +10,10 @@ struct PlayerDefinition {
|
|||||||
boost::asio::ip::udp::endpoint Endpoint;
|
boost::asio::ip::udp::endpoint Endpoint;
|
||||||
unsigned int PacketID;
|
unsigned int PacketID;
|
||||||
std::clock_t StopTime;
|
std::clock_t StopTime;
|
||||||
|
boost::asio::ip::address TCPAddress;
|
||||||
|
unsigned short TCPPort;
|
||||||
|
// use for tcp connections
|
||||||
|
boost::shared_ptr<boost::asio::ip::tcp::socket> TCPSocket;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -5,8 +5,9 @@
|
|||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#include <glm/common.hpp>
|
#include <glm/common.hpp>
|
||||||
#include <boost/asio/ip/udp.hpp>
|
|
||||||
|
|
||||||
|
#include "Network/TCPServer.h"
|
||||||
|
#include "Network/UDPServer.h"
|
||||||
#include "Network/MessageType.h"
|
#include "Network/MessageType.h"
|
||||||
#include "Network/PlayerDefinition.h"
|
#include "Network/PlayerDefinition.h"
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
@@ -28,28 +29,29 @@ public:
|
|||||||
void Update() override;
|
void Update() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Network channels
|
||||||
|
TCPServer m_Reliable;
|
||||||
|
UDPServer m_Unreliable;
|
||||||
|
// dont forget to set these in the childrens receive logic
|
||||||
|
boost::asio::ip::address m_Address;
|
||||||
int m_Port = 27666;
|
int m_Port = 27666;
|
||||||
// UDP logic
|
|
||||||
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
|
||||||
boost::asio::io_service m_IOService;
|
|
||||||
std::unique_ptr<boost::asio::ip::udp::socket> m_Socket;
|
|
||||||
|
|
||||||
// Sending messages to client logic
|
// Sending messages to client logic
|
||||||
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
std::map<PlayerID, PlayerDefinition> m_ConnectedPlayers;
|
||||||
|
std::vector<PlayerID> m_PlayersToDisconnect;
|
||||||
// HACK: Fix INPUTSIZE
|
// HACK: Fix INPUTSIZE
|
||||||
char readBuffer[INPUTSIZE] = { 0 };
|
char readBuffer[BUFFERSIZE] = { 0 };
|
||||||
size_t bytesRead = 0;
|
size_t bytesRead = 0;
|
||||||
// time for previouse message
|
// time for previouse message
|
||||||
std::clock_t previousePingMessage = std::clock();
|
std::clock_t previousePingMessage = std::clock();
|
||||||
std::clock_t previousSnapshotMessage = std::clock();
|
std::clock_t previousSnapshotMessage = std::clock();
|
||||||
std::clock_t timOutTimer = std::clock();
|
std::clock_t timOutTimer = std::clock();
|
||||||
|
|
||||||
// How often we send messages (milliseconds)
|
// How often we send messages (milliseconds)
|
||||||
float pingIntervalMs;
|
float pingIntervalMs;
|
||||||
float snapshotInterval;
|
float snapshotInterval;
|
||||||
int checkTimeOutInterval = 100;
|
int checkTimeOutInterval = 100;
|
||||||
int m_NextPlayerID = 0;
|
int m_NextPlayerID = 0;
|
||||||
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
std::vector<Events::InputCommand> m_InputCommandsToBroadcast;
|
||||||
|
|
||||||
//Timers
|
//Timers
|
||||||
std::clock_t m_StartPingTime;
|
std::clock_t m_StartPingTime;
|
||||||
|
|
||||||
@@ -58,11 +60,9 @@ private:
|
|||||||
PacketID m_PreviousPacketID = 0;
|
PacketID m_PreviousPacketID = 0;
|
||||||
|
|
||||||
// Private member functions
|
// Private member functions
|
||||||
size_t receive(char* data);
|
//int receive(char* data);
|
||||||
void readFromClients();
|
void reliableBroadcast(Packet& packet);
|
||||||
void send(PlayerID player, Packet& packet);
|
void unreliableBroadcast(Packet& packet);
|
||||||
void send(Packet& packet);
|
|
||||||
void broadcast(Packet& packet);
|
|
||||||
void sendSnapshot();
|
void sendSnapshot();
|
||||||
void addChildrenToPacket(Packet& packet, EntityID entityID);
|
void addChildrenToPacket(Packet& packet, EntityID entityID);
|
||||||
void addInputCommandsToPacket(Packet& packet);
|
void addInputCommandsToPacket(Packet& packet);
|
||||||
@@ -70,15 +70,19 @@ private:
|
|||||||
void checkForTimeOuts();
|
void checkForTimeOuts();
|
||||||
void disconnect(PlayerID playerID);
|
void disconnect(PlayerID playerID);
|
||||||
void parseMessageType(Packet& packet);
|
void parseMessageType(Packet& packet);
|
||||||
void parseOnInputCommand(Packet& packet);
|
|
||||||
void parseOnPlayerDamage(Packet& packet);
|
void parseOnPlayerDamage(Packet& packet);
|
||||||
void parseConnect(Packet& packet);
|
|
||||||
void parseDisconnect();
|
|
||||||
void parseClientPing();
|
|
||||||
void parsePing();
|
|
||||||
void identifyPacketLoss();
|
void identifyPacketLoss();
|
||||||
void kick(PlayerID player);
|
void kick(PlayerID player);
|
||||||
PlayerID GetPlayerIDFromEndpoint(boost::asio::ip::udp::endpoint endpoint);
|
PlayerID GetPlayerIDFromEndpoint();
|
||||||
|
void parsePlayerTransform(Packet& packet);
|
||||||
|
void parseOnInputCommand(Packet& packet);
|
||||||
|
void parseClientPing();
|
||||||
|
void parsePing();
|
||||||
|
void parseUDPConnect(Packet & packet);
|
||||||
|
void parseTCPConnect(Packet & packet);
|
||||||
|
void parseDisconnect();
|
||||||
|
bool shouldSendToClient(EntityWrapper childEntity);
|
||||||
|
|
||||||
// Debug event
|
// Debug event
|
||||||
EventRelay<Server, Events::InputCommand> m_EInputCommand;
|
EventRelay<Server, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
@@ -88,7 +92,8 @@ private:
|
|||||||
bool OnEntityDeleted(const Events::EntityDeleted& e);
|
bool OnEntityDeleted(const Events::EntityDeleted& e);
|
||||||
EventRelay<Server, Events::ComponentDeleted> m_EComponentDeleted;
|
EventRelay<Server, Events::ComponentDeleted> m_EComponentDeleted;
|
||||||
bool OnComponentDeleted(const Events::ComponentDeleted& e);
|
bool OnComponentDeleted(const Events::ComponentDeleted& e);
|
||||||
void parsePlayerTransform(Packet& packet);
|
EventRelay<Server, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
|
bool OnPlayerDamage(const Events::PlayerDamage& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef TCPClient_h__
|
||||||
|
#define TCPClient_h__
|
||||||
|
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
#include "NetworkClient.h"
|
||||||
|
|
||||||
|
class TCPClient : public NetworkClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TCPClient();
|
||||||
|
~TCPClient();
|
||||||
|
|
||||||
|
void Connect(std::string playerName, std::string address, int port);
|
||||||
|
void Disconnect();
|
||||||
|
void Receive(Packet& packet);
|
||||||
|
void Send(Packet & packet);
|
||||||
|
bool IsSocketAvailable();
|
||||||
|
private:
|
||||||
|
// Assio TCP logic
|
||||||
|
boost::asio::ip::tcp::endpoint m_Endpoint;
|
||||||
|
boost::asio::io_service m_IOService;
|
||||||
|
std::unique_ptr<boost::asio::ip::tcp::socket> m_Socket;
|
||||||
|
size_t readBuffer(char* data);
|
||||||
|
PacketID m_SendPacketID = 0;
|
||||||
|
bool m_IsConnected = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef TCPServer_h__
|
||||||
|
#define TCPServer_h__
|
||||||
|
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
#include <boost/bind.hpp>
|
||||||
|
#include <map>
|
||||||
|
#include "NetworkServer.h"
|
||||||
|
|
||||||
|
class TCPServer : public NetworkServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TCPServer();
|
||||||
|
~TCPServer();
|
||||||
|
void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers);
|
||||||
|
void Receive(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
|
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
|
void Send(Packet & packet);
|
||||||
|
void Disconnect();
|
||||||
|
private:
|
||||||
|
// TCP logic
|
||||||
|
boost::asio::io_service m_IOService;
|
||||||
|
std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
|
||||||
|
boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket;
|
||||||
|
|
||||||
|
void handle_accept(boost::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||||
|
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||||
|
const boost::system::error_code& error);
|
||||||
|
int readBuffer(char* data, PlayerDefinition& playerDefinition);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef UDPClient_h__
|
||||||
|
#define UDPClient_h__
|
||||||
|
|
||||||
|
#include <boost/asio.hpp>
|
||||||
|
#include "Network/NetworkClient.h"
|
||||||
|
|
||||||
|
class UDPClient : public NetworkClient
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UDPClient();
|
||||||
|
~UDPClient();
|
||||||
|
|
||||||
|
void Connect(std::string playerName, std::string address, int port);
|
||||||
|
void Disconnect();
|
||||||
|
void Receive(Packet& packet);
|
||||||
|
void Send(Packet & packet);
|
||||||
|
bool IsSocketAvailable();
|
||||||
|
private:
|
||||||
|
// Assio UDP logic
|
||||||
|
boost::asio::io_service m_IOService;
|
||||||
|
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||||
|
boost::shared_ptr<boost::asio::ip::udp::socket> m_Socket;
|
||||||
|
int readBuffer(char* data);
|
||||||
|
PacketID m_SendPacketID = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#ifndef UDPServer_h__
|
||||||
|
#define UDPServer_h__
|
||||||
|
|
||||||
|
#include "NetworkServer.h"
|
||||||
|
#include <boost/asio/ip/udp.hpp>
|
||||||
|
|
||||||
|
class UDPServer : public NetworkServer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UDPServer();
|
||||||
|
~UDPServer();
|
||||||
|
void AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers);
|
||||||
|
void Receive(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
|
void Send(Packet & packet, PlayerDefinition & playerDefinition);
|
||||||
|
void Send(Packet & packet);
|
||||||
|
bool IsSocketAvailable();
|
||||||
|
private:
|
||||||
|
// UDP logic
|
||||||
|
boost::asio::io_service m_IOService;
|
||||||
|
boost::asio::ip::udp::endpoint m_ReceiverEndpoint;
|
||||||
|
std::unique_ptr<boost::asio::ip::udp::socket> m_Socket;
|
||||||
|
int readBuffer(char* data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -33,6 +33,8 @@ public:
|
|||||||
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
|
glm::mat4 ViewMatrix() const { return m_ViewMatrix; }
|
||||||
void SetViewMatrix(glm::mat4 val);
|
void SetViewMatrix(glm::mat4 val);
|
||||||
|
|
||||||
|
glm::mat4 BillboardMatrix();
|
||||||
|
|
||||||
float AspectRatio() const { return m_AspectRatio; }
|
float AspectRatio() const { return m_AspectRatio; }
|
||||||
void SetAspectRatio(float val);
|
void SetAspectRatio(float val);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ public:
|
|||||||
|
|
||||||
void Draw(GLuint texture);
|
void Draw(GLuint texture);
|
||||||
|
|
||||||
|
void OnWindowResize();
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
//Return the blurred result of the texture that was sent into draw
|
//Return the blurred result of the texture that was sent into draw
|
||||||
GLuint GaussianTexture() const { return m_GaussianTexture_vert; }
|
GLuint GaussianTexture() const { return m_GaussianTexture_vert; }
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "FrameBuffer.h"
|
#include "FrameBuffer.h"
|
||||||
#include "ShaderProgram.h"
|
#include "ShaderProgram.h"
|
||||||
#include "Util/UnorderedMapVec2.h"
|
#include "Util/UnorderedMapVec2.h"
|
||||||
|
#include "Util/CommonFunctions.h"
|
||||||
#include "Texture.h"
|
#include "Texture.h"
|
||||||
|
|
||||||
class DrawFinalPass
|
class DrawFinalPass
|
||||||
@@ -17,8 +18,9 @@ public:
|
|||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene, GLuint SSAOTexture);
|
||||||
void ClearBuffer();
|
void ClearBuffer();
|
||||||
|
void OnWindowResize();
|
||||||
|
|
||||||
//Return the texture that is used in later stages to apply the bloom effect
|
//Return the texture that is used in later stages to apply the bloom effect
|
||||||
GLuint BloomTexture() const { return m_BloomTexture; }
|
GLuint BloomTexture() const { return m_BloomTexture; }
|
||||||
@@ -30,12 +32,12 @@ public:
|
|||||||
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
||||||
FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; }
|
FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; }
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
||||||
|
|
||||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
|
||||||
|
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture);
|
||||||
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
@@ -50,6 +52,7 @@ private:
|
|||||||
Texture* m_BlackTexture;
|
Texture* m_BlackTexture;
|
||||||
Texture* m_NeutralNormalTexture;
|
Texture* m_NeutralNormalTexture;
|
||||||
Texture* m_GreyTexture;
|
Texture* m_GreyTexture;
|
||||||
|
Texture* m_ErrorTexture;
|
||||||
|
|
||||||
FrameBuffer m_FinalPassFrameBuffer;
|
FrameBuffer m_FinalPassFrameBuffer;
|
||||||
FrameBuffer m_FinalPassFrameBufferLowRes;
|
FrameBuffer m_FinalPassFrameBufferLowRes;
|
||||||
@@ -69,6 +72,7 @@ private:
|
|||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
ShaderProgram* m_ExplosionEffectSplatMapProgram;
|
ShaderProgram* m_ExplosionEffectSplatMapProgram;
|
||||||
|
ShaderProgram* m_SpriteProgram;
|
||||||
ShaderProgram* m_ForwardPlusSplatMapProgram;
|
ShaderProgram* m_ForwardPlusSplatMapProgram;
|
||||||
ShaderProgram* m_ShieldToStencilProgram;
|
ShaderProgram* m_ShieldToStencilProgram;
|
||||||
ShaderProgram* m_FillDepthBufferProgram;
|
ShaderProgram* m_FillDepthBufferProgram;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public:
|
|||||||
void SetSSBOSizes();
|
void SetSSBOSizes();
|
||||||
void CullLights(RenderScene& scene);
|
void CullLights(RenderScene& scene);
|
||||||
void FillLightList(RenderScene& scene);
|
void FillLightList(RenderScene& scene);
|
||||||
|
void OnWindowResize();
|
||||||
|
|
||||||
GLuint FrustumSSBO() const { return m_FrustumSSBO; }
|
GLuint FrustumSSBO() const { return m_FrustumSSBO; }
|
||||||
GLuint LightSSBO() const { return m_LightSSBO; }
|
GLuint LightSSBO() const { return m_LightSSBO; }
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#define Model_h__
|
#define Model_h__
|
||||||
|
|
||||||
#include "Rendering/RawModelCustom.h"
|
#include "Rendering/RawModelCustom.h"
|
||||||
|
#include "Util/CommonFunctions.h"
|
||||||
//#include "Rendering/RawModelAssimp.h"
|
//#include "Rendering/RawModelAssimp.h"
|
||||||
#include "../OpenGL.h"
|
#include "../OpenGL.h"
|
||||||
#include "Core/AABB.h"
|
#include "Core/AABB.h"
|
||||||
|
|||||||
@@ -108,6 +108,7 @@ struct ModelJob : RenderJob
|
|||||||
EndIndex = matGroup->EndIndex;
|
EndIndex = matGroup->EndIndex;
|
||||||
Matrix = matrix;
|
Matrix = matrix;
|
||||||
Color = modelComponent["Color"];
|
Color = modelComponent["Color"];
|
||||||
|
GlowIntensity = ((double)modelComponent["GlowIntensity"]);
|
||||||
Entity = modelComponent.EntityID;
|
Entity = modelComponent.EntityID;
|
||||||
glm::vec3 abspos = Transform::AbsolutePosition(world, modelComponent.EntityID);
|
glm::vec3 abspos = Transform::AbsolutePosition(world, modelComponent.EntityID);
|
||||||
glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
|
glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
|
||||||
@@ -120,6 +121,32 @@ struct ModelJob : RenderJob
|
|||||||
|
|
||||||
if (model->IsSkinned()) {
|
if (model->IsSkinned()) {
|
||||||
Skeleton = Model->m_RawModel->m_Skeleton;
|
Skeleton = Model->m_RawModel->m_Skeleton;
|
||||||
|
|
||||||
|
if (Skeleton != nullptr) {
|
||||||
|
if (world->HasComponent(Entity, "Animation")) {
|
||||||
|
auto animationComponent = world->GetComponent(Entity, "Animation");
|
||||||
|
|
||||||
|
for (int i = 1; i <= 3; i++) {
|
||||||
|
::Skeleton::AnimationData animationData;
|
||||||
|
animationData.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationComponent["AnimationName" + std::to_string(i)]);
|
||||||
|
if (animationData.animation == nullptr) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
animationData.time = (double)animationComponent["Time" + std::to_string(i)];
|
||||||
|
animationData.weight = (double)animationComponent["Weight" + std::to_string(i)];
|
||||||
|
|
||||||
|
Animations.push_back(animationData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world->HasComponent(Entity, "AnimationOffset")) {
|
||||||
|
auto animationOffsetComponent = world->GetComponent(Entity, "AnimationOffset");
|
||||||
|
AnimationOffset.animation = model->m_RawModel->m_Skeleton->GetAnimation(animationOffsetComponent["AnimationName"]);
|
||||||
|
AnimationOffset.time = (double)animationOffsetComponent["Time"];
|
||||||
|
} else {
|
||||||
|
AnimationOffset.animation = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -140,11 +167,11 @@ struct ModelJob : RenderJob
|
|||||||
glm::vec4 Color;
|
glm::vec4 Color;
|
||||||
const ::Model* Model = nullptr;
|
const ::Model* Model = nullptr;
|
||||||
::Skeleton* Skeleton = nullptr;
|
::Skeleton* Skeleton = nullptr;
|
||||||
// const ::Skeleton::Animation* Animation = nullptr;
|
std::vector<::Skeleton::AnimationData> Animations;
|
||||||
|
::Skeleton::AnimationOffset AnimationOffset;
|
||||||
|
|
||||||
|
|
||||||
|
float GlowIntensity = 8.0;
|
||||||
glm::vec4 DiffuseColor;
|
glm::vec4 DiffuseColor;
|
||||||
glm::vec4 SpecularColor;
|
glm::vec4 SpecularColor;
|
||||||
glm::vec4 IncandescenceColor;
|
glm::vec4 IncandescenceColor;
|
||||||
|
|||||||
@@ -6,9 +6,10 @@
|
|||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
|
||||||
#include "../Common.h"
|
#include "../Common.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
#include "Image.h"
|
#include "Image.h"
|
||||||
|
|
||||||
class PNG : public Image
|
class PNG : public Image, public Resource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PNG(std::string path);
|
PNG(std::string path);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ public:
|
|||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene);
|
||||||
void ClearPicking();
|
void ClearPicking();
|
||||||
|
|
||||||
|
void OnWindowResize();
|
||||||
|
|
||||||
//Getters
|
//Getters
|
||||||
const ShaderProgram& PickingProgram() const { return *m_PickingProgram; }
|
const ShaderProgram& PickingProgram() const { return *m_PickingProgram; }
|
||||||
//const std::unordered_map<glm::ivec2, EntityID>& PickingColorsToEntity() const { return m_PickingColorsToEntity; }
|
//const std::unordered_map<glm::ivec2, EntityID>& PickingColorsToEntity() const { return m_PickingColorsToEntity; }
|
||||||
@@ -40,7 +42,7 @@ private:
|
|||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
ShaderProgram* m_PickingProgram;
|
ShaderProgram* m_PickingProgram;
|
||||||
ShaderProgram* m_PickingSkinnedProgram;
|
ShaderProgram* m_PickingSkinnedProgram;
|
||||||
Camera* m_Camera;
|
Camera* m_Camera;
|
||||||
|
|
||||||
struct PickingInfo
|
struct PickingInfo
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
struct TextureProperties {
|
struct TextureProperties {
|
||||||
std::string TexturePath;
|
std::string TexturePath;
|
||||||
glm::vec2 UVRepeat;
|
glm::vec2 UVRepeat;
|
||||||
std::shared_ptr<::Texture> Texture;
|
Texture* Texture;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MaterialBasic
|
struct MaterialBasic
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
#include "PointLightJob.h"
|
#include "PointLightJob.h"
|
||||||
#include "DirectionalLightJob.h"
|
#include "DirectionalLightJob.h"
|
||||||
#include "ExplosionEffectJob.h"
|
#include "ExplosionEffectJob.h"
|
||||||
|
#include "SpriteJob.h"
|
||||||
|
|
||||||
struct RenderScene
|
struct RenderScene
|
||||||
{
|
{
|
||||||
@@ -25,6 +26,7 @@ struct RenderScene
|
|||||||
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
|
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> TransparentShieldedObjects;
|
std::list<std::shared_ptr<RenderJob>> TransparentShieldedObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> ShieldObjects;
|
std::list<std::shared_ptr<RenderJob>> ShieldObjects;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> SpriteJob;
|
||||||
std::list<std::shared_ptr<RenderJob>> PointLight;
|
std::list<std::shared_ptr<RenderJob>> PointLight;
|
||||||
std::list<std::shared_ptr<RenderJob>> Text;
|
std::list<std::shared_ptr<RenderJob>> Text;
|
||||||
std::list<std::shared_ptr<RenderJob>> DirectionalLight;
|
std::list<std::shared_ptr<RenderJob>> DirectionalLight;
|
||||||
@@ -41,7 +43,7 @@ struct RenderScene
|
|||||||
Jobs.OpaqueShieldedObjects.clear();
|
Jobs.OpaqueShieldedObjects.clear();
|
||||||
Jobs.TransparentShieldedObjects.clear();
|
Jobs.TransparentShieldedObjects.clear();
|
||||||
Jobs.ShieldObjects.clear();
|
Jobs.ShieldObjects.clear();
|
||||||
Jobs.Text.clear();
|
Jobs.SpriteJob.clear();
|
||||||
Jobs.DirectionalLight.clear();
|
Jobs.DirectionalLight.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "../Core/EPlayerSpawned.h"
|
#include "../Core/EPlayerSpawned.h"
|
||||||
#include "../Core/Octree.h"
|
#include "../Core/Octree.h"
|
||||||
#include "../Collision/EntityAABB.h"
|
#include "../Collision/EntityAABB.h"
|
||||||
|
#include "../Core/ConfigFile.h"
|
||||||
|
|
||||||
class RenderSystem : public ImpureSystem
|
class RenderSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
@@ -47,6 +48,10 @@ private:
|
|||||||
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
||||||
|
void fillSprites(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
|
|
||||||
|
bool isEntityVisible(EntityWrapper& entity);
|
||||||
|
|
||||||
bool isChildOfACamera(EntityWrapper entity);
|
bool isChildOfACamera(EntityWrapper entity);
|
||||||
bool isChildOfCurrentCamera(EntityWrapper entity);
|
bool isChildOfCurrentCamera(EntityWrapper entity);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,15 +16,20 @@
|
|||||||
#include "DrawScreenQuadPass.h"
|
#include "DrawScreenQuadPass.h"
|
||||||
#include "DrawBloomPass.h"
|
#include "DrawBloomPass.h"
|
||||||
#include "DrawColorCorrectionPass.h"
|
#include "DrawColorCorrectionPass.h"
|
||||||
|
#include "SSAOPass.h"
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "ImGuiRenderPass.h"
|
#include "ImGuiRenderPass.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "../Core/Transform.h"
|
#include "../Core/Transform.h"
|
||||||
#include "imgui/imgui.h"
|
#include "imgui/imgui.h"
|
||||||
#include "TextPass.h"
|
#include "TextPass.h"
|
||||||
|
#include "Util/CommonFunctions.h"
|
||||||
|
#include "Core/PerformanceTimer.h"
|
||||||
|
|
||||||
class Renderer : public IRenderer
|
class Renderer : public IRenderer
|
||||||
{
|
{
|
||||||
|
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Renderer(EventBroker* eventBroker)
|
Renderer(EventBroker* eventBroker)
|
||||||
: m_EventBroker(eventBroker)
|
: m_EventBroker(eventBroker)
|
||||||
@@ -36,8 +41,12 @@ public:
|
|||||||
|
|
||||||
virtual PickData Pick(glm::vec2 screenCoord) override;
|
virtual PickData Pick(glm::vec2 screenCoord) override;
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
|
|
||||||
|
static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer;
|
||||||
|
|
||||||
EventBroker* m_EventBroker;
|
EventBroker* m_EventBroker;
|
||||||
TextPass* m_TextPass;
|
TextPass* m_TextPass;
|
||||||
|
|
||||||
@@ -49,6 +58,13 @@ private:
|
|||||||
Model* m_UnitSphere;
|
Model* m_UnitSphere;
|
||||||
|
|
||||||
int m_DebugTextureToDraw = 0;
|
int m_DebugTextureToDraw = 0;
|
||||||
|
bool m_ResizeWindow = false;
|
||||||
|
float m_SSAO_Radius = 1.0f;
|
||||||
|
float m_SSAO_Bias = 0.05f;
|
||||||
|
float m_SSAO_Contrast = 1.5f;
|
||||||
|
float m_SSAO_IntensityScale = 1.0f;
|
||||||
|
int m_SSAO_NumOfSamples = 24;
|
||||||
|
int m_SSAO_NumOfTurns = 7;
|
||||||
|
|
||||||
PickingPass* m_PickingPass;
|
PickingPass* m_PickingPass;
|
||||||
LightCullingPass* m_LightCullingPass;
|
LightCullingPass* m_LightCullingPass;
|
||||||
@@ -57,6 +73,7 @@ private:
|
|||||||
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
||||||
DrawBloomPass* m_DrawBloomPass;
|
DrawBloomPass* m_DrawBloomPass;
|
||||||
DrawColorCorrectionPass* m_DrawColorCorrectionPass;
|
DrawColorCorrectionPass* m_DrawColorCorrectionPass;
|
||||||
|
SSAOPass* m_SSAOPass;
|
||||||
|
|
||||||
//----------------------Functions----------------------//
|
//----------------------Functions----------------------//
|
||||||
void InitializeWindow();
|
void InitializeWindow();
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
#ifndef SSAOPass_h__
|
||||||
|
#define SSAOPass_h__
|
||||||
|
|
||||||
|
#include "IRenderer.h"
|
||||||
|
#include "SSAOPassState.h"
|
||||||
|
//#include "LightCullingPass.h" Finalpass om den skall skickas in
|
||||||
|
#include "FrameBuffer.h"
|
||||||
|
#include "ShaderProgram.h"
|
||||||
|
#include "DrawBloomPass.h"
|
||||||
|
//#include "Util/UnorderedMapVec2.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class SSAOPass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SSAOPass(IRenderer* rendere);
|
||||||
|
~SSAOPass() {
|
||||||
|
delete m_DrawBloomPass;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Draw(GLuint depthBuffer, Camera* camera);
|
||||||
|
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns);
|
||||||
|
void ClearBuffer();
|
||||||
|
void OnWindowResize();
|
||||||
|
|
||||||
|
//Return the SSAO of the texture sent to Draw
|
||||||
|
GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); }
|
||||||
|
|
||||||
|
private:
|
||||||
|
void InitializeTexture();
|
||||||
|
void InitializeFrameBuffer();
|
||||||
|
void InitializeShaderProgram();
|
||||||
|
void InitializeBuffer();
|
||||||
|
|
||||||
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
|
//void blurHorizontal(GLuint depthBuffer);
|
||||||
|
//void blurVertical(GLuint depthBuffer);
|
||||||
|
|
||||||
|
Model* m_ScreenQuad;
|
||||||
|
|
||||||
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
|
float m_Radius;
|
||||||
|
float m_Bias;
|
||||||
|
float m_Contrast;
|
||||||
|
float m_IntensityScale;
|
||||||
|
int m_NumOfSamples;
|
||||||
|
int m_NumOfTurns;
|
||||||
|
|
||||||
|
GLuint m_SSAOTexture;
|
||||||
|
FrameBuffer m_SSAOFramBuffer;
|
||||||
|
|
||||||
|
GLuint m_SSAOViewSpaceZTexture;
|
||||||
|
FrameBuffer m_SSAOViewSpaceZFramBuffer;
|
||||||
|
|
||||||
|
ShaderProgram* m_SSAOProgram;
|
||||||
|
ShaderProgram* m_SSAOViewSpaceZProgram;
|
||||||
|
|
||||||
|
DrawBloomPass* m_DrawBloomPass;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef SSAOPassState_h__
|
||||||
|
#define SSAOPassState_h__
|
||||||
|
|
||||||
|
#include "Rendering/RenderState.h"
|
||||||
|
|
||||||
|
class SSAOPassState : public RenderState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SSAOPassState();
|
||||||
|
~SSAOPassState();
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -100,50 +100,29 @@ public:
|
|||||||
|
|
||||||
int GetBoneID(std::string name);
|
int GetBoneID(std::string name);
|
||||||
|
|
||||||
void CalculateFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion = false);
|
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, AnimationOffset animationOffset, bool noRootMotion = false);
|
||||||
void CalculateFrameBones(std::vector<AnimationData> animations, bool noRootMotion = false);
|
std::vector<glm::mat4> GetFrameBones(std::vector<AnimationData> animations, bool noRootMotion = false);
|
||||||
|
|
||||||
const Animation* GetAnimation(std::string name);
|
const Animation* GetAnimation(std::string name);
|
||||||
|
|
||||||
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, const Bone* bone, glm::mat4 parentMatrix);
|
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, std::map<int, glm::mat4>& frameBones, const Bone* bone, glm::mat4 parentMatrix);
|
||||||
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, const Bone* bone, glm::mat4 parentMatrix);
|
void AccumulateBoneTransforms(bool noRootMotion, std::vector<AnimationData> animations, AnimationOffset animationOffset, std::map<int, glm::mat4>& frameBones, const Bone* bone, glm::mat4 parentMatrix);
|
||||||
|
|
||||||
void PrintSkeleton();
|
void PrintSkeleton();
|
||||||
void PrintSkeleton(const Bone* parent, int depthCount);
|
void PrintSkeleton(const Bone* parent, int depthCount);
|
||||||
std::map<std::string, Animation> Animations;
|
std::map<std::string, Animation> Animations;
|
||||||
|
|
||||||
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
|
glm::mat4 GetBoneTransform(const Bone* bone, const Animation* animation, float time, glm::mat4 childMatrix);
|
||||||
|
glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector<AnimationData> animations, AnimationOffset animationOffset, glm::mat4 childMatrix);
|
||||||
|
glm::mat4 GetBoneTransform(bool noRootMotion, const Bone* bone, std::vector<AnimationData> animations, glm::mat4 childMatrix);
|
||||||
int GetKeyframe(const Animation& animation, double time);
|
int GetKeyframe(const Animation& animation, double time);
|
||||||
|
|
||||||
|
|
||||||
std::vector<glm::mat4> GetBones()
|
|
||||||
{
|
|
||||||
std::vector<glm::mat4> finalMatrices;
|
|
||||||
for (auto &kv : m_BoneLocalTransforms) {
|
|
||||||
finalMatrices.push_back(kv.second);
|
|
||||||
}
|
|
||||||
return finalMatrices;;
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 GetBoneTransformSuper(int boneID)
|
|
||||||
{
|
|
||||||
if(m_BoneTransforms.find(boneID) != m_BoneTransforms.end()) {
|
|
||||||
return m_BoneTransforms.at(boneID);
|
|
||||||
} else {
|
|
||||||
return glm::mat4(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
|
glm::mat4 GetOffsetTransform(const Bone* bone, AnimationOffset animationOffset);
|
||||||
|
|
||||||
std::map<std::string, Bone*> m_BonesByName;
|
std::map<std::string, Bone*> m_BonesByName;
|
||||||
float aim = 0.f;
|
|
||||||
|
|
||||||
|
|
||||||
std::map<int, glm::mat4> m_BoneLocalTransforms;
|
|
||||||
std::map<int, glm::mat4> m_BoneTransforms;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
#ifndef SpriteJob_h__
|
||||||
|
#define SpriteJob_h__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "../Core/ComponentWrapper.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include "RenderJob.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
#include "../Core/World.h"
|
||||||
|
#include "../Core/Transform.h"
|
||||||
|
#include "Skeleton.h"
|
||||||
|
|
||||||
|
struct SpriteJob : RenderJob
|
||||||
|
{
|
||||||
|
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted)
|
||||||
|
: RenderJob()
|
||||||
|
{
|
||||||
|
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
|
||||||
|
::RawModel::MaterialProperties matProp = Model->MaterialGroups().front();
|
||||||
|
TextureID = 0;
|
||||||
|
|
||||||
|
DiffuseTexture = CommonFunctions::LoadTexture(cSprite["DiffuseTexture"], true);
|
||||||
|
|
||||||
|
IncandescenceTexture = CommonFunctions::LoadTexture(cSprite["GlowMap"], true);
|
||||||
|
|
||||||
|
StartIndex = matProp.material->StartIndex;
|
||||||
|
EndIndex = matProp.material->EndIndex;
|
||||||
|
Matrix = matrix;
|
||||||
|
Color = cSprite["Color"];
|
||||||
|
Entity = cSprite.EntityID;
|
||||||
|
Position = Transform::AbsolutePosition(world, cSprite.EntityID);
|
||||||
|
Depth = 0;
|
||||||
|
if (depthSorted) {
|
||||||
|
glm::vec3 viewpos = glm::vec3(camera->ViewMatrix() * glm::vec4(Position, 1));
|
||||||
|
Depth = viewpos.z;
|
||||||
|
}
|
||||||
|
World = world;
|
||||||
|
Pickable = world->HasComponent(cSprite.EntityID, "Button");
|
||||||
|
|
||||||
|
FillColor = fillColor;
|
||||||
|
FillPercentage = fillPercentage;
|
||||||
|
};
|
||||||
|
|
||||||
|
unsigned int TextureID;
|
||||||
|
|
||||||
|
EntityID Entity;
|
||||||
|
glm::mat4 Matrix;
|
||||||
|
const Texture* DiffuseTexture;
|
||||||
|
const Texture* NormalTexture;
|
||||||
|
const Texture* SpecularTexture;
|
||||||
|
const Texture* IncandescenceTexture;
|
||||||
|
float Shininess = 0.f;
|
||||||
|
glm::vec4 Color;
|
||||||
|
glm::vec3 Position;
|
||||||
|
const ::Model* Model = nullptr;
|
||||||
|
unsigned int StartIndex = 0;
|
||||||
|
unsigned int EndIndex = 0;
|
||||||
|
World* World;
|
||||||
|
bool Pickable;
|
||||||
|
|
||||||
|
glm::vec4 FillColor = glm::vec4(0);
|
||||||
|
float FillPercentage = 0.0;
|
||||||
|
|
||||||
|
void CalculateHash() override
|
||||||
|
{
|
||||||
|
Hash = TextureID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -4,14 +4,11 @@
|
|||||||
#include "../../Common.h"
|
#include "../../Common.h"
|
||||||
#include "../../OpenGL.h"
|
#include "../../OpenGL.h"
|
||||||
#include "../../GLM.h"
|
#include "../../GLM.h"
|
||||||
|
#include "../Texture.h"
|
||||||
|
|
||||||
class CommonFuntions
|
namespace CommonFunctions
|
||||||
{
|
{
|
||||||
public:
|
Texture* LoadTexture(std::string path, bool threaded);
|
||||||
CommonFuntions() = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+3
-2
@@ -8,7 +8,6 @@
|
|||||||
#include "Core/EventBroker.h"
|
#include "Core/EventBroker.h"
|
||||||
#include "Rendering/Renderer.h"
|
#include "Rendering/Renderer.h"
|
||||||
#include "Core/InputManager.h"
|
#include "Core/InputManager.h"
|
||||||
#include "GUI/Frame.h"
|
|
||||||
#include "Core/World.h"
|
#include "Core/World.h"
|
||||||
#include "Input/InputProxy.h"
|
#include "Input/InputProxy.h"
|
||||||
#include "Input/KeyboardInputHandler.h"
|
#include "Input/KeyboardInputHandler.h"
|
||||||
@@ -35,6 +34,9 @@
|
|||||||
#include "Sound/SoundManager.h"
|
#include "Sound/SoundManager.h"
|
||||||
#include "Systems/SoundSystem.h"
|
#include "Systems/SoundSystem.h"
|
||||||
|
|
||||||
|
//Performance
|
||||||
|
#include "Core/PerformanceTimer.h"
|
||||||
|
|
||||||
class Game
|
class Game
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -53,7 +55,6 @@ private:
|
|||||||
IRenderer* m_Renderer;
|
IRenderer* m_Renderer;
|
||||||
InputManager* m_InputManager;
|
InputManager* m_InputManager;
|
||||||
InputProxy* m_InputProxy;
|
InputProxy* m_InputProxy;
|
||||||
GUI::Frame* m_FrameStack;
|
|
||||||
World* m_World;
|
World* m_World;
|
||||||
Octree<EntityAABB>* m_OctreeCollision;
|
Octree<EntityAABB>* m_OctreeCollision;
|
||||||
Octree<EntityAABB>* m_OctreeTrigger;
|
Octree<EntityAABB>* m_OctreeTrigger;
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef MiniDump_h__
|
||||||
|
#define MiniDump_h__
|
||||||
|
|
||||||
|
#include <Windows.h>
|
||||||
|
|
||||||
|
void WINAPI Create_Dump(PEXCEPTION_POINTERS pException, BOOL File_Flag, BOOL Show_Flag);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#ifndef AmmoPickupSystem_h__
|
||||||
|
#define AmmoPickupSystem_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Core/Transform.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/EntityFileParser.h"
|
||||||
|
#include "Core/EPickupSpawned.h"
|
||||||
|
#include "Core/EAmmoPickup.h"
|
||||||
|
#include "Engine/Collision/ETrigger.h"
|
||||||
|
#include "Common.h"
|
||||||
|
|
||||||
|
class AmmoPickupSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AmmoPickupSystem(SystemParams params);
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EventRelay<AmmoPickupSystem, Events::TriggerTouch> m_ETriggerTouch;
|
||||||
|
bool OnTriggerTouch(Events::TriggerTouch& e);
|
||||||
|
|
||||||
|
struct NewAmmoPickup {
|
||||||
|
glm::vec3 Pos;
|
||||||
|
double AmmoGain;
|
||||||
|
double RespawnTimer;
|
||||||
|
double DecreaseThisRespawnTimer;
|
||||||
|
};
|
||||||
|
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef AmmunitionHUDSystem_h__
|
||||||
|
#define AmmunitionHUDSystem_h__
|
||||||
|
|
||||||
|
#include "../../Engine/Core/System.h"
|
||||||
|
#include "../../Engine/GLM.h"
|
||||||
|
|
||||||
|
class AmmunitionHUDSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AmmunitionHUDSystem(SystemParams params)
|
||||||
|
: System(params)
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#ifndef CapturePointHUDSystem_h__
|
||||||
|
#define CapturePointHUDSystem_h__
|
||||||
|
|
||||||
|
#include <GLFW/glfw3.h>
|
||||||
|
#include <glm/common.hpp>
|
||||||
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Engine/Collision/ETrigger.h"
|
||||||
|
|
||||||
|
class CapturePointHUDSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CapturePointHUDSystem(SystemParams params);
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -44,7 +44,6 @@ private:
|
|||||||
|
|
||||||
//std::vector<ComponentWrapper>
|
//std::vector<ComponentWrapper>
|
||||||
|
|
||||||
const double m_CaptureTimeToTakeOver = 15.0;
|
|
||||||
bool m_ResetTimers = false;
|
bool m_ResetTimers = false;
|
||||||
|
|
||||||
//vectors which will keep track of enter/leave changes
|
//vectors which will keep track of enter/leave changes
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
#ifndef DamageIndicatorSystem_h__
|
||||||
|
#define DamageIndicatorSystem_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Core/Transform.h"
|
||||||
|
#include "Core/ResourceManager.h"
|
||||||
|
#include "Core/EntityFileParser.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Common.h"
|
||||||
|
#include <tuple>
|
||||||
|
|
||||||
|
#include "Rendering/ESetCamera.h"
|
||||||
|
#include <glm/gtc/quaternion.hpp>
|
||||||
|
#include <glm/gtx/vector_angle.hpp>
|
||||||
|
|
||||||
|
#include "Rendering/Util/CommonFunctions.h"
|
||||||
|
|
||||||
|
class DamageIndicatorSystem : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DamageIndicatorSystem(SystemParams params);
|
||||||
|
|
||||||
|
private:
|
||||||
|
EventRelay<DamageIndicatorSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
|
bool OnPlayerDamage(Events::PlayerDamage& e);
|
||||||
|
|
||||||
|
EventRelay<DamageIndicatorSystem, Events::SetCamera> m_ESetCamera;
|
||||||
|
bool OnSetCamera(const Events::SetCamera& e);
|
||||||
|
|
||||||
|
EntityID m_CurrentCamera = -1;
|
||||||
|
|
||||||
|
};
|
||||||
|
#endif
|
||||||
@@ -3,13 +3,11 @@
|
|||||||
|
|
||||||
#include "../../Engine/Core/System.h"
|
#include "../../Engine/Core/System.h"
|
||||||
#include "../../Engine/GLM.h"
|
#include "../../Engine/GLM.h"
|
||||||
#include "../../Engine/Rendering/ESetCamera.h"
|
|
||||||
#include <imgui/imgui.h>
|
|
||||||
|
|
||||||
class PlayerHUDSystem : public ImpureSystem
|
class HealthHUDSystem : public ImpureSystem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayerHUDSystem(SystemParams params)
|
HealthHUDSystem(SystemParams params)
|
||||||
: System(params)
|
: System(params)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@@ -9,6 +9,8 @@
|
|||||||
#include "Core/EPlayerDamage.h"
|
#include "Core/EPlayerDamage.h"
|
||||||
#include "Core/EPlayerHealthPickup.h"
|
#include "Core/EPlayerHealthPickup.h"
|
||||||
#include "Core/EPlayerDeath.h"
|
#include "Core/EPlayerDeath.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -23,15 +25,18 @@ public:
|
|||||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//methods which will take care of specific events
|
bool m_NetworkEnabled;
|
||||||
|
|
||||||
|
// methods which will take care of specific events
|
||||||
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
|
EventRelay<HealthSystem, Events::PlayerDamage> m_EPlayerDamage;
|
||||||
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
bool HealthSystem::OnPlayerDamaged(Events::PlayerDamage& e);
|
||||||
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
EventRelay<HealthSystem, Events::PlayerHealthPickup> m_EPlayerHealthPickup;
|
||||||
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e);
|
bool HealthSystem::OnPlayerHealthPickup(Events::PlayerHealthPickup& e);
|
||||||
|
EventRelay<HealthSystem, Events::InputCommand> m_InputCommand;
|
||||||
|
bool HealthSystem::OnInputCommand(Events::InputCommand& e);
|
||||||
|
|
||||||
//vector which will keep track of health changes
|
//vector which will keep track of health changes
|
||||||
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
std::vector<std::tuple<EntityID, double>> m_DeltaHealthVector;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
#ifndef KillFeedSystem_h__
|
||||||
|
#define KillFeedSystem_h__
|
||||||
|
|
||||||
|
#include "../../Engine/Core/System.h"
|
||||||
|
#include "../../Engine/GLM.h"
|
||||||
|
#include "Core/EPlayerDeath.h"
|
||||||
|
|
||||||
|
class KillFeedSystem : public ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
KillFeedSystem(SystemParams params)
|
||||||
|
: System(params)
|
||||||
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &KillFeedSystem::OnPlayerDeath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EventRelay<KillFeedSystem, Events::PlayerDeath> m_EPlayerDeath;
|
||||||
|
bool KillFeedSystem::OnPlayerDeath(Events::PlayerDeath& e);
|
||||||
|
|
||||||
|
struct KillFeedInfo
|
||||||
|
{
|
||||||
|
std::string Content;
|
||||||
|
glm::vec4 Color;
|
||||||
|
float TimeToLive = 5.f;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::list<KillFeedInfo> m_DeathQueue;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -13,6 +13,8 @@ public:
|
|||||||
PlayerSpawnSystem(SystemParams params);
|
PlayerSpawnSystem(SystemParams params);
|
||||||
|
|
||||||
virtual void Update(double dt) override;
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
static void SetRespawnTime(float respawnTime) { m_RespawnTime = respawnTime; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct SpawnRequest
|
struct SpawnRequest
|
||||||
@@ -23,10 +25,19 @@ private:
|
|||||||
|
|
||||||
bool m_NetworkEnabled = false;
|
bool m_NetworkEnabled = false;
|
||||||
std::vector<SpawnRequest> m_SpawnRequests;
|
std::vector<SpawnRequest> m_SpawnRequests;
|
||||||
|
|
||||||
|
//Player ID -> EntityWrapper.
|
||||||
std::map<int, EntityWrapper> m_PlayerEntities;
|
std::map<int, EntityWrapper> m_PlayerEntities;
|
||||||
|
//EntityWrapper ID -> Player ID.
|
||||||
|
std::map<EntityID, int> m_PlayerIDs;
|
||||||
|
|
||||||
|
static float m_RespawnTime;
|
||||||
|
float m_Timer;
|
||||||
|
|
||||||
EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand;
|
EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(Events::InputCommand& e);
|
||||||
EventRelay<PlayerSpawnSystem, Events::PlayerSpawned> m_OnPlayerSpawnerd;
|
EventRelay<PlayerSpawnSystem, Events::PlayerSpawned> m_OnPlayerSpawnerd;
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
EventRelay<PlayerSpawnSystem, Events::PlayerDeath> m_OnPlayerDeath;
|
||||||
|
bool OnPlayerDeath(Events::PlayerDeath& e);
|
||||||
};
|
};
|
||||||
@@ -15,11 +15,16 @@ class SpawnerSystem : public System
|
|||||||
public:
|
public:
|
||||||
SpawnerSystem(SystemParams params);
|
SpawnerSystem(SystemParams params);
|
||||||
|
|
||||||
static EntityWrapper Spawn(EntityWrapper spawner, EntityWrapper parent = EntityWrapper::Invalid);
|
// If dontCollideComponent is set, to e.g. "Player", then all the spawner
|
||||||
|
// will try to pick a spawn location so that the spawned entity doesn't
|
||||||
|
// collide with anything that has that component and is collidable.
|
||||||
|
static EntityWrapper Spawn(EntityWrapper spawner, EntityWrapper parent = EntityWrapper::Invalid, const std::string& dontCollideComponent = "");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<SpawnerSystem, Events::SpawnerSpawn> m_OnSpawnerSpawn;
|
EventRelay<SpawnerSystem, Events::SpawnerSpawn> m_OnSpawnerSpawn;
|
||||||
bool OnSpawnerSpawn(Events::SpawnerSpawn& e);
|
bool OnSpawnerSpawn(Events::SpawnerSpawn& e);
|
||||||
|
static void transformEntityToSpawnPoint(EntityWrapper spawnedEntity, EntityWrapper spawnPoint);
|
||||||
|
static bool spawnedEntityIsColliding(EntityWrapper spawnedEntity, EntityWrapper spawnPoint, const std::string& dontCollideComponent);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#include "Sound/EPlaySoundOnEntity.h"
|
||||||
|
#include "Collision/Collision.h"
|
||||||
|
#include "Rendering/AnimationSystem.h"
|
||||||
|
#include "Core/ConfigFile.h"
|
||||||
|
#include "WeaponBehaviour.h"
|
||||||
|
#include "../SpawnerSystem.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Core/EShoot.h"
|
||||||
|
|
||||||
|
|
||||||
|
class AssaultWeaponBehaviour : public WeaponBehaviour
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AssaultWeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity);
|
||||||
|
|
||||||
|
virtual void Fire() override;
|
||||||
|
virtual void CeaseFire() override;
|
||||||
|
virtual void Reload() override;
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
EntityWrapper m_FirstPersonModel;
|
||||||
|
EntityWrapper m_ThirdPersonModel;
|
||||||
|
// State
|
||||||
|
bool m_Firing = false;
|
||||||
|
bool m_Reloading = false;
|
||||||
|
double m_ReloadTimer = 0.0;
|
||||||
|
EntityWrapper m_FirstPersonReloadImpersonator;
|
||||||
|
EntityWrapper m_ThirdPersonReloadImpersonator;
|
||||||
|
double m_TimeSinceLastFire = 0.0;
|
||||||
|
|
||||||
|
EventRelay<WeaponBehaviour, Events::AnimationComplete> m_EAnimationComplete;
|
||||||
|
bool OnAnimationComplete(Events::AnimationComplete& e);
|
||||||
|
|
||||||
|
bool hasAmmo();
|
||||||
|
void fireRound();
|
||||||
|
void spawnTracer();
|
||||||
|
float traceRayDistance(glm::vec3 origin, glm::vec3 direction);
|
||||||
|
void playFireSound();
|
||||||
|
void playEmptySound();
|
||||||
|
void viewPunch();
|
||||||
|
void finishReload();
|
||||||
|
void playShootAnimation();
|
||||||
|
void playIdleAnimation();
|
||||||
|
void playReloadAnimation();
|
||||||
|
bool shoot(double damage);
|
||||||
|
void showHitMarker();
|
||||||
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
#ifndef WeaponBehaviour_h__
|
||||||
|
#define WeaponBehaviour_h__
|
||||||
|
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Rendering/IRenderer.h"
|
||||||
|
#include "Core/Octree.h"
|
||||||
|
#include "Collision/EntityAABB.h"
|
||||||
|
|
||||||
|
class WeaponBehaviour : public System
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WeaponBehaviour(SystemParams systemParams, IRenderer* renderer, Octree<EntityAABB>* collisionOctree, EntityWrapper player)
|
||||||
|
: System(systemParams)
|
||||||
|
, m_Renderer(renderer)
|
||||||
|
, m_CollisionOctree(collisionOctree)
|
||||||
|
, m_Player(player)
|
||||||
|
{ }
|
||||||
|
virtual ~WeaponBehaviour() = default;
|
||||||
|
|
||||||
|
WeaponBehaviour(const WeaponBehaviour&) = delete;
|
||||||
|
WeaponBehaviour& operator=(const WeaponBehaviour &) = delete;
|
||||||
|
|
||||||
|
virtual void Fire() = 0;
|
||||||
|
virtual void CeaseFire() { }
|
||||||
|
virtual void Reload() { }
|
||||||
|
virtual void Update(double dt) { }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
IRenderer* m_Renderer;
|
||||||
|
Octree<EntityAABB>* m_CollisionOctree;
|
||||||
|
EntityWrapper m_Player;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
#ifndef WeaponSystem_h__
|
||||||
|
#define WeaponSystem_h__
|
||||||
|
|
||||||
|
#include "Rendering/IRenderer.h"
|
||||||
|
|
||||||
|
#include "Common.h"
|
||||||
|
#include "Core/System.h"
|
||||||
|
#include "Core/EPlayerDamage.h"
|
||||||
|
#include "Core/EShoot.h"
|
||||||
|
#include "Core/EPlayerSpawned.h"
|
||||||
|
#include "Input/EInputCommand.h"
|
||||||
|
#include "Core/EntityFile.h"
|
||||||
|
#include "Core/EntityFileParser.h"
|
||||||
|
#include "Core/Octree.h"
|
||||||
|
#include "Collision/EntityAABB.h"
|
||||||
|
#include "Systems/SpawnerSystem.h"
|
||||||
|
#include "Sound/EPlaySoundOnEntity.h"
|
||||||
|
#include "AssaultWeaponBehaviour.h"
|
||||||
|
|
||||||
|
class WeaponSystem : public PureSystem, ImpureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WeaponSystem(SystemParams params, IRenderer* renderer, Octree<EntityAABB>* collisionOctree);
|
||||||
|
|
||||||
|
virtual void Update(double dt) override;
|
||||||
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
SystemParams m_SystemParams;
|
||||||
|
IRenderer* m_Renderer;
|
||||||
|
Octree<EntityAABB>* m_CollisionOctree;
|
||||||
|
|
||||||
|
std::unordered_map<EntityWrapper, std::shared_ptr<WeaponBehaviour>> m_ActiveWeapons;
|
||||||
|
|
||||||
|
// Events
|
||||||
|
EventRelay<WeaponSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
EventRelay<WeaponSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
bool OnInputCommand(Events::InputCommand& e);
|
||||||
|
|
||||||
|
void selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,192 +0,0 @@
|
|||||||
#ifndef WeaponSystem_h__
|
|
||||||
#define WeaponSystem_h__
|
|
||||||
|
|
||||||
//#include <GLFW/glfw3.h>
|
|
||||||
//#include <glm/common.hpp>
|
|
||||||
#include "Rendering/IRenderer.h"
|
|
||||||
|
|
||||||
#include "Common.h"
|
|
||||||
#include "Core/System.h"
|
|
||||||
#include "Core/EPlayerDamage.h"
|
|
||||||
#include "Core/EShoot.h"
|
|
||||||
#include "Core/EPlayerSpawned.h"
|
|
||||||
#include "Input/EInputCommand.h"
|
|
||||||
#include "Core/EntityFile.h"
|
|
||||||
#include "Core/EntityFileParser.h"
|
|
||||||
#include "Core/Octree.h"
|
|
||||||
#include "Collision/EntityAABB.h"
|
|
||||||
#include "Systems/SpawnerSystem.h"
|
|
||||||
#include "Sound/EPlaySoundOnEntity.h"
|
|
||||||
|
|
||||||
class WeaponBehaviour;
|
|
||||||
|
|
||||||
class WeaponSystem : public PureSystem, ImpureSystem
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WeaponSystem(SystemParams params, IRenderer* renderer, Octree<EntityAABB>* collisionOctree);
|
|
||||||
|
|
||||||
virtual void Update(double dt) override;
|
|
||||||
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& cPlayer, double dt) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
SystemParams m_SystemParams;
|
|
||||||
IRenderer* m_Renderer;
|
|
||||||
Octree<EntityAABB>* m_CollisionOctree;
|
|
||||||
|
|
||||||
std::unordered_map<EntityWrapper, std::shared_ptr<WeaponBehaviour>> m_ActiveWeapons;
|
|
||||||
|
|
||||||
// Events
|
|
||||||
EventRelay<WeaponSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
|
||||||
EventRelay<WeaponSystem, Events::Shoot> m_EShoot;
|
|
||||||
bool OnShoot(Events::Shoot& e);
|
|
||||||
EventRelay<WeaponSystem, Events::InputCommand> m_EInputCommand;
|
|
||||||
bool OnInputCommand(Events::InputCommand& e);
|
|
||||||
|
|
||||||
void selectWeapon(EntityWrapper player, ComponentInfo::EnumType slot);
|
|
||||||
};
|
|
||||||
|
|
||||||
class WeaponBehaviour : public System
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
WeaponBehaviour(SystemParams systemParams, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity)
|
|
||||||
: System(systemParams)
|
|
||||||
, m_CollisionOctree(collisionOctree)
|
|
||||||
, m_Entity(weaponEntity)
|
|
||||||
{ }
|
|
||||||
virtual ~WeaponBehaviour() = default;
|
|
||||||
|
|
||||||
WeaponBehaviour(const WeaponBehaviour&) = delete;
|
|
||||||
WeaponBehaviour& operator=(const WeaponBehaviour &) = delete;
|
|
||||||
|
|
||||||
virtual void Fire() = 0;
|
|
||||||
virtual void CeaseFire() { }
|
|
||||||
virtual void Reload() { }
|
|
||||||
virtual void Update(double dt) { }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
Octree<EntityAABB>* m_CollisionOctree;
|
|
||||||
EntityWrapper m_Entity;
|
|
||||||
};
|
|
||||||
|
|
||||||
class AssaultWeaponBehaviour : public WeaponBehaviour
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AssaultWeaponBehaviour(SystemParams systemParams, Octree<EntityAABB>* collisionOctree, EntityWrapper weaponEntity)
|
|
||||||
: WeaponBehaviour(systemParams, collisionOctree, weaponEntity)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
virtual void Fire() override
|
|
||||||
{
|
|
||||||
m_TimeSinceLastFire = 0.0;
|
|
||||||
m_Firing = true;
|
|
||||||
fireRound();
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void CeaseFire() override
|
|
||||||
{
|
|
||||||
m_Firing = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Reload() override
|
|
||||||
{
|
|
||||||
ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"];
|
|
||||||
|
|
||||||
int& magAmmo = cAssaultWeapon["MagazineAmmo"];
|
|
||||||
int magSize = cAssaultWeapon["MagazineSize"];
|
|
||||||
int& ammo = cAssaultWeapon["Ammo"];
|
|
||||||
|
|
||||||
// Don't reload if we're already fully loaded
|
|
||||||
if (magAmmo == magSize) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Throw away rounds in magazine to incentivise ammo sharing
|
|
||||||
int toLoad = glm::min(magSize, ammo);
|
|
||||||
magAmmo = toLoad;
|
|
||||||
ammo -= toLoad;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void Update(double dt) override
|
|
||||||
{
|
|
||||||
if (!m_Firing) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_TimeSinceLastFire += dt;
|
|
||||||
|
|
||||||
ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"];
|
|
||||||
if (m_TimeSinceLastFire >= 1.0 / ((double)cAssaultWeapon["RPM"] / 60.0)) {
|
|
||||||
fireRound();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_Firing = false;
|
|
||||||
double m_TimeSinceLastFire = 0.0;
|
|
||||||
EntityFile* m_RayRed = nullptr;
|
|
||||||
EntityFile* m_RayBlue = nullptr;
|
|
||||||
|
|
||||||
void fireRound()
|
|
||||||
{
|
|
||||||
ComponentWrapper& cAssaultWeapon = m_Entity["AssaultWeapon"];
|
|
||||||
|
|
||||||
int& magAmmo = cAssaultWeapon["MagazineAmmo"];
|
|
||||||
int ammo = cAssaultWeapon["Ammo"];
|
|
||||||
|
|
||||||
// Reload if our magazine is empty
|
|
||||||
if (magAmmo <= 0) {
|
|
||||||
Reload();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fire
|
|
||||||
magAmmo -= 1;
|
|
||||||
spawnTracer();
|
|
||||||
playSound();
|
|
||||||
|
|
||||||
m_TimeSinceLastFire = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void spawnTracer()
|
|
||||||
{
|
|
||||||
if (!IsClient) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
EntityWrapper spawner;
|
|
||||||
if (m_Entity == LocalPlayer) {
|
|
||||||
spawner = m_Entity.FirstChildByName("WeaponMuzzle");
|
|
||||||
} else {
|
|
||||||
spawner = m_Entity.FirstChildByName("ThirdPersonWeaponMuzzle");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!spawner.Valid()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Events::SpawnerSpawn e;
|
|
||||||
e.Spawner = spawner;
|
|
||||||
m_EventBroker->Publish(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
float traceRayDistance(glm::vec3 origin, glm::vec3 direction)
|
|
||||||
{
|
|
||||||
// TODO: Cast a ray and size tracer appropriately
|
|
||||||
return 100.f;
|
|
||||||
}
|
|
||||||
|
|
||||||
void playSound()
|
|
||||||
{
|
|
||||||
if (!IsClient) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Events::PlaySoundOnEntity e;
|
|
||||||
e.EmitterID = m_Entity.ID;
|
|
||||||
e.FilePath = "Audio/laser/laser1.wav";
|
|
||||||
m_EventBroker->Publish(e);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -4,6 +4,9 @@ LoadMap=
|
|||||||
; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation.
|
; if true -> Pool allocation is not used when calling Allocate/Free, just use regular dynamic allocation.
|
||||||
; if false -> Use pool allocation.
|
; if false -> Use pool allocation.
|
||||||
DisableMemoryPool=false
|
DisableMemoryPool=false
|
||||||
|
RespawnTime = 8.0
|
||||||
|
EditorEnabled=false
|
||||||
|
OutOfBodyExperience=false
|
||||||
|
|
||||||
[Editor]
|
[Editor]
|
||||||
CameraSpeed=3
|
CameraSpeed=3
|
||||||
@@ -20,7 +23,7 @@ StartNetwork=false
|
|||||||
IsServer=false
|
IsServer=false
|
||||||
Name=Bob
|
Name=Bob
|
||||||
Address=127.0.0.1
|
Address=127.0.0.1
|
||||||
Port=13
|
Port=27666
|
||||||
MaxConnections=8
|
MaxConnections=8
|
||||||
SnapshotInterval=0.05
|
SnapshotInterval=0.05
|
||||||
SendInputIntervalMs=33
|
SendInputIntervalMs=33
|
||||||
|
|||||||
@@ -24,4 +24,7 @@ F1=ToggleEditor
|
|||||||
C=ConnectToServer
|
C=ConnectToServer
|
||||||
N=SwitchToServer
|
N=SwitchToServer
|
||||||
M=SwitchToClient
|
M=SwitchToClient
|
||||||
P=SwitchToPlayer
|
P=SwitchToPlayer
|
||||||
|
K=TakeDamage,1500
|
||||||
|
F2=PerformanceTimingResetAllTimers
|
||||||
|
F3=PerformanceTimingCreateExcelData
|
||||||
@@ -32,9 +32,17 @@
|
|||||||
<xs:include schemaLocation="Components/Lifetime.xsd"/>
|
<xs:include schemaLocation="Components/Lifetime.xsd"/>
|
||||||
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
|
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
|
||||||
<xs:include schemaLocation="Components/HealthPickup.xsd"/>
|
<xs:include schemaLocation="Components/HealthPickup.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/AmmoPickup.xsd"/>
|
||||||
<xs:include schemaLocation="Components/AnimationOffset.xsd"/>
|
<xs:include schemaLocation="Components/AnimationOffset.xsd"/>
|
||||||
<xs:include schemaLocation="Components/DashAbility.xsd"/>
|
<xs:include schemaLocation="Components/DashAbility.xsd"/>
|
||||||
<xs:include schemaLocation="Components/AssaultWeapon.xsd"/>
|
<xs:include schemaLocation="Components/AssaultWeapon.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Shield.xsd"/>
|
<xs:include schemaLocation="Components/Shield.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Sprite.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Shielded.xsd"/>
|
<xs:include schemaLocation="Components/Shielded.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/CapturePointHUD.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/AmmunitionHUD.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Menu.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/KillFeed.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Page.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/Button.xsd"/>
|
||||||
</xs:schema>
|
</xs:schema>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<AmmoPickup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AmmoPickup.xsd">
|
||||||
|
<RespawnTimer>3</RespawnTimer>
|
||||||
|
<AmmoGain>30</AmmoGain>
|
||||||
|
</AmmoPickup>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?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="AmmoPickup">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>An Ammo Pickup</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="RespawnTimer" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The respawn timer for a ammo pickup</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="AmmoGain" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>How much percent ammo gain the player will get</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<AmmunitionHUD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="AmmunitionHUD.xsd">
|
||||||
|
</AmmunitionHUD>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?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:include schemaLocation="../Types/TeamEnum.xsd"/>
|
||||||
|
<xs:element name="AmmunitionHUD">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Hud element for tracking ammunition from parent with AssaultWeapon component. Child with the name "MagazineAmmo" tracks clip ammunition. Child with the name "Ammo" tracks ammo.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -6,4 +6,6 @@
|
|||||||
<MaxAmmo>360</MaxAmmo>
|
<MaxAmmo>360</MaxAmmo>
|
||||||
<BaseDamage>5</BaseDamage>
|
<BaseDamage>5</BaseDamage>
|
||||||
<RPM>120</RPM>
|
<RPM>120</RPM>
|
||||||
|
<ViewPunch>0.01</ViewPunch>
|
||||||
|
<ReloadTime>2</ReloadTime>
|
||||||
</AssaultWeapon>
|
</AssaultWeapon>
|
||||||
@@ -22,6 +22,12 @@
|
|||||||
<xs:element name="RPM" type="t:double" minOccurs="0">
|
<xs:element name="RPM" type="t:double" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Rate of fire in rounds per minute</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Rate of fire in rounds per minute</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="ViewPunch" type="t:float" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>View punch in radians for each bullet fired</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="ReloadTime" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Time it takes to reload the weapon in seconds</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Button xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Button.xsd">
|
||||||
|
</Button>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
<?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="Button">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Makes sprites klickable.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
<CapturePoint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePoint.xsd">
|
<CapturePoint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePoint.xsd">
|
||||||
<CapturePointNumber>0</CapturePointNumber>
|
<CapturePointNumber>0</CapturePointNumber>
|
||||||
<CaptureTimer>0</CaptureTimer>
|
<CaptureTimer>0</CaptureTimer>
|
||||||
|
<CapturePointMaxTimer>15</CapturePointMaxTimer>
|
||||||
<HomePointForTeam><Spectator/></HomePointForTeam>
|
<HomePointForTeam><Spectator/></HomePointForTeam>
|
||||||
</CapturePoint>
|
</CapturePoint>
|
||||||
@@ -20,7 +20,11 @@
|
|||||||
<xs:documentation>CapturePointNumber specify an int number for this</xs:documentation>
|
<xs:documentation>CapturePointNumber specify an int number for this</xs:documentation>
|
||||||
</xs:annotation>
|
</xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="CapturePointMaxTimer" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>The time needed to take over a Capture Point</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
<xs:element name="HomePointForTeam" type="TeamEnum" minOccurs="0">
|
<xs:element name="HomePointForTeam" type="TeamEnum" minOccurs="0">
|
||||||
<xs:annotation>
|
<xs:annotation>
|
||||||
<xs:documentation>Specify if this is a HomePoint for either team</xs:documentation>
|
<xs:documentation>Specify if this is a HomePoint for either team</xs:documentation>
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<CapturePointHUD xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointHUD.xsd">
|
||||||
|
<CapturePointNumber>0</CapturePointNumber>
|
||||||
|
<Owner><Spectator/></Owner>
|
||||||
|
</CapturePointHUD>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<?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:include schemaLocation="../Types/TeamEnum.xsd"/>
|
||||||
|
<xs:element name="CapturePointHUD">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Hud element for tracking capture points.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="CapturePointNumber" type="t:int" minOccurs="0">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Corresponds to the number on the capture point it should track.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Owner" type="TeamEnum" minOccurs="0">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Specify the team that own this capturePoint.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<KillFeed xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="KillFeed.xsd">
|
||||||
|
</KillFeed>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?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="KillFeed">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>HUD element for tracking the 3 last kills, printed on the children with the names "KillFeed1", "KillFeed2", "KillFeed3"</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Menu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Menu.xsd">
|
||||||
|
</Menu>
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<?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="Menu">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Attach this to the center point of a menu that uses several pages.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -8,4 +8,5 @@
|
|||||||
<NormalMap>true</NormalMap>
|
<NormalMap>true</NormalMap>
|
||||||
<SpecularMap>true</SpecularMap>
|
<SpecularMap>true</SpecularMap>
|
||||||
<GlowMap>true</GlowMap>
|
<GlowMap>true</GlowMap>
|
||||||
|
<GlowIntensity>3.0</GlowIntensity>
|
||||||
</Model>
|
</Model>
|
||||||
@@ -33,6 +33,9 @@
|
|||||||
<xs:element name="GlowMap" type="t:bool" minOccurs="0">
|
<xs:element name="GlowMap" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Whether the model should use the Glowmap or not</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Whether the model should use the Glowmap or not</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
<xs:element name="GlowIntensity" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Intensity of the glow map</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
</xs:all>
|
</xs:all>
|
||||||
</xs:complexType>
|
</xs:complexType>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<Page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Page.xsd">
|
||||||
|
<ID>0</ID>
|
||||||
|
</Page>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?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="Page">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>Use this on a child to a Menu entity and make sure that ID is not the same as other pages.</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="ID" type="t:int" minOccurs="0"/>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
<Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd">
|
<Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd">
|
||||||
<Velocity X="0" Y="0" Z="0"/>
|
<Velocity X="0" Y="0" Z="0"/>
|
||||||
<Gravity>true</Gravity>
|
<Gravity>true</Gravity>
|
||||||
|
<PrevOrigin X="-9876.5" Y="-9876.5" Z="-9876.5"/>
|
||||||
<IsOnGround>false</IsOnGround>
|
<IsOnGround>false</IsOnGround>
|
||||||
<VerticalStepHeight>0.33</VerticalStepHeight>
|
<VerticalStepHeight>0.33</VerticalStepHeight>
|
||||||
</Physics>
|
</Physics>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<xs:annotation><xs:documentation>m/s^2</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>m/s^2</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
<xs:element name="Gravity" type="t:bool" minOccurs="0"/>
|
<xs:element name="Gravity" type="t:bool" minOccurs="0"/>
|
||||||
|
<xs:element name="PrevOrigin" type="t:Vector" minOccurs="0"/>
|
||||||
<xs:element name="IsOnGround" type="t:bool" minOccurs="0"/>
|
<xs:element name="IsOnGround" type="t:bool" minOccurs="0"/>
|
||||||
<xs:element name="VerticalStepHeight" type="t:double" minOccurs="0">
|
<xs:element name="VerticalStepHeight" type="t:double" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>The largest height of a "stair-step" that can be walked over</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>The largest height of a "stair-step" that can be walked over</xs:documentation></xs:annotation>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user