summaryrefslogtreecommitdiffhomepage
path: root/Stars45/WeaponGroup.cpp
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-04-01 21:23:39 +0200
committerAki <please@ignore.pl>2022-04-01 21:23:39 +0200
commit3c487c5cd69c53d6fea948643c0a76df03516605 (patch)
tree72730c7b8b26a5ef8fc9a987ec4c16129efd5aac /Stars45/WeaponGroup.cpp
parent8f353abd0bfe18baddd8a8250ab7c4f2d1c83a6e (diff)
downloadstarshatter-3c487c5cd69c53d6fea948643c0a76df03516605.zip
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.gz
starshatter-3c487c5cd69c53d6fea948643c0a76df03516605.tar.bz2
Moved Stars45 to StarsEx
Diffstat (limited to 'Stars45/WeaponGroup.cpp')
-rw-r--r--Stars45/WeaponGroup.cpp346
1 files changed, 0 insertions, 346 deletions
diff --git a/Stars45/WeaponGroup.cpp b/Stars45/WeaponGroup.cpp
deleted file mode 100644
index 5519c68..0000000
--- a/Stars45/WeaponGroup.cpp
+++ /dev/null
@@ -1,346 +0,0 @@
-/* Starshatter: The Open Source Project
- Copyright (c) 2021-2022, Starshatter: The Open Source Project Contributors
- Copyright (c) 2011-2012, Starshatter OpenSource Distribution Contributors
- Copyright (c) 1997-2006, Destroyer Studios LLC.
-
- AUTHOR: John DiCamillo
-
-
- OVERVIEW
- ========
- Weapon Control Category (Group) class
-*/
-
-#include "WeaponGroup.h"
-#include "Ship.h"
-
-// +----------------------------------------------------------------------+
-
-WeaponGroup::WeaponGroup(const char* n)
- : selected(0), trigger(false), orders(Weapon::MANUAL),
- control(Weapon::SINGLE_FIRE), sweep(Weapon::SWEEP_TIGHT),
- mass(0.0f), resist(0.0f), name(n), ammo(0)
-{ }
-
-// +--------------------------------------------------------------------+
-
-WeaponGroup::~WeaponGroup()
-{
- weapons.destroy();
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::SetName(const char* n)
-{
- name = n;
-}
-
-void
-WeaponGroup::SetAbbreviation(const char* a)
-{
- abrv = a;
-}
-
-// +--------------------------------------------------------------------+
-
-bool
-WeaponGroup::IsPrimary() const
-{
- if (weapons.size() > 0)
- return weapons[0]->IsPrimary();
-
- return false;
-}
-
-bool
-WeaponGroup::IsDrone() const
-{
- if (weapons.size() > 0)
- return weapons[0]->IsDrone();
-
- return false;
-}
-
-bool
-WeaponGroup::IsDecoy() const
-{
- if (weapons.size() > 0)
- return weapons[0]->IsDecoy();
-
- return false;
-}
-
-bool
-WeaponGroup::IsProbe() const
-{
- if (weapons.size() > 0)
- return weapons[0]->IsProbe();
-
- return false;
-}
-
-bool
-WeaponGroup::IsMissile() const
-{
- if (weapons.size() > 0)
- return weapons[0]->IsMissile();
-
- return false;
-}
-
-bool
-WeaponGroup::IsBeam() const
-{
- if (weapons.size() > 0)
- return weapons[0]->IsBeam();
-
- return false;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::AddWeapon(Weapon* w)
-{
- weapons.append(w);
-}
-
-int
-WeaponGroup::NumWeapons() const
-{
- return weapons.size();
-}
-
-List<Weapon>&
-WeaponGroup::GetWeapons()
-{
- return weapons;
-}
-
-bool
-WeaponGroup::Contains(const Weapon* w) const
-{
- return weapons.contains(w)?true:false;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::SelectWeapon(int n)
-{
- if (n >= 0 && n < weapons.size())
- selected = n;
-}
-
-void
-WeaponGroup::CycleWeapon()
-{
- selected++;
-
- if (selected >= weapons.size())
- selected = 0;
-}
-
-Weapon*
-WeaponGroup::GetWeapon(int n) const
-{
- if (n >= 0 && n < weapons.size())
- return weapons[n];
-
- return 0;
-}
-
-Weapon*
-WeaponGroup::GetSelected() const
-{
- return weapons[selected];
-}
-
-bool
-WeaponGroup::CanTarget(DWORD tgt_class) const
-{
- if (selected >= 0 && selected < weapons.size())
- return weapons[selected]->CanTarget(tgt_class);
-
- return false;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::ExecFrame(double seconds)
-{
- ammo = 0;
- mass = 0.0f;
- resist = 0.0f;
-
- ListIter<Weapon> iter = weapons;
- while (++iter) {
- Weapon* w = iter.value();
- w->ExecFrame(seconds);
-
- ammo += w->Ammo();
- mass += w->Mass();
- resist += w->Resistance();
- }
-}
-
-void
-WeaponGroup::CheckAmmo()
-{
- ammo = 0;
- mass = 0.0f;
- resist = 0.0f;
-
- ListIter<Weapon> iter = weapons;
- while (++iter) {
- Weapon* w = iter.value();
-
- ammo += w->Ammo();
- mass += w->Mass();
- resist += w->Resistance();
- }
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::SetTarget(SimObject* target, System* subtarget)
-{
- ListIter<Weapon> w = weapons;
- while (++w)
- w->SetTarget(target, subtarget);
-}
-
-SimObject*
-WeaponGroup::GetTarget() const
-{
- SimObject* target = 0;
-
- if (weapons.size())
- target = weapons[0]->GetTarget();
-
- return target;
-}
-
-System*
-WeaponGroup::GetSubTarget() const
-{
- System* subtarget = 0;
-
- if (weapons.size())
- subtarget = weapons[0]->GetSubTarget();
-
- return subtarget;
-}
-
-void
-WeaponGroup::DropTarget()
-{
- ListIter<Weapon> w = weapons;
- while (++w)
- w->SetTarget(0, 0);
-}
-
-// +--------------------------------------------------------------------+
-
-WeaponDesign*
-WeaponGroup::GetDesign() const
-{
- if (selected >= 0 && selected < weapons.size())
- return (WeaponDesign*) weapons[selected]->Design();
-
- return 0;
-}
-
-// +--------------------------------------------------------------------+
-
-int
-WeaponGroup::Status() const
-{
- int status = System::NOMINAL;
- int critical = true;
-
- ListIter<Weapon> iter = (List<Weapon>&) weapons; // cast-away const
- while (++iter) {
- Weapon* w = iter.value();
-
- if (w->Status() < System::NOMINAL)
- status = System::DEGRADED;
-
- if (w->Status() > System::CRITICAL)
- critical = false;
- }
-
- if (critical)
- return System::CRITICAL;
-
- return status;
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::SetFiringOrders(int o)
-{
- orders = o;
-
- ListIter<Weapon> w = weapons;
- while (++w)
- w->SetFiringOrders(orders);
-}
-
-void
-WeaponGroup::SetControlMode(int m)
-{
- control = m;
-
- ListIter<Weapon> w = weapons;
- while (++w)
- w->SetControlMode(control);
-}
-
-void
-WeaponGroup::SetSweep(int s)
-{
- sweep = s;
-
- ListIter<Weapon> w = weapons;
- while (++w)
- w->SetSweep(sweep);
-}
-
-// +--------------------------------------------------------------------+
-
-void
-WeaponGroup::PowerOff()
-{
- ListIter<Weapon> w = weapons;
- while (++w)
- w->PowerOff();
-}
-
-void
-WeaponGroup::PowerOn()
-{
- ListIter<Weapon> w = weapons;
- while (++w)
- w->PowerOn();
-}
-
-// +--------------------------------------------------------------------+
-
-int
-WeaponGroup::Value() const
-{
- int result = 0;
-
- for (int i = 0; i < weapons.size(); i++) {
- const Weapon* w = weapons[i];
- result += w->Value();
- }
-
- return result;
-}