Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft - Lib Component #810

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
2701083
Fix bug - Store::Subtract adds quantity instead of subtracting it
royfalk Jan 23, 2023
7e0e45f
Merge from master
royfalk Feb 3, 2023
0cb1a73
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Apr 25, 2023
c6dba50
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk May 30, 2023
b2d8681
Merge branch 'master' of https://github.com/vegastrike/Vega-Strike-En…
royfalk Jul 30, 2023
8668683
Refactor cloaking in the game
royfalk Aug 31, 2023
e38f3fa
Move cloak code from unit_csv to cloak class
royfalk Oct 10, 2023
0dd2465
Add missing return statement
royfalk Oct 11, 2023
e74dd23
Merge branch 'task_aug_unit' into task_almost_september
royfalk Oct 17, 2023
c663324
Implement radar code as a separate component
royfalk Oct 17, 2023
7c357ba
Fix bug in the radar where small ships are not tracked.
royfalk Oct 26, 2023
474e401
Merge branch 'task_almost_september' into task_october
royfalk Oct 26, 2023
9d5551e
Introduce lib_component
royfalk Nov 10, 2023
2c0e12b
Refactor resource class
royfalk Mar 12, 2024
fec840e
Introduce armor hull and shield components
royfalk Mar 22, 2024
f509220
Move regeneration from health to shield
royfalk Mar 24, 2024
a4a8a7d
Further work on Armor class
royfalk Mar 26, 2024
ab8538a
Make Shield a super class of DamageableLayer
royfalk Mar 27, 2024
799a732
Make armor class a superclass of DamageableLayer
royfalk Mar 29, 2024
77d3dab
Make Hull a superclass of DamageableLayer
royfalk Mar 29, 2024
019b507
Add fuel component
royfalk Apr 10, 2024
7f53ea9
Implement afterburners and Drive
royfalk Apr 18, 2024
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
6 changes: 6 additions & 0 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -663,12 +663,17 @@ SET(LIBCOMPONENT
src/components/component.cpp
src/components/energy_types.cpp

src/components/armor.cpp
src/components/hull.cpp
src/components/shield.cpp

src/components/afterburner.cpp
src/components/cloak.cpp
src/components/drive.cpp
src/components/energy_consumer.cpp
src/components/energy_container.cpp
src/components/energy_manager.cpp
src/components/fuel.cpp
src/components/jump_drive.cpp
src/components/radar.cpp
src/components/reactor.cpp
Expand Down Expand Up @@ -1639,6 +1644,7 @@ IF (USE_GTEST)
src/exit_unit_tests.cpp
src/components/tests/energy_container_tests.cpp
src/components/tests/balancing_tests.cpp
src/components/tests/armor_tests.cpp
)

ADD_LIBRARY(vegastrike-testing
Expand Down
4 changes: 2 additions & 2 deletions engine/src/cmd/ai/docking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ bool DockingOps::DockToTarget(Unit *utdw) {
if (physicallyDock) {
return parent->Dock(utdw);
} else {
utdw->energy_manager.Refill(EnergyType::SPEC);
utdw->ftl_energy.Refill();
return true;
}
} else if (diss <= 1.2 * rad * rad) {
Expand All @@ -216,7 +216,7 @@ bool DockingOps::DockToTarget(Unit *utdw) {
if (physicallyDock) {
return parent->Dock(utdw);
} else {
parent->energy_manager.Refill(EnergyType::SPEC);
parent->ftl_energy.Refill();
return true;
}
}
Expand Down
2 changes: 1 addition & 1 deletion engine/src/cmd/ai/firekeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1731,7 +1731,7 @@ void FireKeyboard::Execute() {

float f_result = f().shieldpowerstate;
if (f_result != 1) {
parent->shield->AdjustPower(f_result);
parent->shield->SetPower(f_result);
}
if (f().firekey == PRESS || f().jfirekey == PRESS || j().firekey == DOWN || j().jfirekey == DOWN) {
if (!_Universe->AccessCockpit()->CanDrawNavSystem()) {
Expand Down
2 changes: 1 addition & 1 deletion engine/src/cmd/ai/warpto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ static void ActuallyWarpTo(Unit *parent, const QVector &tarpos, Vector tarvel, U
XMLSupport::parse_float(vs_config->getVariable("AI", "min_energy_to_enter_warp", ".33"));
static float min_warpfield_to_enter_warp =
XMLSupport::parse_float(vs_config->getVariable("AI", "min_warp_to_try", "1.5"));
if ((parent->energy_manager.Percent(EnergyType::SPEC) > min_energy_to_enter_warp)
if ((parent->ftl_energy.Percent() > min_energy_to_enter_warp)
&& (parent->GetMaxWarpFieldStrength(1) > min_warpfield_to_enter_warp)) {
if (parent->graphicOptions.InWarp == 0) {
parent->graphicOptions.InWarp = 1; //don't want the AI thrashing
Expand Down
8 changes: 4 additions & 4 deletions engine/src/cmd/armed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,14 @@ void Armed::Fire(unsigned int weapon_type_bitmask, bool listen_to_owner) {
//&& ( (ROLES::EVERYTHING_ELSE&weapon_type_bitmask&i->type->role_bits) || i->type->role_bits == 0 )
((locked_on && missile_and_want_to_fire_missiles) || gun_and_want_to_fire_guns);
if ((*i).type->type == WEAPON_TYPE::BEAM) {
if ((*i).type->GetConsumption() * simulation_atom_var > unit->energy_manager.GetLevel(EnergyType::Energy)) {
if ((*i).type->GetConsumption() * simulation_atom_var > unit->energy.Level()) {
//NOT ONLY IN non-networking mode : anyway, the server will tell everyone including us to stop if not already done
(*i).UnFire();
continue;
}
} else
//Only in non-networking mode
if (i->type->GetConsumption() > unit->energy_manager.GetLevel(EnergyType::Energy)) {
if (i->type->GetConsumption() > unit->energy.Level()) {
if (!want_to_fire) {
i->UnFire();
}
Expand All @@ -279,11 +279,11 @@ void Armed::Fire(unsigned int weapon_type_bitmask, bool listen_to_owner) {
if (i->ref.gun) {
if ((!i->ref.gun->Dissolved()) || i->ref.gun->Ready()) {
// TODO: switch to standard energy usage
unit->energy_manager.Deplete(EnergyType::Energy, i->type->GetConsumption() * simulation_atom_var);
unit->energy.Deplete(i->type->GetConsumption() * simulation_atom_var);
}
}
} else if (i->type->isMissile()) { // FIXME other than beams, only missiles are processed here?
unit->energy_manager.Deplete(EnergyType::Energy, i->type->GetConsumption());
unit->energy.Deplete(i->type->GetConsumption());
}
//IF WE REFRESH ENERGY FROM SERVER : Think to send the energy update to the firing client with ACK TO fireRequest
//fire only 1 missile at a time
Expand Down
Loading