Destroyable

This commit is contained in:
David Markowitz 2023-06-10 05:10:00 -07:00
parent b91f84d884
commit 0b5df9f0b1
2 changed files with 29 additions and 21 deletions

View File

@ -185,13 +185,13 @@ void Entity::ApplyComponentWhitelist(TemplateComponents& components) const {
void Entity::ApplyComponentBlacklist(TemplateComponents& components) const {
bool hasPetComponent = std::find_if(components.begin(), components.end(), [](const auto& componentCandidate) {
return componentCandidate.first == eReplicaComponentType::PET;
}) != components.end();
if (hasPetComponent) {
auto toRemove = std::remove_if(components.begin(), components.end(), [](const auto& componentCandidate) {
return componentCandidate.first == eReplicaComponentType::MODEL_BEHAVIOR || componentCandidate.first == eReplicaComponentType::ITEM;
});
components.erase(toRemove, components.end());
}
}) != components.end();
if (hasPetComponent) {
auto toRemove = std::remove_if(components.begin(), components.end(), [](const auto& componentCandidate) {
return componentCandidate.first == eReplicaComponentType::MODEL_BEHAVIOR || componentCandidate.first == eReplicaComponentType::ITEM;
});
components.erase(toRemove, components.end());
}
}
void Entity::ApplyComponentConfig(TemplateComponents& components) const {
@ -253,6 +253,9 @@ void Entity::Initialize() {
case eReplicaComponentType::BOUNCER:
AddComponent<BouncerComponent>();
break;
case eReplicaComponentType::DESTROYABLE:
AddComponent<DestroyableComponent>();
break;
case eReplicaComponentType::SKILL:
AddComponent<SkillComponent>();
break;
@ -273,6 +276,7 @@ void Entity::Initialize() {
break;
case eReplicaComponentType::COLLECTIBLE:
AddComponent<CollectibleComponent>();
AddComponent<DestroyableComponent>();
break;
case eReplicaComponentType::MOVING_PLATFORM:
AddComponent<MovingPlatformComponent>(GetVarAsString(u"attached_path"));
@ -301,6 +305,10 @@ void Entity::Initialize() {
case eReplicaComponentType::PROPERTY_MANAGEMENT:
AddComponent<PropertyManagementComponent>();
break;
case eReplicaComponentType::QUICK_BUILD:
AddComponent<QuickBuildComponent>();
AddComponent<DestroyableComponent>();
break;
case eReplicaComponentType::SWITCH:
AddComponent<SwitchComponent>();
break;
@ -337,6 +345,7 @@ void Entity::Initialize() {
case eReplicaComponentType::MULTI_ZONE_ENTRANCE:
AddComponent<MultiZoneEntranceComponent>();
break;
case eReplicaComponentType::BUFF:
AddComponent<BuffComponent>();
break;
@ -350,7 +359,6 @@ void Entity::Initialize() {
AddComponent<BuildBorderComponent>();
break;
case eReplicaComponentType::SCRIPT:
case eReplicaComponentType::DESTROYABLE:
case eReplicaComponentType::GHOST:
case eReplicaComponentType::SPAWN:
case eReplicaComponentType::MODULAR_BUILD:
@ -375,7 +383,7 @@ void Entity::Initialize() {
case eReplicaComponentType::FX:
case eReplicaComponentType::VEHICLE_PHYSICS:
case eReplicaComponentType::PHYSICS_SYSTEM:
case eReplicaComponentType::QUICK_BUILD:
case eReplicaComponentType::CHANGLING_BUILD:
case eReplicaComponentType::CHOICE_BUILD:
case eReplicaComponentType::PACKAGE:

View File

@ -191,24 +191,24 @@
* Multiple components require the destructible component.
*/
int buffComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::BUFF);
int quickBuildComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD);
// int destroyableComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::DESTROYABLE);
// int quickBuildComponentID = compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::QUICK_BUILD);
int componentID = 0;
if (collectibleComponentID > 0) componentID = collectibleComponentID;
if (quickBuildComponentID > 0) componentID = quickBuildComponentID;
if (buffComponentID > 0) componentID = buffComponentID;
// int componentID = 0;
// if (collectibleComponentID > 0) componentID = collectibleComponentID;
// if (quickBuildComponentID > 0) componentID = quickBuildComponentID;
// if (destroyableComponentID > 0) componentID = destroyableComponentID;
CDDestructibleComponentTable* destCompTable = CDClientManager::Instance().GetTable<CDDestructibleComponentTable>();
std::vector<CDDestructibleComponent> destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); });
// CDDestructibleComponentTable* destCompTable = CDClientManager::Instance().GetTable<CDDestructibleComponentTable>();
// std::vector<CDDestructibleComponent> destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); });
if (buffComponentID > 0 || collectibleComponentID > 0) {
DestroyableComponent* comp = new DestroyableComponent(this);
// if (destroyableComponentID > 0 || collectibleComponentID > 0) {
// DestroyableComponent* comp = new DestroyableComponent(this);
if (m_Character) {
comp->LoadFromXml(m_Character->GetXMLDoc());
} else {
if (componentID > 0) {
std::vector<CDDestructibleComponent> destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); });
// std::vector<CDDestructibleComponent> destCompData = destCompTable->Query([=](CDDestructibleComponent entry) { return (entry.id == componentID); });
if (destCompData.size() > 0) {
if (HasComponent(eReplicaComponentType::RACING_STATS)) {
@ -274,7 +274,7 @@
}
}
m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, comp));
// m_Components.insert(std::make_pair(eReplicaComponentType::DESTROYABLE, comp));
}
// if (compRegistryTable->GetByIDAndType(m_TemplateID, eReplicaComponentType::CHARACTER) > 0 || m_Character) {