mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 21:47:24 +00:00
Use better API terminology for radii
- SetProximityRadius just calls AddProximityRadius so its clear what is going on. - created struct BoxDimensions for clear reading of what the floats are
This commit is contained in:
parent
be17d1a467
commit
68a5cc1d89
@ -279,7 +279,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1: { //Make a new box shape
|
case 1: { //Make a new box shape
|
||||||
NiPoint3 boxSize(x, y, z);
|
BoxDimensions boxSize(x, y, z);
|
||||||
if (x == 0.0f) {
|
if (x == 0.0f) {
|
||||||
//LU has some weird values, so I think it's best to scale them down a bit
|
//LU has some weird values, so I think it's best to scale them down a bit
|
||||||
if (height < 0.5f) height = 2.0f;
|
if (height < 0.5f) height = 2.0f;
|
||||||
@ -289,7 +289,7 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
|||||||
width = width * m_Scale;
|
width = width * m_Scale;
|
||||||
height = height * m_Scale;
|
height = height * m_Scale;
|
||||||
|
|
||||||
boxSize = NiPoint3(width, height, width);
|
boxSize = BoxDimensions(width, height, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), boxSize);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), boxSize);
|
||||||
|
@ -36,23 +36,24 @@ void ProximityMonitorComponent::LoadTemplateData() {
|
|||||||
GeneralUtils::TryParse(proximitySplit.at(0), radiusSmall);
|
GeneralUtils::TryParse(proximitySplit.at(0), radiusSmall);
|
||||||
GeneralUtils::TryParse(proximitySplit.at(1), radiusLarge);
|
GeneralUtils::TryParse(proximitySplit.at(1), radiusLarge);
|
||||||
if (radiusSmall != -1.0f && radiusLarge != -1.0f) {
|
if (radiusSmall != -1.0f && radiusLarge != -1.0f) {
|
||||||
SetProximityRadius(radiusSmall, "rocketSmall");
|
AddProximityRadius(radiusSmall, "rocketSmall");
|
||||||
SetProximityRadius(radiusLarge, "rocketLarge");
|
AddProximityRadius(radiusLarge, "rocketLarge");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProximityMonitorComponent::SetProximityRadius(float proxRadius, const std::string& name) {
|
void ProximityMonitorComponent::AddProximityRadius(float proxRadius, const std::string& name) {
|
||||||
dpEntity* en = new dpEntity(m_ParentEntity->GetObjectID(), proxRadius);
|
dpEntity* entity = new dpEntity(m_ParentEntity->GetObjectID(), proxRadius);
|
||||||
en->SetPosition(m_ParentEntity->GetPosition());
|
|
||||||
|
|
||||||
dpWorld::Instance().AddEntity(en);
|
|
||||||
m_ProximitiesData.insert(std::make_pair(name, en));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProximityMonitorComponent::SetProximityRadius(dpEntity* entity, const std::string& name) {
|
|
||||||
dpWorld::Instance().AddEntity(entity);
|
|
||||||
entity->SetPosition(m_ParentEntity->GetPosition());
|
entity->SetPosition(m_ParentEntity->GetPosition());
|
||||||
|
|
||||||
|
dpWorld::Instance().AddEntity(entity);
|
||||||
|
m_ProximitiesData.insert(std::make_pair(name, entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProximityMonitorComponent::AddProximityRadius(const BoxDimensions& dimensions, const std::string& name) {
|
||||||
|
dpEntity* entity = new dpEntity(m_ParentEntity->GetObjectID(), dimensions);
|
||||||
|
entity->SetPosition(m_ParentEntity->GetPosition());
|
||||||
|
dpWorld::Instance().AddEntity(entity);
|
||||||
m_ProximitiesData.insert(std::make_pair(name, entity));
|
m_ProximitiesData.insert(std::make_pair(name, entity));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,14 +32,14 @@ public:
|
|||||||
* @param proxRadius the radius to use for the physics entity we use to detect proximity
|
* @param proxRadius the radius to use for the physics entity we use to detect proximity
|
||||||
* @param name the name of this check
|
* @param name the name of this check
|
||||||
*/
|
*/
|
||||||
void SetProximityRadius(float proxRadius, const std::string& name);
|
void AddProximityRadius(float proxRadius, const std::string& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an entry to check proximity for, given a name
|
* Creates an entry to check proximity for, given a name
|
||||||
* @param entity the physics entity to add to our proximity sensors
|
* @param entity the physics entity to add to our proximity sensors
|
||||||
* @param name the name of this check
|
* @param name the name of this check
|
||||||
*/
|
*/
|
||||||
void SetProximityRadius(dpEntity* entity, const std::string& name);
|
void AddProximityRadius(const BoxDimensions& entity, const std::string& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the last of entities that are used to check proximity, given a name
|
* Returns the last of entities that are used to check proximity, given a name
|
||||||
|
@ -559,17 +559,14 @@ void Entity::IsGhosted() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to header
|
|
||||||
bool Entity::operator==(const Entity& other) const {
|
bool Entity::operator==(const Entity& other) const {
|
||||||
return other.m_ObjectID == m_ObjectID;
|
return other.m_ObjectID == m_ObjectID;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to header
|
|
||||||
bool Entity::operator!=(const Entity& other) const {
|
bool Entity::operator!=(const Entity& other) const {
|
||||||
return !(other.m_ObjectID == m_ObjectID);
|
return !(other.m_ObjectID == m_ObjectID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Move to header
|
|
||||||
bool Entity::HasComponent(const eReplicaComponentType componentId) const {
|
bool Entity::HasComponent(const eReplicaComponentType componentId) const {
|
||||||
return m_Components.find(componentId) != m_Components.end();
|
return m_Components.find(componentId) != m_Components.end();
|
||||||
}
|
}
|
||||||
@ -593,15 +590,15 @@ void Entity::Unsubscribe(CppScripts::Script* scriptToRemove, const std::string&
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fine
|
// Fine
|
||||||
void Entity::SetProximityRadius(const float proxRadius, const std::string& name) {
|
void Entity::AddProximityRadius(const float proxRadius, const std::string& name) {
|
||||||
auto* proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
|
auto* proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
|
||||||
if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(proxRadius, name);
|
if (proximityMonitorComponent) proximityMonitorComponent->AddProximityRadius(proxRadius, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove in favor of a square constructor
|
// Remove in favor of a square constructor
|
||||||
void Entity::SetProximityRadius(dpEntity* entity, const std::string& name) {
|
void Entity::AddProximityRadius(const BoxDimensions& dimensions, const std::string& name) {
|
||||||
auto* proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
|
auto* proximityMonitorComponent = AddComponent<ProximityMonitorComponent>();
|
||||||
if (proximityMonitorComponent) proximityMonitorComponent->SetProximityRadius(entity, name);
|
if (proximityMonitorComponent) proximityMonitorComponent->AddProximityRadius(dimensions, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetGMLevel(eGameMasterLevel value) {
|
void Entity::SetGMLevel(eGameMasterLevel value) {
|
||||||
|
@ -35,6 +35,7 @@ class Item;
|
|||||||
class Character;
|
class Character;
|
||||||
class EntityCallbackTimer;
|
class EntityCallbackTimer;
|
||||||
class LDFBaseData;
|
class LDFBaseData;
|
||||||
|
class BoxDimensions;
|
||||||
enum class eTriggerEventType;
|
enum class eTriggerEventType;
|
||||||
enum class eGameMasterLevel : uint8_t;
|
enum class eGameMasterLevel : uint8_t;
|
||||||
enum class eReplicaComponentType : uint32_t;
|
enum class eReplicaComponentType : uint32_t;
|
||||||
@ -168,9 +169,14 @@ public:
|
|||||||
* no longer be notified of notificationName events
|
* no longer be notified of notificationName events
|
||||||
*/
|
*/
|
||||||
void Unsubscribe(CppScripts::Script* scriptToRemove, const std::string& notificationName);
|
void Unsubscribe(CppScripts::Script* scriptToRemove, const std::string& notificationName);
|
||||||
// ### STOPPED HERE ###
|
|
||||||
void SetProximityRadius(const float proxRadius, const std::string& name);
|
void AddProximityRadius(const float proxRadius, const std::string& name);
|
||||||
void SetProximityRadius(dpEntity* entity, const std::string& name);
|
void AddProximityRadius(const BoxDimensions& dimensions, const std::string& name);
|
||||||
|
|
||||||
|
// Technically this is the live accrate API, however what it does is not setting the proximity radius, but rather
|
||||||
|
// adding a new one to the list of proximity radii. For that reason we will have the old API just call AddProximityRadius.
|
||||||
|
inline void SetProximityRadius(const float proxRadius, const std::string& name) { this->AddProximityRadius(proxRadius, name); }
|
||||||
|
inline void SetProximityRadius(const BoxDimensions& dimensions, const std::string& name) { this->AddProximityRadius(dimensions, name); }
|
||||||
|
|
||||||
void AddChild(Entity* child);
|
void AddChild(Entity* child);
|
||||||
void RemoveChild(Entity* child);
|
void RemoveChild(Entity* child);
|
||||||
|
@ -18,7 +18,7 @@ dpEntity::dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStati
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case dpShapeType::Box:
|
case dpShapeType::Box:
|
||||||
m_CollisionShape = new dpShapeBox(this, 1.0f, 1.0f, 1.0f);
|
m_CollisionShape = new dpShapeBox(this, BoxDimensions(1.0f, 1.0f, 1.0f));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -26,14 +26,14 @@ dpEntity::dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStati
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dpEntity::dpEntity(const LWOOBJID& objectID, NiPoint3 boxDimensions, bool isStatic) {
|
dpEntity::dpEntity(const LWOOBJID& objectID, const BoxDimensions& boxDimensions, bool isStatic) {
|
||||||
m_ObjectID = objectID;
|
m_ObjectID = objectID;
|
||||||
m_IsStatic = isStatic;
|
m_IsStatic = isStatic;
|
||||||
m_CollisionShape = nullptr;
|
m_CollisionShape = nullptr;
|
||||||
m_Scale = 1.0f;
|
m_Scale = 1.0f;
|
||||||
m_CollisionGroup = COLLISION_GROUP_ALL;
|
m_CollisionGroup = COLLISION_GROUP_ALL;
|
||||||
|
|
||||||
m_CollisionShape = new dpShapeBox(this, boxDimensions.x, boxDimensions.y, boxDimensions.z);
|
m_CollisionShape = new dpShapeBox(this, boxDimensions);
|
||||||
}
|
}
|
||||||
|
|
||||||
dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic) {
|
dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic) {
|
||||||
@ -43,7 +43,7 @@ dpEntity::dpEntity(const LWOOBJID& objectID, float width, float height, float de
|
|||||||
m_Scale = 1.0f;
|
m_Scale = 1.0f;
|
||||||
m_CollisionGroup = COLLISION_GROUP_ALL;
|
m_CollisionGroup = COLLISION_GROUP_ALL;
|
||||||
|
|
||||||
m_CollisionShape = new dpShapeBox(this, width, height, depth);
|
m_CollisionShape = new dpShapeBox(this, BoxDimensions(width, height, depth));
|
||||||
}
|
}
|
||||||
|
|
||||||
dpEntity::dpEntity(const LWOOBJID& objectID, float radius, bool isStatic) {
|
dpEntity::dpEntity(const LWOOBJID& objectID, float radius, bool isStatic) {
|
||||||
|
@ -10,12 +10,14 @@
|
|||||||
#include "dpCollisionGroups.h"
|
#include "dpCollisionGroups.h"
|
||||||
#include "dpGrid.h"
|
#include "dpGrid.h"
|
||||||
|
|
||||||
|
class BoxDimensions;
|
||||||
|
|
||||||
class dpEntity {
|
class dpEntity {
|
||||||
friend class dpGrid; //using friend here for now so grid can access everything
|
friend class dpGrid; //using friend here for now so grid can access everything
|
||||||
|
|
||||||
public:
|
public:
|
||||||
dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStatic = true);
|
dpEntity(const LWOOBJID& objectID, dpShapeType shapeType, bool isStatic = true);
|
||||||
dpEntity(const LWOOBJID& objectID, NiPoint3 boxDimensions, bool isStatic = true);
|
dpEntity(const LWOOBJID& objectID, const BoxDimensions& boxDimensions, bool isStatic = true);
|
||||||
dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic = true);
|
dpEntity(const LWOOBJID& objectID, float width, float height, float depth, bool isStatic = true);
|
||||||
dpEntity(const LWOOBJID& objectID, float radius, bool isStatic = true);
|
dpEntity(const LWOOBJID& objectID, float radius, bool isStatic = true);
|
||||||
|
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
dpShapeBox::dpShapeBox(dpEntity* parentEntity, float width, float height, float depth) :
|
dpShapeBox::dpShapeBox(dpEntity* parentEntity, const BoxDimensions& dimensions) :
|
||||||
dpShapeBase(parentEntity),
|
dpShapeBase(parentEntity),
|
||||||
m_Width(width / 2),
|
m_Width(dimensions.width / 2),
|
||||||
m_Height(height / 2),
|
m_Height(dimensions.height / 2),
|
||||||
m_Depth(depth / 2),
|
m_Depth(dimensions.depth / 2),
|
||||||
m_Scale(1.0f) {
|
m_Scale(1.0f) {
|
||||||
m_ShapeType = dpShapeType::Box;
|
m_ShapeType = dpShapeType::Box;
|
||||||
|
|
||||||
|
@ -4,9 +4,16 @@
|
|||||||
#include "NiPoint3.h"
|
#include "NiPoint3.h"
|
||||||
#include "NiQuaternion.h"
|
#include "NiQuaternion.h"
|
||||||
|
|
||||||
|
struct BoxDimensions {
|
||||||
|
BoxDimensions(float width, float height, float depth) : width(width), height(height), depth(depth) { }
|
||||||
|
float width;
|
||||||
|
float height;
|
||||||
|
float depth;
|
||||||
|
};
|
||||||
|
|
||||||
class dpShapeBox : public dpShapeBase {
|
class dpShapeBox : public dpShapeBase {
|
||||||
public:
|
public:
|
||||||
dpShapeBox(dpEntity* parentEntity, float width, float height, float depth);
|
dpShapeBox(dpEntity* parentEntity, const BoxDimensions& dimensions);
|
||||||
~dpShapeBox();
|
~dpShapeBox();
|
||||||
|
|
||||||
bool IsColliding(dpShapeBase* other);
|
bool IsColliding(dpShapeBase* other);
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#include "AmSkullkinDrillStand.h"
|
#include "AmSkullkinDrillStand.h"
|
||||||
#include "GameMessages.h"
|
#include "GameMessages.h"
|
||||||
#include "dpEntity.h"
|
#include "dpShapeBox.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "RenderComponent.h"
|
#include "RenderComponent.h"
|
||||||
|
|
||||||
void AmSkullkinDrillStand::OnStartup(Entity* self) {
|
void AmSkullkinDrillStand::OnStartup(Entity* self) {
|
||||||
self->SetVar(u"bActive", true);
|
self->SetVar(u"bActive", true);
|
||||||
|
|
||||||
self->SetProximityRadius(new dpEntity(self->GetObjectID(), { 6, 14, 6 }), "knockback");
|
self->SetProximityRadius(BoxDimensions(6.0f, 14.0f, 6.0f), "knockback");
|
||||||
}
|
}
|
||||||
|
|
||||||
void AmSkullkinDrillStand::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
|
void AmSkullkinDrillStand::OnNotifyObject(Entity* self, Entity* sender, const std::u16string& name, int32_t param1, int32_t param2) {
|
||||||
|
Loading…
Reference in New Issue
Block a user