2020-01-31 19:34:47 +01:00
|
|
|
/*
|
|
|
|
Copyright (c) 2019-2020 Péter Magyar
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2019-06-22 23:28:36 +02:00
|
|
|
#ifndef ENTITY_RESOURCE_H
|
|
|
|
#define ENTITY_RESOURCE_H
|
|
|
|
|
|
|
|
#include "core/reference.h"
|
|
|
|
|
2019-08-13 23:58:42 +02:00
|
|
|
class Stat;
|
|
|
|
class Entity;
|
2019-11-30 21:46:11 +01:00
|
|
|
class EntityResourceData;
|
2019-08-13 23:58:42 +02:00
|
|
|
|
2019-06-22 23:28:36 +02:00
|
|
|
class EntityResource : public Reference {
|
|
|
|
GDCLASS(EntityResource, Reference);
|
|
|
|
|
|
|
|
public:
|
2020-03-11 16:08:07 +01:00
|
|
|
bool get_dirty() const;
|
|
|
|
void set_dirty(const bool value);
|
2019-06-22 23:28:36 +02:00
|
|
|
|
2020-03-11 16:08:07 +01:00
|
|
|
bool get_should_process() const;
|
|
|
|
void set_should_process(const bool value);
|
2019-06-22 23:28:36 +02:00
|
|
|
|
2019-11-30 21:46:11 +01:00
|
|
|
Ref<EntityResourceData> get_resource_data();
|
2020-03-11 16:08:07 +01:00
|
|
|
void set_resource_data(const Ref<EntityResourceData> &value);
|
2019-11-30 21:46:11 +01:00
|
|
|
|
2020-04-19 17:15:36 +02:00
|
|
|
StringName get_data_path() const;
|
|
|
|
void set_data_path(const StringName &value);
|
2019-08-13 23:58:42 +02:00
|
|
|
|
2020-03-11 16:08:07 +01:00
|
|
|
int get_current_value() const;
|
|
|
|
void set_current_value(const int value);
|
2019-08-13 23:58:42 +02:00
|
|
|
|
2020-03-11 16:08:07 +01:00
|
|
|
int get_max_value() const;
|
|
|
|
void set_max_value(const int value);
|
2019-08-13 23:58:42 +02:00
|
|
|
|
|
|
|
Entity *get_owner();
|
|
|
|
void set_owner(Entity *entity);
|
|
|
|
void set_owner_bind(Node *owner);
|
|
|
|
|
|
|
|
void ons_added(Entity *owner);
|
|
|
|
void onc_added(Entity *owner);
|
|
|
|
|
|
|
|
void ons_stat_changed(Ref<Stat> stat);
|
|
|
|
void onc_stat_changed(Ref<Stat> stat);
|
|
|
|
|
2019-09-27 18:05:43 +02:00
|
|
|
void ons_target_changed(Entity *entity, Entity *old_target);
|
|
|
|
void onc_target_changed(Entity *entity, Entity *old_target);
|
2019-08-13 23:58:42 +02:00
|
|
|
|
2020-03-11 16:08:07 +01:00
|
|
|
void process_server(const float delta);
|
|
|
|
void _process_server(const float delta);
|
2019-08-13 23:58:42 +02:00
|
|
|
|
2020-03-11 16:08:07 +01:00
|
|
|
void process_client(const float delta);
|
|
|
|
void _process_client(const float delta);
|
2019-12-01 00:24:38 +01:00
|
|
|
|
2020-03-11 16:08:07 +01:00
|
|
|
void receivec_update(const int current);
|
|
|
|
void receivec_update_full(const int current, const int max);
|
|
|
|
void receivec_update_string(const String str);
|
2019-06-22 23:28:36 +02:00
|
|
|
|
2019-11-30 21:46:11 +01:00
|
|
|
void resolve_references();
|
|
|
|
|
2019-09-13 09:26:53 +02:00
|
|
|
Dictionary to_dict();
|
|
|
|
void from_dict(const Dictionary &dict);
|
|
|
|
|
|
|
|
Dictionary _to_dict();
|
|
|
|
void _from_dict(const Dictionary &dict);
|
|
|
|
|
2019-06-22 23:28:36 +02:00
|
|
|
EntityResource();
|
2019-12-01 00:24:38 +01:00
|
|
|
~EntityResource();
|
2019-06-22 23:28:36 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
private:
|
2019-12-01 00:24:38 +01:00
|
|
|
bool _server_side;
|
|
|
|
|
2019-08-13 23:58:42 +02:00
|
|
|
Entity *_owner;
|
2019-06-22 23:28:36 +02:00
|
|
|
bool _dirty;
|
|
|
|
bool _should_process;
|
2019-11-30 21:46:11 +01:00
|
|
|
|
|
|
|
Ref<EntityResourceData> _data;
|
2020-04-19 17:15:36 +02:00
|
|
|
StringName _data_path;
|
2019-11-30 21:46:11 +01:00
|
|
|
|
2019-08-13 23:58:42 +02:00
|
|
|
int _current;
|
|
|
|
int _max;
|
2019-06-22 23:28:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|