Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0aedeb61b4 | |||
| 0869afd529 | |||
| 56a13d03fc | |||
| dad18a200f | |||
| d6e3a47182 | |||
| 038a706e28 | |||
| bdcb33d992 | |||
| 8a8c375d3a | |||
| 8936b3d6c3 | |||
| 8a3564ad49 | |||
| 9581e9ac84 |
+1
-1
Submodule assets updated: 007b54bd67...33455a9d10
@@ -84,6 +84,18 @@ bool AABBvsTriangles(const AABB& box,
|
||||
const std::vector<unsigned int>& modelIndices,
|
||||
const glm::mat4& modelMatrix);
|
||||
|
||||
enum Output
|
||||
{
|
||||
OutContained,
|
||||
OutSeparated,
|
||||
OutIntersecting
|
||||
};
|
||||
//Detects intersection and containment.
|
||||
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||
const RawModel::Vertex* modelVertices,
|
||||
const std::vector<unsigned int>& modelIndices,
|
||||
const glm::mat4& modelMatrix);
|
||||
|
||||
//Return true if the boxes are intersecting.
|
||||
bool AABBVsAABB(const AABB& a, const AABB& b);
|
||||
//Return true if the boxes are intersecting.
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
virtual const glm::vec3 Rotation() const { return m_Rotation; }
|
||||
virtual bool Jumping() const { return m_Jumping; }
|
||||
virtual bool Crouching() const { return m_Crouching; }
|
||||
virtual bool CrouchingLastFrame() const { return m_CrouchingLastFrame; }
|
||||
virtual bool DoubleJumping() const { return m_DoubleJumping; }
|
||||
virtual void SetDoubleJumping(bool isDoubleJumping) {
|
||||
m_DoubleJumping = isDoubleJumping;
|
||||
@@ -44,6 +45,7 @@ protected:
|
||||
bool m_Jumping = false;
|
||||
bool m_DoubleJumping = false;
|
||||
bool m_Crouching = false;
|
||||
bool m_CrouchingLastFrame = false;
|
||||
//assault dash membervariables - needed to calculate the doubletap- and dashlogic
|
||||
double m_AssaultDashDoubleTapDeltaTime = 0.0;
|
||||
//i will let m_AssaultDashDoubleTapSensitivityTimer stay hardcoded, its not really a gamevariable (more an inputvariable),
|
||||
@@ -82,6 +84,7 @@ void FirstPersonInputController<EventContext>::Reset()
|
||||
{
|
||||
m_Rotation = glm::vec3(0.f, 0.f, 0.f);
|
||||
m_Jumping = false;
|
||||
m_CrouchingLastFrame = m_Crouching;
|
||||
}
|
||||
|
||||
template <typename EventContext>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Core/System.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
|
||||
class SpectatorCameraSystem : public ImpureSystem
|
||||
{
|
||||
@@ -17,6 +18,8 @@ private:
|
||||
|
||||
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
|
||||
bool OnInputCommand(const Events::InputCommand& e);
|
||||
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
|
||||
bool OnDisconnect(const Events::PlayerDisconnected& e);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -29,4 +29,6 @@ K=TakeDamage,1500
|
||||
F2=PerformanceTimingResetAllTimers
|
||||
F3=PerformanceTimingCreateExcelData
|
||||
Comma=SwapToClassPick
|
||||
Period=SwapToTeamPick
|
||||
Period=SwapToTeamPick
|
||||
Enter=PickClass,1
|
||||
F5=DisconnectFromServer
|
||||
@@ -13,6 +13,7 @@
|
||||
<c:Model>
|
||||
<Resource>models/core/unitcube.mesh</Resource>
|
||||
<Color A="1" B="0.980392158" G="1" R="1"/>
|
||||
<Shadow>false</Shadow>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-0.100000001" Y="0" Z="0"/>
|
||||
@@ -28,6 +29,7 @@
|
||||
<c:Model>
|
||||
<Resource>models/core/unitcube.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
<Shadow>false</Shadow>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-14.500001" Y="1.50000012" Z="16.9222012"/>
|
||||
@@ -52,6 +54,7 @@
|
||||
<c:Model>
|
||||
<Resource>models/core/unitcube.mesh</Resource>
|
||||
<Color A="1" B="1" G="0" R="0"/>
|
||||
<Shadow>false</Shadow>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-14.500001" Y="1.50000012" Z="-17.6888409"/>
|
||||
@@ -67,6 +70,7 @@
|
||||
<c:Model>
|
||||
<Resource>models/core/unitcube.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
<Shadow>false</Shadow>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="12.1000004" Y="1.50000012" Z="16.9222012"/>
|
||||
@@ -82,6 +86,7 @@
|
||||
<c:Model>
|
||||
<Resource>models/core/unitcube.mesh</Resource>
|
||||
<Color A="1" B="1" G="0" R="0"/>
|
||||
<Shadow>false</Shadow>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="12.1228638" Y="1.50000012" Z="-17.9642811"/>
|
||||
@@ -198,6 +203,7 @@
|
||||
<c:Model>
|
||||
<Resource>models/core/unitcube.mesh</Resource>
|
||||
<Color A="1" B="39.2156868" G="0" R="3.13725495"/>
|
||||
<Shadow>false</Shadow>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Scale X="-70" Y="-70" Z="-70"/>
|
||||
@@ -210,7 +216,7 @@
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="-">
|
||||
<Entity name="CapP">
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:CapturePoint>
|
||||
@@ -254,6 +260,13 @@
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:PointLight/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="Blue">
|
||||
@@ -265,7 +278,25 @@
|
||||
<Scale X="3.4000001" Y="4.70000029" Z="0.700000048"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource></Resource>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:PointLight/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="Spectator">
|
||||
<Components>
|
||||
@@ -276,7 +307,43 @@
|
||||
<Scale X="1" Y="5.70000029" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:PointLight/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource></Resource>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:PointLight/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource></Resource>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
@@ -287,11 +354,11 @@
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="-">
|
||||
<Entity name="CapP">
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:CapturePoint>
|
||||
<CaptureTimer>-15</CaptureTimer>
|
||||
<CaptureTimer>12</CaptureTimer>
|
||||
<HomePointForTeam>
|
||||
<Blue/>
|
||||
</HomePointForTeam>
|
||||
@@ -317,7 +384,38 @@
|
||||
<Scale X="4.4000001" Y="2" Z="3.70000029"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource></Resource>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="Blue">
|
||||
<Components>
|
||||
|
||||
@@ -360,7 +360,14 @@ constexpr bool FaceIsGround(float faceNormalY)
|
||||
//An array containing 3 int pairs { 0, 2 }, { 0, 1 }, { 1, 2 }
|
||||
constexpr std::array<std::pair<int, int>, 3> dimensionPairs({ std::pair<int, int>(0, 2), std::pair<int, int>(0, 1), std::pair<int, int>(1, 2) });
|
||||
|
||||
bool AABBvsTriangle(const AABB& box,
|
||||
enum class BoxTriRes
|
||||
{
|
||||
Front,
|
||||
Behind,
|
||||
Intersect
|
||||
};
|
||||
|
||||
BoxTriRes AABBvsTriangle(const AABB& box,
|
||||
const std::array<glm::vec3, 3>& triPos,
|
||||
const glm::vec3& originalBoxVelocity,
|
||||
float verticalStepHeight,
|
||||
@@ -374,7 +381,7 @@ bool AABBvsTriangle(const AABB& box,
|
||||
//Less checks, and we should be able to walk out from models if we are trapped inside.
|
||||
glm::vec3 triNormal = glm::cross(triPos[1] - triPos[0], triPos[2] - triPos[0]);
|
||||
if (!vectorHasLength(triNormal) || (glm::dot(triNormal, originalBoxVelocity) > 0)) {
|
||||
return false;
|
||||
return BoxTriRes::Behind;
|
||||
}
|
||||
triNormal = glm::normalize(triNormal);
|
||||
|
||||
@@ -409,6 +416,9 @@ bool AABBvsTriangle(const AABB& box,
|
||||
const glm::vec3& min = box.MinCorner();
|
||||
const glm::vec3& max = box.MaxCorner();
|
||||
|
||||
// If there is no intersection, whether the box center is in front of or behind the triangle.
|
||||
BoxTriRes noIntersection = glm::dot(triNormal, origin - triPos[0]) > 0 ? BoxTriRes::Front : BoxTriRes::Behind;
|
||||
|
||||
//For each projection in xy-, xz-, and yx-planes.
|
||||
for (std::pair<int, int> dim : dimensionPairs) {
|
||||
//2D Triangle.
|
||||
@@ -426,7 +436,7 @@ bool AABBvsTriangle(const AABB& box,
|
||||
bool pushedFromTriangleLine;
|
||||
//if projections don't overlap, return false.
|
||||
if (!rectangleVsTriangle(boxMin, boxMax, t2D, resolutionVector, resolutionDist, pushedFromTriangleLine)) {
|
||||
return false;
|
||||
return noIntersection;
|
||||
} else if (resolveCollision) {
|
||||
//Overwrite the smallest resolution if this is smaller.
|
||||
if (resolutionDist < resolveShortest.DistanceSq) {
|
||||
@@ -462,14 +472,15 @@ bool AABBvsTriangle(const AABB& box,
|
||||
float t = glm::dot(triNormal, triPos[0] - origin) / glm::dot(triNormal, diagonal);
|
||||
//If intersection point between plane and diagonal is within the box.
|
||||
if (glm::abs(t) > 1) {
|
||||
return false;
|
||||
return noIntersection;
|
||||
}
|
||||
|
||||
if (!resolveCollision) {
|
||||
return true;
|
||||
return BoxTriRes::Intersect;
|
||||
}
|
||||
|
||||
glm::vec3 cornerResolution = (1+t) * diagonal;
|
||||
cornerResolution = glm::dot(cornerResolution, triNormal) * triNormal;
|
||||
//Overwrite the smallest resolution if cornerResolution is smaller.
|
||||
float lenSq = glm::length2(cornerResolution);
|
||||
if (lenSq < resolveShortest.DistanceSq) {
|
||||
@@ -498,7 +509,7 @@ bool AABBvsTriangle(const AABB& box,
|
||||
case ResolveDimZ:
|
||||
//If we get here, the resolution is along one coordinate axis.
|
||||
//set velocity to 0 in y if it is along y-axis.
|
||||
return true;
|
||||
return BoxTriRes::Intersect;
|
||||
case Line:
|
||||
projNorm = glm::normalize(outResolution);
|
||||
break;
|
||||
@@ -533,10 +544,10 @@ bool AABBvsTriangle(const AABB& box,
|
||||
boxVelocity = boxVelocity - glm::dot(boxVelocity, projNorm) * projNorm;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return BoxTriRes::Intersect;
|
||||
}
|
||||
|
||||
bool AABBvsTriangles(const AABB& box,
|
||||
Output AABBvsTriangles(const AABB& box,
|
||||
const RawModel::Vertex* modelVertices,
|
||||
const std::vector<unsigned int>& modelIndices,
|
||||
const glm::mat4& modelMatrix,
|
||||
@@ -546,8 +557,8 @@ bool AABBvsTriangles(const AABB& box,
|
||||
glm::vec3& outResolutionVector,
|
||||
bool resolveCollision)
|
||||
{
|
||||
bool hit = false;
|
||||
|
||||
bool intersect = false;
|
||||
Output out = Output::OutContained;
|
||||
bool everHitTheGround = false;
|
||||
AABB newBox = box;
|
||||
outResolutionVector = glm::vec3(0.f);
|
||||
@@ -560,20 +571,27 @@ bool AABBvsTriangles(const AABB& box,
|
||||
};
|
||||
glm::vec3 outVec;
|
||||
bool collideWithGround = isOnGround;
|
||||
if (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
|
||||
hit = true;
|
||||
switch (AABBvsTriangle(newBox, triVertices, originalBoxVelocity, verticalStepHeight, collideWithGround, boxVelocity, outVec, resolveCollision)) {
|
||||
case Collision::BoxTriRes::Front:
|
||||
out = Output::OutSeparated;
|
||||
break;
|
||||
case Collision::BoxTriRes::Intersect:
|
||||
intersect = true;
|
||||
outResolutionVector += outVec;
|
||||
newBox = AABB::FromOriginSize(newBox.Origin() + outVec, newBox.Size());
|
||||
if (collideWithGround) {
|
||||
everHitTheGround = isOnGround = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!everHitTheGround) {
|
||||
isOnGround = false;
|
||||
}
|
||||
return hit;
|
||||
return intersect ? Output::OutIntersecting : out;
|
||||
}
|
||||
|
||||
bool AABBvsTriangles(const AABB& box,
|
||||
@@ -593,13 +611,31 @@ bool AABBvsTriangles(const AABB& box,
|
||||
verticalStepHeight,
|
||||
isOnGround,
|
||||
outResolutionVector,
|
||||
true);
|
||||
true) == Output::OutIntersecting;
|
||||
}
|
||||
|
||||
bool AABBvsTriangles(const AABB& box,
|
||||
const RawModel::Vertex* modelVertices,
|
||||
const std::vector<unsigned int>& modelIndices,
|
||||
const glm::mat4& modelMatrix)
|
||||
{
|
||||
glm::vec3 vel, outres;
|
||||
bool g;
|
||||
return AABBvsTriangles(box,
|
||||
modelVertices,
|
||||
modelIndices,
|
||||
modelMatrix,
|
||||
vel,
|
||||
0.f,
|
||||
g,
|
||||
outres,
|
||||
false) == Output::OutIntersecting;
|
||||
}
|
||||
|
||||
Output AABBvsTrianglesWContainment(const AABB& box,
|
||||
const RawModel::Vertex* modelVertices,
|
||||
const std::vector<unsigned int>& modelIndices,
|
||||
const glm::mat4& modelMatrix)
|
||||
{
|
||||
glm::vec3 vel, outres;
|
||||
bool g;
|
||||
|
||||
@@ -37,6 +37,10 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
bool hit;
|
||||
float dist;
|
||||
if (boxB.Entity.HasComponent("Model")) {
|
||||
if (!((bool)boxB.Entity["Model"]["Visible"])) {
|
||||
// Don't collide against invisible models.
|
||||
continue;
|
||||
}
|
||||
RawModel* model;
|
||||
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
|
||||
try {
|
||||
@@ -77,7 +81,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
}
|
||||
|
||||
if (boxB.Entity.HasComponent("Model") && Collision::AABBVsAABB(boxA, boxB)) {
|
||||
//Here we know boxB is a entity with Collideable, AABB, and Model.
|
||||
// Here we know boxB is a entity with Collideable, AABB, and Model.
|
||||
if (!((bool)boxB.Entity["Model"]["Visible"])) {
|
||||
// Don't collide against invisible models.
|
||||
continue;
|
||||
}
|
||||
RawModel* model;
|
||||
try {
|
||||
model = ResourceManager::Load<RawModel, true>(boxB.Entity["Model"]["Resource"]);
|
||||
@@ -88,12 +96,11 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
|
||||
|
||||
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
|
||||
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
|
||||
bool isOnGround = (bool)cPhysics["IsOnGround"];
|
||||
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
|
||||
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
||||
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector.
|
||||
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
|
||||
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||
boxA = *Collision::EntityAbsoluteAABB(entity);
|
||||
cPhysics["Velocity"] = inOutVelocity;
|
||||
if (isOnGround) {
|
||||
|
||||
@@ -10,6 +10,16 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
||||
return;
|
||||
}
|
||||
|
||||
RawModel* triggerModel = nullptr;
|
||||
glm::mat4 triggerModelMat;
|
||||
if (triggerEntity.HasComponent("Model")) {
|
||||
try {
|
||||
triggerModel = ResourceManager::Load<RawModel, true>(triggerEntity["Model"]["Resource"]);
|
||||
triggerModelMat = Transform::ModelMatrix(triggerEntity);
|
||||
} catch (const std::exception&) {
|
||||
}
|
||||
}
|
||||
|
||||
m_OctreeOut.clear();
|
||||
m_Octree->ObjectsInSameRegion(*triggerBox, m_OctreeOut);
|
||||
|
||||
@@ -22,7 +32,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
||||
if (colliderFitsInTrigger) {
|
||||
completelyInsideBox = AABB::FromOriginSize((*triggerBox).Origin(), (*triggerBox).Size() - 2.0f * colliderBox.Size());
|
||||
}
|
||||
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox)) {
|
||||
|
||||
// We know the entity is inside the trigger box, but perhaps not the model yet.
|
||||
Collision::Output out = triggerModel == nullptr
|
||||
? Collision::Output::OutContained
|
||||
: Collision::AABBvsTrianglesWContainment(
|
||||
colliderBox,
|
||||
triggerModel->Vertices(),
|
||||
triggerModel->m_Indices,
|
||||
triggerModelMat);
|
||||
|
||||
if (colliderFitsInTrigger && Collision::AABBVsAABB(completelyInsideBox, colliderBox) && out == Collision::Output::OutContained) {
|
||||
// Entity is completely inside the trigger.
|
||||
// If it was only touching before, it is erased.
|
||||
m_EntitiesTouchingTrigger[triggerEntity].erase(colliderEntity);
|
||||
@@ -32,7 +52,8 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
||||
completeSet.insert(colliderEntity);
|
||||
publish<Events::TriggerEnter>(colliderEntity, triggerEntity);
|
||||
}
|
||||
} else {
|
||||
continue;
|
||||
} else if (out != Collision::Output::OutSeparated) {
|
||||
// Entity is only touching the trigger.
|
||||
auto& touchSet = m_EntitiesTouchingTrigger[triggerEntity];
|
||||
auto& completeSet = m_EntitiesCompletelyInTrigger[triggerEntity];
|
||||
@@ -47,17 +68,17 @@ void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapp
|
||||
touchSet.insert(colliderEntity);
|
||||
}
|
||||
// Else, it was touching the trigger last frame too and nothing is done.
|
||||
}
|
||||
} else {
|
||||
// Entity is not touching the trigger,
|
||||
// Throw event if it was previously.
|
||||
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
||||
continue;
|
||||
}
|
||||
// This only occurs if the entity was completely inside the trigger one frame,
|
||||
// then completely outside the trigger, e.g. when dying and respawning.
|
||||
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
||||
}
|
||||
// Only get here if entity is not touching the trigger,
|
||||
// throw event if it was touching previously.
|
||||
if (throwLeaveIfWasInTrigger(m_EntitiesTouchingTrigger[triggerEntity], colliderEntity, triggerEntity)) {
|
||||
continue;
|
||||
}
|
||||
// This only occurs if the entity was completely inside the trigger one frame,
|
||||
// then completely outside the trigger, e.g. when dying and respawning.
|
||||
throwLeaveIfWasInTrigger(m_EntitiesCompletelyInTrigger[triggerEntity], colliderEntity, triggerEntity);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
|
||||
Enable();
|
||||
} else {
|
||||
Disable();
|
||||
m_EventBroker->Publish(Events::UnlockMouse());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Network/Client.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
using namespace boost::asio::ip;
|
||||
|
||||
Client::Client(World* world, EventBroker* eventBroker)
|
||||
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
|
||||
void Client::parseKick()
|
||||
{
|
||||
LOG_WARNING("You have been kicked from the server.");
|
||||
m_IsConnected = false;
|
||||
disconnect();
|
||||
}
|
||||
|
||||
void Client::parseSpawnEvents()
|
||||
@@ -464,6 +465,10 @@ void Client::disconnect()
|
||||
Packet packet(MessageType::Disconnect, m_SendPacketID);
|
||||
m_Reliable.Send(packet);
|
||||
m_Reliable.Disconnect();
|
||||
Events::PlayerDisconnected e;
|
||||
e.Entity = m_LocalPlayer.ID;
|
||||
e.PlayerID = -1;
|
||||
m_EventBroker->Publish(e);
|
||||
createMainMenu();
|
||||
}
|
||||
|
||||
|
||||
@@ -234,9 +234,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
|
||||
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
|
||||
(bool&)capturePointModels["Model"]["Visible"] = isOwner;
|
||||
for (auto& capModel : capturePointModels.ChildrenWithComponent("Model"))
|
||||
for (auto& capModel : capturePointModels.ChildrenWithComponent("Transform"))
|
||||
{
|
||||
(bool&)capModel["Model"]["Visible"] = isOwner;
|
||||
if (capModel.HasComponent("Model")) {
|
||||
(bool&)capModel["Model"]["Visible"] = isOwner;
|
||||
}
|
||||
if (capModel.HasComponent("PointLight")) {
|
||||
(bool&)capModel["PointLight"]["Visible"] = isOwner;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -264,6 +264,11 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
size = glm::vec3(1.f, 1.f, 1.f);
|
||||
} else {
|
||||
size = glm::vec3(1.f, 1.6f, 1.f);
|
||||
if (controller->CrouchingLastFrame() && isOnGround) {
|
||||
// The collision should resolve this anyway, but
|
||||
// this is more reliable, since the box gets larger.
|
||||
((glm::vec3&)cTransform["Position"]).y += 0.3f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
|
||||
, m_PickedTeam(-1)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
|
||||
}
|
||||
|
||||
void SpectatorCameraSystem::Update(double dt)
|
||||
@@ -87,4 +88,17 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
|
||||
{
|
||||
// If local player gets disconnected, they should be set to
|
||||
// the spectator camera next time a map loads that has one.
|
||||
if (e.Entity == LocalPlayer.ID) {
|
||||
m_CamSetToTeamPick = false;
|
||||
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
|
||||
Events::UnlockMouse unlock;
|
||||
m_EventBroker->Publish(unlock);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user