Skip to content

Commit

Permalink
feat(persons): Add formation patterns for person ships (endless-sky#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
petervdmeer authored Aug 8, 2024
1 parent 4f22367 commit f0298e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions source/Person.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ this program. If not, see <https://www.gnu.org/licenses/>.
#include "Person.h"

#include "DataNode.h"
#include "FormationPattern.h"
#include "GameData.h"
#include "Government.h"
#include "Ship.h"
Expand All @@ -33,6 +34,8 @@ void Person::Load(const DataNode &node)
location.Load(child);
else if(child.Token(0) == "frequency" && child.Size() >= 2)
frequency = child.Value(1);
else if(child.Token(0) == "formation" && child.Size() >= 2)
formationPattern = GameData::Formations().Get(child.Token(1));
else if(child.Token(0) == "ship" && child.Size() >= 2)
{
// Name ships that are not the flagship with the name provided, if any.
Expand All @@ -59,7 +62,11 @@ void Person::Load(const DataNode &node)
void Person::FinishLoading()
{
for(const shared_ptr<Ship> &ship : ships)
{
ship->FinishLoading(true);
if(formationPattern)
ship->SetFormationPattern(formationPattern);
}
}


Expand Down
2 changes: 2 additions & 0 deletions source/Person.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ this program. If not, see <https://www.gnu.org/licenses/>.
#include <memory>

class DataNode;
class FormationPattern;
class Government;
class Ship;
class System;
Expand Down Expand Up @@ -65,6 +66,7 @@ class Person {
int frequency = 100;

std::list<std::shared_ptr<Ship>> ships;
const FormationPattern *formationPattern = nullptr;
const Government *government = nullptr;
Personality personality;
Phrase hail;
Expand Down

0 comments on commit f0298e3

Please sign in to comment.