Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
SelectionFinder.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <ostream>
4#include <sstream>
5#include <string>
6
7#include "TileSlotMap.hpp"
8#include "core/GameState.hpp"
9#include "raylib.h"
10
15 public:
16 enum class EntityType { None, Player, Egg, Tile };
17
18 struct Selection {
20 int id = -1; // player/egg ID
21 int tileX = -1; // tile coords (if type == Tile)
22 int tileY = -1;
23 };
24
36 static Selection findFromRay(const Ray& ray, const GameState& state, float tileSize,
37 const Model& playerModel, float playerModelSize,
38 const Model& eggModel, float eggModelSize,
39 const TileSlotMap& slotMap);
45};
46
47std::ostream& operator<<(std::ostream& os, const SelectionFinder::Selection& sel);
48std::ostream& operator<<(std::ostream& os, const SelectionFinder::EntityType& type);
49
50inline std::string to_string(SelectionFinder::EntityType type)
51{
52 std::ostringstream oss;
53 oss << type;
54 return oss.str();
55}
std::string to_string(SelectionFinder::EntityType type)
std::ostream & operator<<(std::ostream &os, const SelectionFinder::Selection &sel)
Represents the current state of the game. Knows the world state, some metadata, and how to apply even...
Definition GameState.hpp:15
Helper class to perform raycasting and find selected entities in the game world.
static Selection findFromRay(const Ray &ray, const GameState &state, float tileSize, const Model &playerModel, float playerModelSize, const Model &eggModel, float eggModelSize, const TileSlotMap &slotMap)
Performs raycast and finds closest entity.
static Selection getEmptySelection()
Returns an empty selection (type None).
Manages 8-slot spatial assignment per tile for resources and eggs.