Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/voxel/specialvoxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ SpecialVoxel::SpecialVoxel(const glm::ivec3& gridCell, int group, uint32_t color
int SpecialVoxel::group() const {
return m_group;
}

SpecialVoxel* SpecialVoxel::clone() const {
return new SpecialVoxel(*this);
}

2 changes: 2 additions & 0 deletions src/voxel/specialvoxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ class SpecialVoxel: public Voxel {

int group() const;

virtual SpecialVoxel* clone() const override;


protected:
int m_group;
Expand Down
14 changes: 7 additions & 7 deletions src/voxel/specialvoxels/cockpitvoxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ CockpitVoxel::CockpitVoxel(const glm::ivec3& gridCell, int index):
{
}

CockpitVoxel::CockpitVoxel(const CockpitVoxel& other):
SpecialVoxel(other)
{
}

void CockpitVoxel::addToObject(WorldObject* worldObject) {
Voxel::addToObject(worldObject);
worldObject->addCockpitVoxel(m_gridCell);
}

void CockpitVoxel::onRemoval() {
//TODO: Tell my cockpit I'm gone
}

void CockpitVoxel::onDestruction() {
Voxel::onDestruction();
// Spawn dead pilot
CockpitVoxel* CockpitVoxel::clone() const {
return new CockpitVoxel(*this);
}

4 changes: 2 additions & 2 deletions src/voxel/specialvoxels/cockpitvoxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
class CockpitVoxel: public SpecialVoxel {
public:
CockpitVoxel(const glm::ivec3& gridCell, int index);
CockpitVoxel(const CockpitVoxel& other);

virtual void addToObject(WorldObject* object) override;

virtual void onRemoval() override;
virtual void onDestruction() override;
virtual CockpitVoxel* clone() const override;
};

8 changes: 2 additions & 6 deletions src/voxel/specialvoxels/crucialvoxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ void CrucialVoxel::addToObject(WorldObject* worldObject){
worldObject->setCrucialVoxel(m_gridCell);
}

void CrucialVoxel::onRemoval(){
//TODO: Destroy ship / make wreckage?
}

void CrucialVoxel::onDestruction(){
Voxel::onDestruction();
CrucialVoxel* CrucialVoxel::clone() const {
return new CrucialVoxel(*this);
}

4 changes: 2 additions & 2 deletions src/voxel/specialvoxels/crucialvoxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class CrucialVoxel: public SpecialVoxel {

virtual void addToObject(WorldObject* worldObject) override;

virtual void onRemoval() override;
virtual void onDestruction() override;
virtual CrucialVoxel* clone() const override;
};

15 changes: 11 additions & 4 deletions src/voxel/specialvoxels/engineslotvoxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

#include "property/property.h"

#include "voxel/voxelcluster.h"

#include "equipment/engine.h"
#include "equipment/engineslot.h"

#include "voxel/voxelcluster.h"

#include "worldobject/worldobject.h"
#include "worldobject/worldobjectcomponents.h"

Expand All @@ -16,6 +17,12 @@ EngineSlotVoxel::EngineSlotVoxel(const glm::ivec3& gridCell, int index):
{
}

EngineSlotVoxel::EngineSlotVoxel(const EngineSlotVoxel& other):
SpecialVoxel(other)
{
// m_engineSlot remains nullptr
}

void EngineSlotVoxel::addToObject(WorldObject* worldObject) {
Voxel::addToObject(worldObject);
m_engineSlot = std::make_shared<EngineSlot>(&worldObject->components(), this);
Expand All @@ -36,7 +43,7 @@ void EngineSlotVoxel::onRemoval() {
Voxel::onRemoval();
}

void EngineSlotVoxel::onDestruction() {
Voxel::onDestruction();
EngineSlotVoxel* EngineSlotVoxel::clone() const {
return new EngineSlotVoxel(*this);
}

4 changes: 3 additions & 1 deletion src/voxel/specialvoxels/engineslotvoxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class EngineSlot;
class EngineSlotVoxel: public SpecialVoxel {
public:
EngineSlotVoxel(const glm::ivec3& gridCell, int index);
EngineSlotVoxel(const EngineSlotVoxel& other);

virtual Visuals visuals() const override;

virtual void addToObject(WorldObject* worldObject) override;

virtual void onRemoval() override;
virtual void onDestruction() override;

virtual EngineSlotVoxel* clone() const override;


protected:
Expand Down
12 changes: 6 additions & 6 deletions src/voxel/specialvoxels/fuelvoxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
#include "voxel/voxeltree.h"
#include "voxel/voxeltreenode.h"

#include "worldobject/worldobject.h"

#include "voxeleffect/voxelexplosiongenerator.h"

#include "worldobject/worldobject.h"


FuelVoxel::FuelVoxel(const glm::ivec3& gridCell, int index):
SpecialVoxel(gridCell, index, Property<uint32_t>::get("voxels.fuel.color"), Property<float>::get("voxels.fuel.density"), Property<float>::get("voxels.fuel.hp"))
Expand All @@ -24,10 +24,6 @@ float FuelVoxel::damageForwardingDestructionDamage() {
return 100.0f;
}

void FuelVoxel::onRemoval() {

}

void FuelVoxel::onDestruction() {
Voxel::onDestruction();

Expand All @@ -46,3 +42,7 @@ void FuelVoxel::onDestruction() {
generator.spawn();
}

FuelVoxel* FuelVoxel::clone() const {
return new FuelVoxel(*this);
}

3 changes: 2 additions & 1 deletion src/voxel/specialvoxels/fuelvoxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class FuelVoxel: public SpecialVoxel {

virtual float damageForwardingDestructionDamage() override;

virtual void onRemoval() override;
virtual void onDestruction() override;

virtual FuelVoxel* clone() const override;
};

11 changes: 8 additions & 3 deletions src/voxel/specialvoxels/hardpointvoxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ HardpointVoxel::HardpointVoxel(const glm::ivec3& gridCell, int index):

}

HardpointVoxel::HardpointVoxel(const HardpointVoxel& other):
SpecialVoxel(other)
{
// m_hardpoint remains a nullptr
}

Visuals HardpointVoxel::visuals() const {
return Visuals(
m_hardpoint->weapon() ? m_hardpoint->weapon()->visuals() : Voxel::visuals()
Expand All @@ -38,8 +44,7 @@ void HardpointVoxel::onRemoval() {
Voxel::onRemoval();
}

void HardpointVoxel::onDestruction() {
//Drop Ammo?
Voxel::onDestruction();
HardpointVoxel* HardpointVoxel::clone() const {
return new HardpointVoxel(*this);
}

4 changes: 3 additions & 1 deletion src/voxel/specialvoxels/hardpointvoxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class Hardpoint;
class HardpointVoxel: public SpecialVoxel {
public:
HardpointVoxel(const glm::ivec3& gridCell, int index);
HardpointVoxel(const HardpointVoxel& other);

virtual Visuals visuals() const override;

virtual void addToObject(WorldObject* object) override;

virtual void onRemoval() override;
virtual void onDestruction() override;

virtual HardpointVoxel* clone() const override;


protected:
Expand Down
4 changes: 4 additions & 0 deletions src/voxel/voxel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ float Voxel::density() const {
return m_density;
}

Voxel* Voxel::clone() const {
return new Voxel(*this);
}

void Voxel::onRemoval() {

}
Expand Down
4 changes: 3 additions & 1 deletion src/voxel/voxel.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Voxel {
Voxel(const Voxel& other);
virtual ~Voxel();

const glm::ivec3 &gridCell() const;
const glm::ivec3& gridCell() const;

glm::vec3 position() const;

Expand All @@ -37,6 +37,8 @@ class Voxel {

float density() const;

virtual Voxel* clone() const;

// These hooks apply only for WorldObjects and do not need to be called by pure VoxelClusters
virtual void onRemoval();
virtual void onDestruction();
Expand Down
12 changes: 8 additions & 4 deletions src/world/handler/wrecker.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#include "wrecker.h"

#include "physics/physics.h"

#include "voxel/voxel.h"

#include "world/helper/worldobjectmodification.h"

#include "worldobject/worldobject.h"
#include "worldobject/worldobjectinfo.h"
#include "physics/physics.h"
#include "voxel/voxel.h"


void Wrecker::detectWreckedObjects(std::list<WorldObjectModification>& worldObjectModifications) {
m_wreckedObjects.clear();
Expand All @@ -17,7 +21,6 @@ void Wrecker::detectWreckedObjects(std::list<WorldObjectModification>& worldObje
m_newWreckages.push_back(wreckFromObject(object));
}
}

}

std::list<WorldObject*>& Wrecker::wreckedObjects() {
Expand All @@ -35,8 +38,9 @@ WorldObject* Wrecker::wreckFromObject(WorldObject* object) {
wreckage->physics().setSpeed(object->physics().speed());

for (auto& pair : object->voxelMap()) {
wreckage->addVoxel(new Voxel(*pair.second));
wreckage->addVoxel(pair.second->clone());
}

return wreckage;
}