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

Move Robot implementations to .cpp files #1365

Merged
merged 5 commits into from
May 17, 2023
Merged
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
3 changes: 0 additions & 3 deletions OPHD/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ enum class Morale
};


class Robot;
using RobotList = std::vector<Robot*>;

extern const std::map<TerrainType, std::string> TILE_INDEX_TRANSLATION;
extern const std::map<MineProductionRate, std::string> MINE_YIELD_TRANSLATION;

Expand Down
31 changes: 31 additions & 0 deletions OPHD/MapObjects/Robots/Robodigger.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "Robodigger.h"

#include "../../Common.h"
#include "../../Constants/Strings.h"


Robodigger::Robodigger() :
Robot(constants::Robodigger, "robots/robodigger.sprite", Robot::Type::Digger),
mDirection(Direction::Down)
{
}


void Robodigger::direction(Direction dir)
{
mDirection = dir;
}


Direction Robodigger::direction() const
{
return mDirection;
}


NAS2D::Dictionary Robodigger::getDataDict() const
{
auto dictionary = Robot::getDataDict();
dictionary.set("direction", static_cast<int>(mDirection));
return dictionary;
}
25 changes: 8 additions & 17 deletions OPHD/MapObjects/Robots/Robodigger.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,19 @@

#include "../Robot.h"

#include "../../Common.h"
#include "../../Constants/Strings.h"

enum class Direction;


class Robodigger : public Robot
{
public:
Robodigger() :
Robot(constants::Robodigger, "robots/robodigger.sprite", Robot::Type::Digger),
mDirection(Direction::Down)
{
}

void direction(Direction dir) { mDirection = dir; }
Direction direction() const { return mDirection; }

NAS2D::Dictionary getDataDict() const override
{
auto dictionary = Robot::getDataDict();
dictionary.set("direction", static_cast<int>(mDirection));
return dictionary;
}
Robodigger();

void direction(Direction dir);
Direction direction() const;

NAS2D::Dictionary getDataDict() const override;

private:
Direction mDirection;
Expand Down
25 changes: 25 additions & 0 deletions OPHD/MapObjects/Robots/Robodozer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "Robodozer.h"

#include "../../Constants/Strings.h"
#include "../../Map/Tile.h"


Robodozer::Robodozer() :
Robot(constants::Robodozer, "robots/robodozer.sprite", Robot::Type::Dozer)
{
}


void Robodozer::startTask(Tile& tile)
{
Robot::startTask(tile);

mTileIndex = static_cast<std::size_t>(tile.index());
tile.index(TerrainType::Dozed);
}


void Robodozer::abortTask(Tile& tile)
{
tile.index(static_cast<TerrainType>(mTileIndex));
}
21 changes: 4 additions & 17 deletions OPHD/MapObjects/Robots/Robodozer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,16 @@

#include "../Robot.h"

#include "../../Constants/Strings.h"
#include "../../Map/Tile.h"
class Tile;


class Robodozer : public Robot
{
public:
Robodozer(): Robot(constants::Robodozer, "robots/robodozer.sprite", Robot::Type::Dozer)
{
}
Robodozer();

void startTask(Tile& tile) override
{
Robot::startTask(tile);

mTileIndex = static_cast<std::size_t>(tile.index());
tile.index(TerrainType::Dozed);
}

void abortTask(Tile& tile) override
{
tile.index(static_cast<TerrainType>(mTileIndex));
}
void startTask(Tile& tile) override;
void abortTask(Tile& tile) override;

private:
std::size_t mTileIndex = 0;
Expand Down
9 changes: 9 additions & 0 deletions OPHD/MapObjects/Robots/Robominer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Robominer.h"

#include "../../Constants/Strings.h"


Robominer::Robominer() :
Robot(constants::Robominer, "robots/robominer.sprite", Robot::Type::Miner)
{
}
6 changes: 2 additions & 4 deletions OPHD/MapObjects/Robots/Robominer.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#pragma once

#include "../Robot.h"
#include "../../Constants/Strings.h"


class Robominer : public Robot
{
public:
Robominer(): Robot(constants::Robominer, "robots/robominer.sprite", Robot::Type::Miner)
{
}
Robominer();

};
1 change: 1 addition & 0 deletions OPHD/RobotPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class Tile;
class RobotCommand;
using RobotList = std::vector<Robot*>;


class RobotPool
Expand Down
1 change: 1 addition & 0 deletions OPHD/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Cache.h"
#include "Common.h"
#include "Constants/Strings.h"
#include "Constants/Numbers.h"
#include "WindowEventWrapper.h"

Expand Down
3 changes: 3 additions & 0 deletions OPHD/ophd.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,9 @@ IF NOT "$(VcpkgInstalledDir)" == "" (
<ClCompile Include="Technology\ResearchTracker.cpp" />
<ClCompile Include="Technology\TechnologyCatalog.cpp" />
<ClCompile Include="MapObjects\Robot.cpp" />
<ClCompile Include="MapObjects\Robots\Robodigger.cpp" />
<ClCompile Include="MapObjects\Robots\Robodozer.cpp" />
<ClCompile Include="MapObjects\Robots\Robominer.cpp" />
<ClCompile Include="MapObjects\Structures\Factory.cpp" />
<ClCompile Include="MapObjects\Structures\MineFacility.cpp" />
<ClCompile Include="MapObjects\Structure.cpp" />
Expand Down
9 changes: 9 additions & 0 deletions OPHD/ophd.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@
<ClCompile Include="MapObjects\Robot.cpp">
<Filter>Source Files\MapObjects</Filter>
</ClCompile>
<ClCompile Include="MapObjects\Robots\Robodigger.cpp">
<Filter>Source Files\MapObjects</Filter>
</ClCompile>
<ClCompile Include="MapObjects\Robots\Robodozer.cpp">
<Filter>Source Files\MapObjects</Filter>
</ClCompile>
<ClCompile Include="MapObjects\Robots\Robominer.cpp">
<Filter>Source Files\MapObjects</Filter>
</ClCompile>
<ClCompile Include="MapObjects\Structures\Factory.cpp">
<Filter>Source Files\MapObjects\Structures</Filter>
</ClCompile>
Expand Down