format codebase

This commit is contained in:
aronwk-aaron
2022-07-28 08:39:57 -05:00
parent 4f7aa11067
commit 19e77a38d8
881 changed files with 34700 additions and 38689 deletions

View File

@@ -7,15 +7,14 @@ SwitchComponent::SwitchComponent(Entity* parent) : Component(parent) {
m_Active = false;
m_ResetTime = m_Parent->GetVarAs<int32_t>(u"switch_reset_time");
m_Rebuild = m_Parent->GetComponent<RebuildComponent>();
}
SwitchComponent::~SwitchComponent() {
const auto& iterator = std::find(petSwitches.begin(), petSwitches.end(), this);
if (iterator != petSwitches.end())
{
if (iterator != petSwitches.end()) {
petSwitches.erase(iterator);
}
}
@@ -27,14 +26,12 @@ void SwitchComponent::Serialize(RakNet::BitStream* outBitStream, bool bIsInitial
void SwitchComponent::SetActive(bool active) {
m_Active = active;
if (m_PetBouncer != nullptr)
{
if (m_PetBouncer != nullptr) {
m_PetBouncer->SetPetBouncerEnabled(active);
}
}
bool SwitchComponent::GetActive() const
{
bool SwitchComponent::GetActive() const {
return m_Active;
}
@@ -49,85 +46,71 @@ void SwitchComponent::EntityEnter(Entity* entity) {
const auto grpName = m_Parent->GetVarAsString(u"grp_name");
if (!grpName.empty())
{
if (!grpName.empty()) {
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
for (auto* entity : entities)
{
for (auto* entity : entities) {
entity->OnFireEventServerSide(entity, "OnActivated");
}
}
m_Timer = m_ResetTime;
if (m_PetBouncer != nullptr)
{
if (m_PetBouncer != nullptr) {
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 2602, u"pettriggeractive", "BounceEffect", LWOOBJID_EMPTY, 1, 1, true);
GameMessages::SendPlayAnimation(m_Parent, u"engaged", 0, 1);
m_PetBouncer->SetPetBouncerEnabled(true);
}
else
{
} else {
EntityManager::Instance()->SerializeEntity(m_Parent);
}
}
}
void SwitchComponent::EntityLeave(Entity* entity) {
}
void SwitchComponent::Update(float deltaTime) {
if (m_Active) {
m_Timer -= deltaTime;
if (m_Timer <= 0.0f) {
m_Active = false;
if (!m_Parent) return;
m_Parent->TriggerEvent("OnDectivated");
const auto grpName = m_Parent->GetVarAsString(u"grp_name");
if (!grpName.empty())
{
if (!grpName.empty()) {
const auto entities = EntityManager::Instance()->GetEntitiesInGroup(grpName);
for (auto* entity : entities)
{
for (auto* entity : entities) {
entity->OnFireEventServerSide(entity, "OnDectivated");
}
}
if (m_PetBouncer != nullptr)
{
if (m_PetBouncer != nullptr) {
m_PetBouncer->SetPetBouncerEnabled(false);
}
else
{
} else {
EntityManager::Instance()->SerializeEntity(m_Parent);
}
}
}
}
Entity* SwitchComponent::GetParentEntity() const
{
Entity* SwitchComponent::GetParentEntity() const {
return m_Parent;
}
SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position)
{
SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position) {
float closestDistance = 0;
SwitchComponent* closest = nullptr;
for (SwitchComponent* petSwitch : petSwitches)
{
for (SwitchComponent* petSwitch : petSwitches) {
float distance = Vector3::DistanceSquared(petSwitch->m_Parent->GetPosition(), position);
if (closest == nullptr || distance < closestDistance)
{
if (closest == nullptr || distance < closestDistance) {
closestDistance = distance;
closest = petSwitch;
}
@@ -137,18 +120,15 @@ SwitchComponent* SwitchComponent::GetClosestSwitch(NiPoint3 position)
}
void SwitchComponent::SetPetBouncer(BouncerComponent* value)
{
void SwitchComponent::SetPetBouncer(BouncerComponent* value) {
m_PetBouncer = value;
if (value != nullptr)
{
if (value != nullptr) {
m_PetBouncer->SetPetEnabled(true);
petSwitches.push_back(this);
}
}
BouncerComponent* SwitchComponent::GetPetBouncer() const
{
BouncerComponent* SwitchComponent::GetPetBouncer() const {
return m_PetBouncer;
}