3 #include <BLIB/Components/Velocity2D.hpp>
4 #include <BLIB/Util/FileUtil.hpp>
15 float StorageCursor::size = 40.f;
18 constexpr
float MoveTime = 0.3f;
19 constexpr
float RotateRate = 360.f;
20 constexpr
float FlashPeriod = 0.4f;
43 cursorTxtr = engine.renderer().texturePool().getOrLoadTexture(bl::util::FileUtil::joinPath(
45 cursor.create(engine, cursorTxtr);
46 cursor.getTransform().setDepth(bl::cam::OverlayCamera::MinDepth + 1.f);
48 size = cursorTxtr->size().x;
49 moveVel = size / MoveTime;
54 cursor.setParent(parent);
55 bl::rc::Scene* overlay = engine.renderer().getObserver().getCurrentOverlay();
56 cursor.addToScene(overlay, bl::rc::UpdateSpeed::Dynamic);
57 if (peoplemon.entity() != bl::ecs::InvalidEntity) {
58 peoplemon.addToScene(overlay, bl::rc::UpdateSpeed::Dynamic);
63 cursor.flash(FlashPeriod, FlashPeriod);
69 cursor.removeFromScene();
70 if (peoplemon.entity() != bl::ecs::InvalidEntity) { peoplemon.removeFromScene(); }
76 cursor.stopFlashing();
77 cursor.setHidden(
true);
79 else if (!pplInScene && !engine.ecs().hasComponent<bl::com::Toggler>(cursor.entity())) {
80 cursor.flash(FlashPeriod, FlashPeriod);
85 if (pplInScene) { peoplemon.getTransform().rotate(RotateRate * dt); }
92 offset += moveVel * dt;
93 cursor.getTransform().move(moveVector(moveDir) * moveVel * dt);
107 if (!skip)
return false;
117 if (position.y > 0) {
138 if (position.x > 0) {
152 pplTxtr = engine.renderer().texturePool().getOrLoadTexture(
155 if (peoplemon.entity() == bl::ecs::InvalidEntity) {
156 peoplemon.create(engine, pplTxtr);
157 peoplemon.getTransform().setOrigin(pplTxtr->size() * 0.5f);
158 peoplemon.getTransform().setPosition(size * 0.5f, size * 0.5f);
159 peoplemon.setParent(cursor);
161 else { peoplemon.setTexture(pplTxtr); }
165 peoplemon.addToScene(engine.renderer().getObserver().getCurrentOverlay(),
166 bl::rc::UpdateSpeed::Dynamic);
169 peoplemon.getTransform().setRotation(0.f);
170 peoplemon.scaleToSize({size, size});
171 cursor.stopFlashing();
173 else if (peoplemon.entity() != bl::ecs::InvalidEntity) {
174 peoplemon.removeFromScene();
176 cursor.flash(FlashPeriod, FlashPeriod);
199 void StorageCursor::syncPos() { cursor.getTransform().setPosition(makePos()); }
201 glm::vec2 StorageCursor::makePos()
const {
EntityControl
Contains the various inputs a player or AI can use to control the game or an NPC.
Core classes and functionality for both the editor and game.
std::underlying_type_t< Control::EntityControl > EntityControl
Helper typedef to avoid too much casting boilerplate.
Parent namespace for all functionality unique to the game.
static std::string thumbnailImage(Id id)
Returns the path of the image to render as the peoplemon thumbnail.
static constexpr int BoxHeight
static constexpr int BoxWidth
static const std::string & MenuImagePath()
void deactivate()
Removes from the current scene.
void update(float dt)
Updates the cursor motion.
void setHidden(bool hide)
Show or hide the cursor.
void pageRight()
Updates the cursor position if the box to the right is switched to.
bool process(core::input::EntityControl cmd, bool skipAnim)
Processes user input to move the cursor.
void setHolding(core::pplmn::Id peoplemon)
Sets a Peoplemon to render with the cursor. Pass Unknown to clear.
const sf::Vector2i & getPosition() const
Returns the position of the cursor in the box.
static float TileSize()
Returns the size of a square on the grid.
void activate(bl::ecs::Entity parent)
Adds to the current overlay.
bool moving() const
Returns whether or not the cursor position is being interpolated.
void setX(int x)
Sets the x position of the cursor.
StorageCursor(bl::engine::Engine &engine)
Construct a new Storage Cursor.
void pageLeft()
Updates the cursor position if the box to the left is switched to.
static constexpr glm::vec2 BoxPosition