mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-26 07:27:18 +00:00
PhantomPhysicsComponent pass
This commit is contained in:
parent
87675aa62d
commit
28637a206d
@ -61,6 +61,7 @@ const LOT LOT_3D_AMBIENT_SOUND = 6368;
|
|||||||
const LOT LOT_MODEL_IN_WORLD = 14;
|
const LOT LOT_MODEL_IN_WORLD = 14;
|
||||||
const LOT LOT_THINKING_CAP = 6086;
|
const LOT LOT_THINKING_CAP = 6086;
|
||||||
const LOT LOT_ROCKET = 6416;
|
const LOT LOT_ROCKET = 6416;
|
||||||
|
const LOT LOT_LEGACY_RESPAWN_POINT = 4945;
|
||||||
|
|
||||||
|
|
||||||
const float PI = 3.14159f;
|
const float PI = 3.14159f;
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "dpEntity.h"
|
#include "dpEntity.h"
|
||||||
#include "dpShapeBox.h"
|
#include "dpShapeBox.h"
|
||||||
#include "dpShapeSphere.h"
|
#include "dpShapeSphere.h"
|
||||||
|
#include "NiPoint3.h"
|
||||||
|
#include "NiQuaternion.h"
|
||||||
|
|
||||||
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(parent) {
|
||||||
m_Position = m_ParentEntity->GetDefaultPosition();
|
m_Position = m_ParentEntity->GetDefaultPosition();
|
||||||
@ -45,7 +47,7 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
m_Max = 1;
|
m_Max = 1;
|
||||||
|
|
||||||
m_IsDirectional = false;
|
m_IsDirectional = false;
|
||||||
m_Direction = NiPoint3(); // * m_DirectionalMultiplier
|
m_Direction = NiPoint3::ZERO;
|
||||||
|
|
||||||
if (m_ParentEntity->GetVar<bool>(u"create_physics")) {
|
if (m_ParentEntity->GetVar<bool>(u"create_physics")) {
|
||||||
CreatePhysics();
|
CreatePhysics();
|
||||||
@ -56,221 +58,134 @@ PhantomPhysicsComponent::PhantomPhysicsComponent(Entity* parent) : Component(par
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (m_IsRespawnVolume) {
|
if (m_IsRespawnVolume) {
|
||||||
{
|
auto respawnPosSplit = GeneralUtils::SplitString(m_ParentEntity->GetVarAsString(u"rspPos"), '\x1f');
|
||||||
auto respawnString = std::stringstream(m_ParentEntity->GetVarAsString(u"rspPos"));
|
m_RespawnPos = NiPoint3::ZERO;
|
||||||
|
if (respawnPosSplit.size() >= 3) {
|
||||||
std::string segment;
|
GeneralUtils::TryParse(respawnPosSplit[0], m_RespawnPos.x);
|
||||||
std::vector<std::string> seglist;
|
GeneralUtils::TryParse(respawnPosSplit[1], m_RespawnPos.y);
|
||||||
|
GeneralUtils::TryParse(respawnPosSplit[2], m_RespawnPos.z);
|
||||||
while (std::getline(respawnString, segment, '\x1f')) {
|
|
||||||
seglist.push_back(segment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_RespawnPos = NiPoint3(std::stof(seglist[0]), std::stof(seglist[1]), std::stof(seglist[2]));
|
auto respawnRotSplit = GeneralUtils::SplitString(m_ParentEntity->GetVarAsString(u"rspRot"), '\x1f');
|
||||||
}
|
m_RespawnRot = NiQuaternion::IDENTITY;
|
||||||
|
if (respawnRotSplit.size() >= 4) {
|
||||||
{
|
GeneralUtils::TryParse(respawnRotSplit[0], m_RespawnRot.w);
|
||||||
auto respawnString = std::stringstream(m_ParentEntity->GetVarAsString(u"rspRot"));
|
GeneralUtils::TryParse(respawnRotSplit[1], m_RespawnRot.x);
|
||||||
|
GeneralUtils::TryParse(respawnRotSplit[2], m_RespawnRot.y);
|
||||||
std::string segment;
|
GeneralUtils::TryParse(respawnRotSplit[3], m_RespawnRot.z);
|
||||||
std::vector<std::string> seglist;
|
|
||||||
|
|
||||||
while (std::getline(respawnString, segment, '\x1f')) {
|
|
||||||
seglist.push_back(segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_RespawnRot = NiQuaternion(std::stof(seglist[0]), std::stof(seglist[1]), std::stof(seglist[2]), std::stof(seglist[3]));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HF - RespawnPoints. Legacy respawn entity.
|
// HF - RespawnPoints. Legacy respawn entity.
|
||||||
if (m_ParentEntity->GetLOT() == 4945) {
|
if (m_ParentEntity->GetLOT() == LOT_LEGACY_RESPAWN_POINT) {
|
||||||
m_IsRespawnVolume = true;
|
m_IsRespawnVolume = true;
|
||||||
m_RespawnPos = m_Position;
|
m_RespawnPos = m_Position;
|
||||||
m_RespawnRot = m_Rotation;
|
m_RespawnRot = m_Rotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (m_HasCreatedPhysics) return;
|
||||||
for (LDFBaseData* data : settings) {
|
auto* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||||
if (data) {
|
|
||||||
if (data->GetKey() == u"create_physics") {
|
|
||||||
if (bool(std::stoi(data->GetValueAsString()))) {
|
|
||||||
CreatePhysics(settings);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->GetKey() == u"respawnVol") {
|
|
||||||
if (bool(std::stoi(data->GetValueAsString()))) {
|
|
||||||
m_IsRespawnVolume = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_IsRespawnVolume) {
|
|
||||||
if (data->GetKey() == u"rspPos") {
|
|
||||||
//Joy, we get to split strings!
|
|
||||||
std::stringstream test(data->GetValueAsString());
|
|
||||||
std::string segment;
|
|
||||||
std::vector<std::string> seglist;
|
|
||||||
|
|
||||||
while (std::getline(test, segment, '\x1f')) {
|
|
||||||
seglist.push_back(segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_RespawnPos = NiPoint3(std::stof(seglist[0]), std::stof(seglist[1]), std::stof(seglist[2]));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->GetKey() == u"rspRot") {
|
|
||||||
//Joy, we get to split strings!
|
|
||||||
std::stringstream test(data->GetValueAsString());
|
|
||||||
std::string segment;
|
|
||||||
std::vector<std::string> seglist;
|
|
||||||
|
|
||||||
while (std::getline(test, segment, '\x1f')) {
|
|
||||||
seglist.push_back(segment);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_RespawnRot = NiQuaternion(std::stof(seglist[0]), std::stof(seglist[1]), std::stof(seglist[2]), std::stof(seglist[3]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_ParentEntity->GetLOT() == 4945) // HF - RespawnPoints
|
|
||||||
{
|
|
||||||
m_IsRespawnVolume = true;
|
|
||||||
m_RespawnPos = m_Position;
|
|
||||||
m_RespawnRot = m_Rotation;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!m_HasCreatedPhysics) {
|
|
||||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
|
||||||
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||||
|
|
||||||
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
auto* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
||||||
|
|
||||||
if (physComp == nullptr) return;
|
if (!physComp) return;
|
||||||
|
|
||||||
auto* info = physComp->GetByID(componentID);
|
auto* info = physComp->GetByID(componentID);
|
||||||
if (info == nullptr || info->physicsAsset == "" || info->physicsAsset == "NO_PHYSICS") return;
|
if (!info || info->physicsAsset.empty() || info->physicsAsset == "NO_PHYSICS") return;
|
||||||
|
|
||||||
//temp test
|
//temp test
|
||||||
if (info->physicsAsset == "miscellaneous\\misc_phys_10x1x5.hkx") {
|
if (info->physicsAsset == "miscellaneous\\misc_phys_10x1x5.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 5.0f, 1.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 5.0f, 1.0f);
|
||||||
|
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
|
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "miscellaneous\\misc_phys_640x640.hkx") {
|
} else if (info->physicsAsset == "miscellaneous\\misc_phys_640x640.hkx") {
|
||||||
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
// Move this down by 13.521004 units so it is still effectively at the same height as before
|
||||||
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
|
m_Position = m_Position - NiPoint3::UNIT_Y * 13.521004f;
|
||||||
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
// TODO Fix physics simulation to do simulation at high velocities due to bullet through paper problem...
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1638.4f, 13.521004f * 2.0f, 1638.4f);
|
||||||
|
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
|
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") {
|
} else if (info->physicsAsset == "env\\trigger_wall_tall.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 25.0f, 1.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 10.0f, 25.0f, 1.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") {
|
} else if (info->physicsAsset == "env\\env_gen_placeholderphysics.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 20.0f, 20.0f, 20.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 20.0f, 20.0f, 20.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") {
|
} else if (info->physicsAsset == "env\\POI_trigger_wall.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 12.5f, 20.0f); // Not sure what the real size is
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
|
} else if (info->physicsAsset == "env\\NG_NinjaGo\\env_ng_gen_gate_chamber_puzzle_ceiling_tile_falling_phantom.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 18.0f, 5.0f, 15.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f);
|
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 7.5f);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
|
} else if (info->physicsAsset == "env\\NG_NinjaGo\\ng_flamejet_brick_phantom.HKX") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 1.0f, 1.0f, 12.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f);
|
m_dpEntity->SetPosition(m_Position + m_Rotation.GetForwardVector() * 6.0f);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
|
} else if (info->physicsAsset == "env\\Ring_Trigger.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 6.0f, 6.0f, 6.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
|
} else if (info->physicsAsset == "env\\vfx_propertyImaginationBall.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 4.5f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 4.5f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx") {
|
} else if (info->physicsAsset == "env\\env_won_fv_gas-blocking-volume.hkx") {
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 390.496826f, 111.467964f, 600.821534f, true);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_Position.y -= (111.467964f * m_Scale) / 2;
|
m_Position.y -= (111.467964f * m_Scale) / 2;
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
|
||||||
} else {
|
} else {
|
||||||
//Game::logger->Log("PhantomPhysicsComponent", "This one is supposed to have %s", info->physicsAsset.c_str());
|
Game::logger->LogDebug("PhantomPhysicsComponent", "This component is supposed to have asset %s but is defaulting to fallback cube.", info->physicsAsset.c_str());
|
||||||
|
|
||||||
//add fallback cube:
|
//add fallback cube:
|
||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 2.0f, 2.0f, 2.0f);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), 2.0f, 2.0f, 2.0f);
|
||||||
m_dpEntity->SetScale(m_Scale);
|
m_dpEntity->SetScale(m_Scale);
|
||||||
m_dpEntity->SetRotation(m_Rotation);
|
m_dpEntity->SetRotation(m_Rotation);
|
||||||
m_dpEntity->SetPosition(m_Position);
|
m_dpEntity->SetPosition(m_Position);
|
||||||
|
}
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PhantomPhysicsComponent::~PhantomPhysicsComponent() {
|
PhantomPhysicsComponent::~PhantomPhysicsComponent() {
|
||||||
if (m_dpEntity) {
|
if (m_dpEntity) dpWorld::Instance().RemoveEntity(m_dpEntity);
|
||||||
dpWorld::Instance().RemoveEntity(m_dpEntity);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::CreatePhysics() {
|
void PhantomPhysicsComponent::CreatePhysics() {
|
||||||
unsigned char alpha;
|
int32_t type = -1;
|
||||||
unsigned char red;
|
NiPoint3 pos;
|
||||||
unsigned char green;
|
|
||||||
unsigned char blue;
|
|
||||||
int type = -1;
|
|
||||||
float x = 0.0f;
|
|
||||||
float y = 0.0f;
|
|
||||||
float z = 0.0f;
|
|
||||||
float width = 0.0f; //aka "radius"
|
float width = 0.0f; //aka "radius"
|
||||||
float height = 0.0f;
|
float height = 0.0f;
|
||||||
|
|
||||||
if (m_ParentEntity->HasVar(u"primitiveModelType")) {
|
if (m_ParentEntity->HasVar(u"primitiveModelType")) {
|
||||||
type = m_ParentEntity->GetVar<int32_t>(u"primitiveModelType");
|
type = m_ParentEntity->GetVar<int32_t>(u"primitiveModelType");
|
||||||
x = m_ParentEntity->GetVar<float>(u"primitiveModelValueX");
|
pos.x = m_ParentEntity->GetVar<float>(u"primitiveModelValueX");
|
||||||
y = m_ParentEntity->GetVar<float>(u"primitiveModelValueY");
|
pos.y = m_ParentEntity->GetVar<float>(u"primitiveModelValueY");
|
||||||
z = m_ParentEntity->GetVar<float>(u"primitiveModelValueZ");
|
pos.z = m_ParentEntity->GetVar<float>(u"primitiveModelValueZ");
|
||||||
} else {
|
} else {
|
||||||
CDComponentsRegistryTable* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
auto* compRegistryTable = CDClientManager::Instance().GetTable<CDComponentsRegistryTable>();
|
||||||
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
auto componentID = compRegistryTable->GetByIDAndType(m_ParentEntity->GetLOT(), eReplicaComponentType::PHANTOM_PHYSICS);
|
||||||
|
|
||||||
CDPhysicsComponentTable* physComp = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
auto* physCompTable = CDClientManager::Instance().GetTable<CDPhysicsComponentTable>();
|
||||||
|
|
||||||
if (physComp == nullptr) return;
|
if (!physCompTable) return;
|
||||||
|
|
||||||
auto info = physComp->GetByID(componentID);
|
auto info = physCompTable->GetByID(componentID);
|
||||||
|
|
||||||
if (info == nullptr) return;
|
if (!info) return;
|
||||||
|
|
||||||
type = info->pcShapeType;
|
type = info->pcShapeType;
|
||||||
width = info->playerRadius;
|
width = info->playerRadius;
|
||||||
@ -279,8 +194,8 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 1: { //Make a new box shape
|
case 1: { //Make a new box shape
|
||||||
BoxDimensions boxSize(x, y, z);
|
BoxDimensions boxSize(pos.x, pos.y, pos.z);
|
||||||
if (x == 0.0f) {
|
if (pos.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;
|
||||||
if (width < 0.5f) width = 2.0f;
|
if (width < 0.5f) width = 2.0f;
|
||||||
@ -295,11 +210,15 @@ void PhantomPhysicsComponent::CreatePhysics() {
|
|||||||
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), boxSize);
|
m_dpEntity = new dpEntity(m_ParentEntity->GetObjectID(), boxSize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
default: {
|
||||||
|
Game::logger->Log("PhantomPhysicsComponent", "Unknown shape type: %d", type);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_dpEntity) return;
|
if (!m_dpEntity) return;
|
||||||
|
|
||||||
m_dpEntity->SetPosition({ m_Position.x, m_Position.y - (height / 2), m_Position.z });
|
m_dpEntity->SetPosition(NiPoint3(m_Position.x, m_Position.y - (height / 2), m_Position.z));
|
||||||
|
|
||||||
dpWorld::Instance().AddEntity(m_dpEntity);
|
dpWorld::Instance().AddEntity(m_dpEntity);
|
||||||
|
|
||||||
@ -312,12 +231,13 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
|||||||
outBitStream->Write(m_Position.x);
|
outBitStream->Write(m_Position.x);
|
||||||
outBitStream->Write(m_Position.y);
|
outBitStream->Write(m_Position.y);
|
||||||
outBitStream->Write(m_Position.z);
|
outBitStream->Write(m_Position.z);
|
||||||
|
|
||||||
outBitStream->Write(m_Rotation.x);
|
outBitStream->Write(m_Rotation.x);
|
||||||
outBitStream->Write(m_Rotation.y);
|
outBitStream->Write(m_Rotation.y);
|
||||||
outBitStream->Write(m_Rotation.z);
|
outBitStream->Write(m_Rotation.z);
|
||||||
outBitStream->Write(m_Rotation.w);
|
outBitStream->Write(m_Rotation.w);
|
||||||
|
|
||||||
m_PositionInfoDirty = false;
|
if (!bIsInitialUpdate) m_PositionInfoDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
outBitStream->Write(m_EffectInfoDirty || bIsInitialUpdate);
|
outBitStream->Write(m_EffectInfoDirty || bIsInitialUpdate);
|
||||||
@ -328,7 +248,7 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
|||||||
outBitStream->Write(m_EffectType);
|
outBitStream->Write(m_EffectType);
|
||||||
outBitStream->Write(m_DirectionalMultiplier);
|
outBitStream->Write(m_DirectionalMultiplier);
|
||||||
|
|
||||||
// forgive me father for i have sinned
|
// distance info. Option.
|
||||||
outBitStream->Write0();
|
outBitStream->Write0();
|
||||||
//outBitStream->Write(m_MinMax);
|
//outBitStream->Write(m_MinMax);
|
||||||
//if (m_MinMax) {
|
//if (m_MinMax) {
|
||||||
@ -344,7 +264,7 @@ void PhantomPhysicsComponent::Serialize(RakNet::BitStream* outBitStream, bool bI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_EffectInfoDirty = false;
|
if (!bIsInitialUpdate) m_EffectInfoDirty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,28 +277,28 @@ void PhantomPhysicsComponent::Update(float deltaTime) {
|
|||||||
if (!m_dpEntity) return;
|
if (!m_dpEntity) return;
|
||||||
|
|
||||||
//Process enter events
|
//Process enter events
|
||||||
for (auto en : m_dpEntity->GetNewObjects()) {
|
for (auto* en : m_dpEntity->GetNewObjects()) {
|
||||||
m_ParentEntity->OnCollisionPhantom(en->GetObjectID());
|
m_ParentEntity->OnCollisionPhantom(en->GetObjectID());
|
||||||
|
|
||||||
//If we are a respawn volume, inform the client:
|
//If we are a respawn volume, inform the client:
|
||||||
if (m_IsRespawnVolume) {
|
if (!m_IsRespawnVolume) continue;
|
||||||
auto entity = EntityManager::Instance()->GetEntity(en->GetObjectID());
|
auto entity = EntityManager::Instance()->GetEntity(en->GetObjectID());
|
||||||
|
|
||||||
if (entity) {
|
if (!entity) continue;
|
||||||
|
|
||||||
GameMessages::SendPlayerReachedRespawnCheckpoint(entity, m_RespawnPos, m_RespawnRot);
|
GameMessages::SendPlayerReachedRespawnCheckpoint(entity, m_RespawnPos, m_RespawnRot);
|
||||||
entity->SetRespawnPosition(m_RespawnPos);
|
entity->SetRespawnPosition(m_RespawnPos);
|
||||||
entity->SetRespawnRotation(m_RespawnRot);
|
entity->SetRespawnRotation(m_RespawnRot);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Process exit events
|
//Process exit events
|
||||||
for (auto en : m_dpEntity->GetRemovedObjects()) {
|
for (auto* en : m_dpEntity->GetRemovedObjects()) {
|
||||||
m_ParentEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
m_ParentEntity->OnCollisionLeavePhantom(en->GetObjectID());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) {
|
void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) {
|
||||||
|
if (m_Direction == pos) return;
|
||||||
m_Direction = pos;
|
m_Direction = pos;
|
||||||
m_Direction.x *= m_DirectionalMultiplier;
|
m_Direction.x *= m_DirectionalMultiplier;
|
||||||
m_Direction.y *= m_DirectionalMultiplier;
|
m_Direction.y *= m_DirectionalMultiplier;
|
||||||
@ -391,10 +311,11 @@ void PhantomPhysicsComponent::SetDirection(const NiPoint3& pos) {
|
|||||||
void PhantomPhysicsComponent::SpawnVertices() {
|
void PhantomPhysicsComponent::SpawnVertices() {
|
||||||
if (!m_dpEntity) return;
|
if (!m_dpEntity) return;
|
||||||
|
|
||||||
std::cout << m_ParentEntity->GetObjectID() << std::endl;
|
Game::logger->Log("PhantomPhysicsComponent", "objectId is %llu", m_ParentEntity->GetObjectID());
|
||||||
auto box = static_cast<dpShapeBox*>(m_dpEntity->GetShape());
|
auto box = dynamic_cast<dpShapeBox*>(m_dpEntity->GetShape());
|
||||||
|
if (!box) return;
|
||||||
for (auto vert : box->GetVertices()) {
|
for (auto vert : box->GetVertices()) {
|
||||||
std::cout << vert.x << ", " << vert.y << ", " << vert.z << std::endl;
|
Game::logger->Log("PhantomPhysicsComponent", "%f, %f, %f", vert.x, vert.y, vert.z);
|
||||||
|
|
||||||
EntityInfo info;
|
EntityInfo info;
|
||||||
info.lot = 33;
|
info.lot = 33;
|
||||||
@ -403,41 +324,47 @@ void PhantomPhysicsComponent::SpawnVertices() {
|
|||||||
info.spawnerID = m_ParentEntity->GetObjectID();
|
info.spawnerID = m_ParentEntity->GetObjectID();
|
||||||
info.spawnerNodeID = 0;
|
info.spawnerNodeID = 0;
|
||||||
|
|
||||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
Entity* newEntity = EntityManager::Instance()->CreateEntity(info);
|
||||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetDirectionalMultiplier(float mul) {
|
void PhantomPhysicsComponent::SetDirectionalMultiplier(float mul) {
|
||||||
|
if (mul == m_DirectionalMultiplier) return;
|
||||||
m_DirectionalMultiplier = mul;
|
m_DirectionalMultiplier = mul;
|
||||||
m_EffectInfoDirty = true;
|
m_EffectInfoDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetEffectType(ePhysicsEffectType type) {
|
void PhantomPhysicsComponent::SetEffectType(const ePhysicsEffectType type) {
|
||||||
|
if (type == m_EffectType) return;
|
||||||
m_EffectType = type;
|
m_EffectType = type;
|
||||||
m_EffectInfoDirty = true;
|
m_EffectInfoDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetMin(uint32_t min) {
|
void PhantomPhysicsComponent::SetMin(const uint32_t min) {
|
||||||
|
if (min == m_Min) return;
|
||||||
m_Min = min;
|
m_Min = min;
|
||||||
m_MinMax = true;
|
m_MinMax = true;
|
||||||
m_EffectInfoDirty = true;
|
m_EffectInfoDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetMax(uint32_t max) {
|
void PhantomPhysicsComponent::SetMax(const uint32_t max) {
|
||||||
|
if (max == m_Max) return;
|
||||||
m_Max = max;
|
m_Max = max;
|
||||||
m_MinMax = true;
|
m_MinMax = true;
|
||||||
m_EffectInfoDirty = true;
|
m_EffectInfoDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetPosition(const NiPoint3& pos) {
|
void PhantomPhysicsComponent::SetPosition(const NiPoint3& pos) {
|
||||||
|
if (pos == m_Position) return;
|
||||||
m_Position = pos;
|
m_Position = pos;
|
||||||
|
m_PositionInfoDirty = true;
|
||||||
if (m_dpEntity) m_dpEntity->SetPosition(pos);
|
if (m_dpEntity) m_dpEntity->SetPosition(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhantomPhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
void PhantomPhysicsComponent::SetRotation(const NiQuaternion& rot) {
|
||||||
|
if (rot == m_Rotation) return;
|
||||||
m_Rotation = rot;
|
m_Rotation = rot;
|
||||||
|
m_PositionInfoDirty = true;
|
||||||
if (m_dpEntity) m_dpEntity->SetRotation(rot);
|
if (m_dpEntity) m_dpEntity->SetRotation(rot);
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
* Darkflame Universe
|
* Darkflame Universe
|
||||||
* Copyright 2018
|
* Copyright 2023
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "NiPoint3.h"
|
|
||||||
#include "NiQuaternion.h"
|
|
||||||
#include "BitStream.h"
|
|
||||||
#include <vector>
|
|
||||||
#include "CppScripts.h"
|
|
||||||
#include "InvalidScript.h"
|
|
||||||
#include "Component.h"
|
#include "Component.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
|
|
||||||
class LDFBaseData;
|
class LDFBaseData;
|
||||||
class Entity;
|
class Entity;
|
||||||
class dpEntity;
|
class dpEntity;
|
||||||
|
class NiPoint3;
|
||||||
|
class NiQuaternion;
|
||||||
enum class ePhysicsEffectType : uint32_t ;
|
enum class ePhysicsEffectType : uint32_t ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +106,7 @@ public:
|
|||||||
* Sets the effect that's currently active
|
* Sets the effect that's currently active
|
||||||
* @param type the effect to set
|
* @param type the effect to set
|
||||||
*/
|
*/
|
||||||
void SetEffectType(ePhysicsEffectType type);
|
void SetEffectType(const ePhysicsEffectType type);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the Physics entity for the component
|
* Returns the Physics entity for the component
|
||||||
@ -127,12 +123,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Legacy stuff no clue what this does
|
* Legacy stuff no clue what this does
|
||||||
*/
|
*/
|
||||||
void SetMin(uint32_t min);
|
void SetMin(const uint32_t min);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legacy stuff no clue what this does
|
* Legacy stuff no clue what this does
|
||||||
*/
|
*/
|
||||||
void SetMax(uint32_t max);
|
void SetMax(const uint32_t max);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -81,6 +81,8 @@
|
|||||||
#include "CDObjectSkillsTable.h"
|
#include "CDObjectSkillsTable.h"
|
||||||
#include "CDObjectsTable.h"
|
#include "CDObjectsTable.h"
|
||||||
#include "CDSkillBehaviorTable.h"
|
#include "CDSkillBehaviorTable.h"
|
||||||
|
#include "CppScripts.h"
|
||||||
|
#include "InvalidScript.h"
|
||||||
|
|
||||||
const std::vector<ComponentWhitelist> Entity::m_ComponentWhitelists = {
|
const std::vector<ComponentWhitelist> Entity::m_ComponentWhitelists = {
|
||||||
{ // Unknown use case
|
{ // Unknown use case
|
||||||
|
Loading…
Reference in New Issue
Block a user