feat: defined clue data resource
This commit is contained in:
parent
dbcd580b4b
commit
7d1ae226bc
2 changed files with 72 additions and 0 deletions
46
modules/you_done_it/clue_data.cpp
Normal file
46
modules/you_done_it/clue_data.cpp
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#include "clue_data.h"
|
||||
#include "you_done_it/macros.h"
|
||||
#include "you_done_it/ydi_client.h"
|
||||
#include <core/config/engine.h>
|
||||
|
||||
void ClueData::_bind_methods() {
|
||||
BIND_HPROPERTY(Variant::INT, id, PROPERTY_HINT_ENUM, NetworkData::ClueID_hint());
|
||||
}
|
||||
|
||||
void ClueData::set_revealed(bool value) {
|
||||
this->revealed = value;
|
||||
}
|
||||
|
||||
void ClueData::set_id(NetworkData::ClueID id) {
|
||||
this->id = id;
|
||||
}
|
||||
|
||||
NetworkData::ClueID ClueData::get_id() const {
|
||||
return this->id;
|
||||
}
|
||||
|
||||
void ClueData::reveal() {
|
||||
if (this->id == NetworkData::CLUE_MAX) {
|
||||
print_error("Attempt to reveal CLUE_MAX, invalid state, aborting");
|
||||
abort();
|
||||
}
|
||||
if (this->revealed) {
|
||||
print_error("Attempt to reveal clue that's already revealed, returning without action");
|
||||
return;
|
||||
}
|
||||
this->revealed = true;
|
||||
ydi::client::send::reveal_clue(this->id);
|
||||
}
|
||||
|
||||
bool ClueData::get_revealed() const {
|
||||
return this->revealed;
|
||||
}
|
||||
|
||||
void ClueData::set_image(Ref<Image> image) {
|
||||
this->image = image;
|
||||
// TODO: Sync to server
|
||||
}
|
||||
|
||||
Ref<Image> ClueData::get_image() const {
|
||||
return this->image;
|
||||
}
|
||||
26
modules/you_done_it/clue_data.h
Normal file
26
modules/you_done_it/clue_data.h
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include "you_done_it/ydi_networking.h"
|
||||
#include <core/io/image.h>
|
||||
#include <core/io/resource.h>
|
||||
|
||||
class ClueData : public Resource {
|
||||
GDCLASS(ClueData, Resource);
|
||||
static void _bind_methods();
|
||||
|
||||
protected:
|
||||
void set_revealed(bool value);
|
||||
|
||||
public:
|
||||
void set_id(NetworkData::ClueID id);
|
||||
NetworkData::ClueID get_id() const;
|
||||
void reveal();
|
||||
bool get_revealed() const;
|
||||
void set_image(Ref<Image> image);
|
||||
Ref<Image> get_image() const;
|
||||
|
||||
private:
|
||||
NetworkData::ClueID id{ NetworkData::CLUE_MAX };
|
||||
bool revealed{ false };
|
||||
Ref<Image> image{};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue