mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-10 18:28:21 +00:00
e524b86e12
* breakout the component types into a scoped enum tested that things are the same as they were before * fix missed rename * fix brick-by-brick name to be crafting because that's what it is
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
#include "AgImagSmashable.h"
|
|
#include "EntityManager.h"
|
|
#include "GeneralUtils.h"
|
|
#include "GameMessages.h"
|
|
#include "EntityInfo.h"
|
|
#include "DestroyableComponent.h"
|
|
#include "eReplicaComponentType.h"
|
|
|
|
void AgImagSmashable::OnDie(Entity* self, Entity* killer) {
|
|
bool maxImagGreaterThanZero = false;
|
|
|
|
if (killer) {
|
|
DestroyableComponent* dest = static_cast<DestroyableComponent*>(killer->GetComponent(eReplicaComponentType::DESTROYABLE));
|
|
if (dest) {
|
|
maxImagGreaterThanZero = dest->GetMaxImagination() > 0;
|
|
}
|
|
|
|
if (maxImagGreaterThanZero) {
|
|
int amount = GeneralUtils::GenerateRandomNumber<int>(0, 3);
|
|
for (int i = 0; i < amount; ++i) {
|
|
GameMessages::SendDropClientLoot(killer, self->GetObjectID(), 935, 0, self->GetPosition());
|
|
}
|
|
}
|
|
}
|
|
|
|
CrateAnimal(self);
|
|
}
|
|
|
|
void AgImagSmashable::CrateAnimal(Entity* self) {
|
|
int funnychance = GeneralUtils::GenerateRandomNumber<int>(0, 26);
|
|
if (funnychance == 1) {
|
|
EntityInfo info;
|
|
info.lot = 8114;
|
|
info.pos = self->GetPosition();
|
|
info.spawner = nullptr;
|
|
info.spawnerID = self->GetSpawnerID();
|
|
info.spawnerNodeID = 0;
|
|
|
|
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
|
if (newEntity) {
|
|
EntityManager::Instance()->ConstructEntity(newEntity);
|
|
}
|
|
}
|
|
}
|