<commit_before>//
// Copyright (c) 2013-2014 <NAME>
// See LICENSE for more information.
//

#ifndef RJ_GAME_ENTITY_BASE_HPP
#define RJ_GAME_ENTITY_BASE_HPP


#include "entity_groups.hpp"
#include <rectojump/global/common.hpp>
#include <rectojump/shared/input.hpp>


namespace rj
{
	class entity_handler;
	class game;

	class entity_base
	{
		friend class entity_handler;

		int m_id{-1};
		bool m_is_registered{false};
		bool m_destroyed{false};
		eprops m_props;
		etypes m_types;

		// handler functions
		void handler_register(game* g, int id) noexcept
		{
			m_game = g;
			m_id = id;
			m_is_registered = true;
		}

		void destroy() noexcept
		{m_destroyed = true;}

	protected:
		game* m_game{nullptr};

		virtual void update(dur duration) = 0;
		virtual void render() = 0;
		virtual void init() { } // called by 'entity_handler'

	public:
		entity_base() = default;
		virtual ~entity_base() = default;

		bool is_registered() const noexcept
		{return m_is_registered || m_id != -1;}

		void set_propertie(eprops::type prop) noexcept
		{m_props |= prop;}

		void set_type(etypes::type type) noexcept
		{m_types |= type;}

		bool has_propertie(eprops::type prop) const noexcept
		{return m_props & prop;}

		bool has_type(etypes::type type) const noexcept
		{return m_types & type;}

		// position, collision
		virtual const vec2f& pos() const noexcept = 0;
		virtual float pos_x() const noexcept = 0;
		virtual float pos_y() const noexcept = 0;
		virtual float top_out() const noexcept = 0;
		virtual float bottom_out() const noexcept = 0;
		virtual float left_out() const noexcept = 0;
		virtual float right_out() const noexcept = 0;<commit_msg>added function to set game<commit_after>//
// Copyright (c) 2013-2014 <NAME>
// See LICENSE for more information.
//

#ifndef RJ_GAME_ENTITY_BASE_HPP
#define RJ_GAME_ENTITY_BASE_HPP


#include "entity_groups.hpp"
#include <rectojump/global/common.hpp>
#include <rectojump/shared/input.hpp>


namespace rj
{
	class entity_handler;
	class game;

	class entity_base
	{
		friend class entity_handler;

		int m_id{-1};
		bool m_is_registered{false};
		bool m_destroyed{false};
		eprops m_props;
		etypes m_types;

		// handler functions
		void handler_register(game* g, int id) noexcept
		{
			m_game = g;
			m_id = id;
			m_is_registered = true;
		}

		void destroy() noexcept
		{m_destroyed = true;}

	protected:
		game* m_game{nullptr};

		virtual void update(dur duration) = 0;
		virtual void render() = 0;
		virtual void init() { } // called by 'entity_handler'

	public:
		entity_base() = default;
		virtual ~entity_base() = default;

		void set_game(game* g) noexcept
		{m_game = g;}

		bool is_registered() const noexcept
		{return m_is_registered || m_id != -1;}

		void set_propertie(eprops::type prop) noexcept
		{m_props |= prop;}

		void set_type(etypes::type type) noexcept
		{m_types |= type;}

		bool has_propertie(eprops::type prop) const noexcept
		{return m_props & prop;}

		bool has_type(etypes::type type) const noexcept
		{return m_types & type;}

		// position, collision
		virtual const vec2f& pos() const noexcept = 0;
		virtual float pos_x() const noexcept = 0;
		virtual float pos_y() const noexcept = 0;
		virtual float top_out() const noexcept = 0;
		virtual float bottom_out() const noexcept = 0;
		virtual float left_out() const noexcept = 0;
		virtual float right_out() const noexcept = 0;
{'fraction_non_alphanumeric': 0.1083086053412463, 'fraction_numerical': 0.011869436201780416, 'mean_word_length': 4.023845007451565, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7542843', 'n_tokens_mistral': 1326, 'n_tokens_neox': 1159, 'n_words': 339}