Phase 2: Entity data model extensions for behavior system
- Add Behavior enum (IDLE..FLEE, 11 values) and Trigger enum (DONE, BLOCKED, TARGET) as runtime IntEnum classes (closes #297, closes #298) - Add entity label system: labels property (frozenset), add_label(), remove_label(), has_label(), constructor kwarg (closes #296) - Add cell_pos integer logical position decoupled from float draw_pos; grid_pos now aliases cell_pos; SpatialHash::updateCell() for cell-based bucket management; FOV/visibility uses cell_position (closes #295) - Add step callback and default_behavior properties to Entity for grid.step() turn management (closes #299) - Update updateVisibility, visible_entities, ColorLayer::updatePerspective to use cell_position instead of float position BREAKING: grid_pos no longer derives from float x/y position. Use cell_pos/grid_pos for logical position, draw_pos for render position. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
94f5f5a3fd
commit
2f1e472245
15 changed files with 886 additions and 34 deletions
|
|
@ -5,6 +5,8 @@
|
|||
#include "IndexTexture.h"
|
||||
#include "Resources.h"
|
||||
#include <list>
|
||||
#include <unordered_set>
|
||||
#include <string>
|
||||
|
||||
#include "PyCallable.h"
|
||||
#include "PyTexture.h"
|
||||
|
|
@ -66,7 +68,11 @@ public:
|
|||
std::vector<UIGridPointState> gridstate;
|
||||
UISprite sprite;
|
||||
sf::Vector2f position; //(x,y) in grid coordinates; float for animation
|
||||
sf::Vector2i cell_position{0, 0}; // #295: integer logical position (decoupled from float position)
|
||||
sf::Vector2f sprite_offset; // pixel offset for oversized sprites (applied pre-zoom)
|
||||
std::unordered_set<std::string> labels; // #296: entity label system for collision/targeting
|
||||
PyObject* step_callback = nullptr; // #299: callback for grid.step() turn management
|
||||
int default_behavior = 0; // #299: BehaviorType::IDLE - behavior to revert to after DONE
|
||||
//void render(sf::Vector2f); //override final;
|
||||
|
||||
UIEntity();
|
||||
|
|
@ -80,6 +86,9 @@ public:
|
|||
pyobject = nullptr;
|
||||
Py_DECREF(tmp);
|
||||
}
|
||||
// #299: Clean up step callback
|
||||
Py_XDECREF(step_callback);
|
||||
step_callback = nullptr;
|
||||
}
|
||||
|
||||
// Visibility methods
|
||||
|
|
@ -131,6 +140,26 @@ public:
|
|||
static int set_sprite_offset(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_sprite_offset_member(PyUIEntityObject* self, void* closure);
|
||||
static int set_sprite_offset_member(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
|
||||
// #295 - cell_pos (integer logical position)
|
||||
static PyObject* get_cell_pos(PyUIEntityObject* self, void* closure);
|
||||
static int set_cell_pos(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_cell_member(PyUIEntityObject* self, void* closure);
|
||||
static int set_cell_member(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
|
||||
// #296 - Label system
|
||||
static PyObject* get_labels(PyUIEntityObject* self, void* closure);
|
||||
static int set_labels(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
|
||||
// #299 - Step callback and default behavior
|
||||
static PyObject* get_step(PyUIEntityObject* self, void* closure);
|
||||
static int set_step(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
static PyObject* get_default_behavior(PyUIEntityObject* self, void* closure);
|
||||
static int set_default_behavior(PyUIEntityObject* self, PyObject* value, void* closure);
|
||||
static PyObject* py_add_label(PyUIEntityObject* self, PyObject* arg);
|
||||
static PyObject* py_remove_label(PyUIEntityObject* self, PyObject* arg);
|
||||
static PyObject* py_has_label(PyUIEntityObject* self, PyObject* arg);
|
||||
|
||||
static PyMethodDef methods[];
|
||||
static PyGetSetDef getsetters[];
|
||||
static PyObject* repr(PyUIEntityObject* self);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue