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
14
class
SelectionFinder
{
15
public
:
16
enum class
EntityType
{
None
,
Player
,
Egg
,
Tile
};
17
18
struct
Selection
{
19
EntityType
type
=
EntityType::None
;
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);
44
static
Selection
getEmptySelection
();
45
};
46
47
std::ostream&
operator<<
(std::ostream& os,
const
SelectionFinder::Selection
& sel);
48
std::ostream&
operator<<
(std::ostream& os,
const
SelectionFinder::EntityType
& type);
49
50
inline
std::string
to_string
(
SelectionFinder::EntityType
type)
51
{
52
std::ostringstream oss;
53
oss << type;
54
return
oss.str();
55
}
GameState.hpp
to_string
std::string to_string(SelectionFinder::EntityType type)
Definition
SelectionFinder.hpp:50
operator<<
std::ostream & operator<<(std::ostream &os, const SelectionFinder::Selection &sel)
Definition
SelectionFinder.cpp:102
TileSlotMap.hpp
GameState
Represents the current state of the game. Knows the world state, some metadata, and how to apply even...
Definition
GameState.hpp:15
SelectionFinder
Helper class to perform raycasting and find selected entities in the game world.
Definition
SelectionFinder.hpp:14
SelectionFinder::findFromRay
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.
Definition
SelectionFinder.cpp:9
SelectionFinder::EntityType
EntityType
Definition
SelectionFinder.hpp:16
SelectionFinder::EntityType::Player
@ Player
SelectionFinder::EntityType::None
@ None
SelectionFinder::EntityType::Egg
@ Egg
SelectionFinder::getEmptySelection
static Selection getEmptySelection()
Returns an empty selection (type None).
Definition
SelectionFinder.cpp:82
TileSlotMap
Manages 8-slot spatial assignment per tile for resources and eggs.
Definition
TileSlotMap.hpp:19
SelectionFinder::Selection
Definition
SelectionFinder.hpp:18
SelectionFinder::Selection::type
EntityType type
Definition
SelectionFinder.hpp:19
SelectionFinder::Selection::tileX
int tileX
Definition
SelectionFinder.hpp:21
SelectionFinder::Selection::tileY
int tileY
Definition
SelectionFinder.hpp:22
Tile
gui
src
renderer
raylib_helpers
SelectionFinder.hpp
Generated by
1.9.8