Skip to content

Commit

Permalink
Fix a whole heap of problems with mines
Browse files Browse the repository at this point in the history
  • Loading branch information
daid committed Dec 21, 2024
1 parent 2e32486 commit 1bf3431
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class ExplodeOnTimeout
class DelayedExplodeOnTouch : public ExplodeOnTouch
{
public:
float trigger_holdoff_delay = 1.0f;
float delay = 1.0f;
bool triggered = false;
};
Expand Down
14 changes: 9 additions & 5 deletions src/systems/missilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ void MissileSystem::update(float delta)
}

for(auto [entity, flight, transform, physics] : sp::ecs::Query<MissileFlight, sp::Transform, sp::Physics>()) {
physics.setVelocity(vec2FromAngle(transform.getRotation()) * flight.speed);
if (flight.timeout > 0.0f) {
flight.timeout -= delta;
if (flight.timeout <= 0.0f && game_server) {
entity.removeComponent<MissileFlight>();
physics.setVelocity({0.0f, 0.0f});
}
}
physics.setVelocity(vec2FromAngle(transform.getRotation()) * flight.speed);
}

for(auto [entity, homing, transform, physics] : sp::ecs::Query<MissileHoming, sp::Transform, sp::Physics>()) {
Expand Down Expand Up @@ -106,6 +107,7 @@ void MissileSystem::update(float delta)

if (game_server) {
for(auto [entity, deot, transform] : sp::ecs::Query<DelayedExplodeOnTouch, sp::Transform>()) {
if (deot.trigger_holdoff_delay > 0.0f) deot.trigger_holdoff_delay -= delta;
if (!deot.triggered) continue;
deot.delay -= delta;
if (deot.delay >= 0.0f) continue;
Expand Down Expand Up @@ -134,7 +136,7 @@ void MissileSystem::collision(sp::ecs::Entity a, sp::ecs::Entity b, float force)
{
if (!game_server) return;
auto deot = a.getComponent<DelayedExplodeOnTouch>();
if (deot) {
if (deot && deot->trigger_holdoff_delay <= 0.0f) {
auto hull = b.getComponent<Hull>();
if (!hull) return;
deot->triggered = true;
Expand Down Expand Up @@ -239,6 +241,7 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
if (!source_transform) return;
auto fireLocation = source_transform->getPosition() + rotateVec2(glm::vec2(tube.position), source_transform->getRotation());
auto category_modifier = MissileWeaponData::convertSizeToCategoryModifier(tube.size);
auto& mwd = MissileWeaponData::getDataFor(tube.type_loaded);

sp::ecs::Entity missile;
switch(tube.type_loaded)
Expand Down Expand Up @@ -272,6 +275,7 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
{
missile = sp::ecs::Entity::create();
auto& mc = missile.addComponent<DelayedExplodeOnTouch>();
mc.trigger_holdoff_delay = mwd.lifetime;
mc.delay = 1.0f;
mc.owner = source;
mc.damage_at_center = 160.0f * category_modifier;
Expand Down Expand Up @@ -315,7 +319,6 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
else
physics.setRectangle(sp::Physics::Type::Sensor, {10, 30});

auto& mwd = MissileWeaponData::getDataFor(tube.type_loaded);
auto& mf = missile.addComponent<MissileFlight>();
mf.speed = mwd.speed / category_modifier;
if (tube.type_loaded == MW_Mine)
Expand All @@ -333,7 +336,7 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
auto& t = missile.addComponent<sp::Transform>();
t.setPosition(fireLocation);
t.setRotation(source_transform->getRotation() + tube.direction);
auto cpe = missile.addComponent<ConstantParticleEmitter>();
auto& cpe = missile.addComponent<ConstantParticleEmitter>();
if (tube.type_loaded == MW_Mine) {
cpe.travel_random_range = 100.0f;
cpe.start_color = {1, 1, 1};
Expand All @@ -344,7 +347,8 @@ void MissileSystem::spawnProjectile(sp::ecs::Entity source, MissileTubes::MountP
cpe.life_time = 10.0f;
}

missile.addComponent<LifeTime>().lifetime = mwd.lifetime / category_modifier;
if (tube.type_loaded != MW_Mine)
missile.addComponent<LifeTime>().lifetime = mwd.lifetime / category_modifier;

if (tube.type_loaded != MW_Mine) {
auto& dbad = missile.addComponent<DestroyedByAreaDamage>();
Expand Down

1 comment on commit 1bf3431

@daid-tinyci
Copy link

@daid-tinyci daid-tinyci bot commented on 1bf3431 Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinyCI build failure:

[/home/tinyci/builds/daid/EmptyEpsilon/_build_native:cmake .. -G Ninja -DSERIOUS_PROTON_DIR=../../SeriousProton -DCMAKE_BUILD_TYPE=RelWithDebInfo] returned [1]:


-- GLM version used: BUNDLED

-- opus version used: BUNDLED

-- Freetype 2 version used: BUNDLED

-- Not using steam SDK

-- Configuring done

CMake Error at CMakeLists.txt:672 (add_executable):

  Cannot find source file:



    src/screenComponents/infoDisplay.cpp



  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h

  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc





-- Generating done

CMake Generate step failed.  Build files cannot be regenerated correctly.

Please sign in to comment.