mirror of
https://github.com/UltraCoderRU/screepsxx.git
synced 2026-01-28 01:55:12 +00:00
Add class StructureTerminal.
This commit is contained in:
parent
b249748d28
commit
d47489b38e
3 changed files with 61 additions and 0 deletions
28
include/Screeps/StructureTerminal.hpp
Normal file
28
include/Screeps/StructureTerminal.hpp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
#ifndef SCREEPS_STRUCTURE_TERMINAL_HPP
|
||||
#define SCREEPS_STRUCTURE_TERMINAL_HPP
|
||||
|
||||
#include "OwnedStructure.hpp"
|
||||
#include "Store.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace Screeps {
|
||||
|
||||
class StructureTerminal : public OwnedStructure
|
||||
{
|
||||
public:
|
||||
explicit StructureTerminal(JS::Value value);
|
||||
|
||||
int cooldown() const;
|
||||
|
||||
Store store() const;
|
||||
|
||||
int send(const std::string& resourceType,
|
||||
int amount,
|
||||
const std::string& destination,
|
||||
std::optional<std::string> description = std::nullopt);
|
||||
};
|
||||
|
||||
} // namespace Screeps
|
||||
|
||||
#endif // SCREEPS_STRUCTURE_TERMINAL_HPP
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
#include "StructureRoad.hpp"
|
||||
#include "StructureSpawn.hpp"
|
||||
#include "StructureStorage.hpp"
|
||||
#include "StructureTerminal.hpp"
|
||||
#include "StructureTower.hpp"
|
||||
#include "StructureWall.hpp"
|
||||
|
||||
|
|
@ -88,6 +89,8 @@ std::unique_ptr<RoomObject> createRoomObject(JS::Value object)
|
|||
return std::make_unique<StructureStorage>(std::move(object));
|
||||
else if (type == Screeps::STRUCTURE_EXTRACTOR)
|
||||
return std::make_unique<StructureExtractor>(std::move(object));
|
||||
else if (type == Screeps::STRUCTURE_TERMINAL)
|
||||
return std::make_unique<StructureTerminal>(std::move(object));
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
30
src/StructureTerminal.cpp
Normal file
30
src/StructureTerminal.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "StructureTerminal.hpp"
|
||||
|
||||
namespace Screeps {
|
||||
|
||||
StructureTerminal::StructureTerminal(JS::Value value) : OwnedStructure(std::move(value))
|
||||
{
|
||||
}
|
||||
|
||||
int StructureTerminal::cooldown() const
|
||||
{
|
||||
return value()["cooldown"].as<int>();
|
||||
}
|
||||
|
||||
Store StructureTerminal::store() const
|
||||
{
|
||||
return Store(value()["store"]);
|
||||
}
|
||||
|
||||
int StructureTerminal::send(const std::string& resourceType,
|
||||
int amount,
|
||||
const std::string& destination,
|
||||
std::optional<std::string> description)
|
||||
{
|
||||
if (description)
|
||||
return value().call<int>("send", resourceType, amount, destination, description);
|
||||
else
|
||||
return value().call<int>("send", resourceType, amount, destination);
|
||||
}
|
||||
|
||||
} // namespace Screeps
|
||||
Loading…
Add table
Reference in a new issue