AMay ffeab76719
Some checks failed
Emscripten Build / Build_and_Deploy_Web_Build (push) Successful in 7m55s
Emscripten Build / UnitTesting (push) Failing after 9m26s
Isolate Ground Slam into its own effect. Prepped effect for implementation. Release Build 13575.
2026-05-05 17:27:00 -05:00

105 lines
4.1 KiB
C++

#pragma region License
/*
License (OLC-3)
~~~~~~~~~~~~~~~
Copyright 2026 Amy Sigona <sigonasr2@gmail.com>
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions or derivations of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions or derivative works in binary form must reproduce the above
copyright notice. This list of conditions and the following disclaimer must be
reproduced in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may
be used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Portions of this software are copyright © 2024 The FreeType
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
All rights reserved.
*/
#pragma endregion
#pragma once
#include "olcUTIL_Geometry2D.h"
#include <variant>
#include"Buff.h"
#include"HurtDamageInfo.h"
#include"FriendlyType.h"
#include"DEFINES.h"
#include"State.h"
class Player;
class Monster;
//A helper class to connect multiple entity types based on their commonalities without using inheritance shenanigans.
class Entity{
friend struct std::hash<Entity>;
friend bool operator==(const Entity&lhs,const Entity&rhs);
friend class AiL;
public:
Entity(Player*player);
Entity(Monster*monster);
Entity(const std::variant<Monster*,Player*>ent);
void ForPlayer(std::function<void(Player&p)>);
void ForMonster(std::function<void(Monster&p)>);
Player*const ToPlayer()const;
Monster*const ToMonster()const;
const vf2d GetPos()const;
void SetIframeTime(const float iframeTime);
Buff&GetOrAddBuff(BuffType buffType,std::pair<BuffDuration,BuffIntensity>newBuff);
const std::optional<Buff>GetBuff(BuffType buff)const;
const float GetDistanceFrom(vf2d target)const;
bool Hurt(int damage,bool onUpperLevel,float z,HurtFlag::HurtFlag hurtFlags=HurtFlag::NONE);
std::optional<Buff>EditBuff(BuffType buff);
const bool IsSkeletonMage()const;
const bool IsBoss()const;
const std::vector<Buff>GetBuffs(BuffType buff)const;
const bool OnUpperLevel()const;
const float GetMoveSpdMult()const;
const float GetSizeMult()const;
const int GetAttack()const;
const float GetZ()const;
const FriendlyType IsFriendly()const;
const State::State GetState()const;
const bool CanMove()const;
const bool HasEnchant(const std::string&enchant)const;
float&GetBlockTimer()const;
Buff&AddBuff(BuffType type,float duration,float intensity);
Buff&AddBuff(BuffType type,float duration,float intensity,std::set<std::string>attr);
void Spin(float duration,float spinSpd);
void Knockback(vf2d vel);
private:
mutableconst std::variant<Monster*,Player*>entity;
inline bool operator==(const Entity&rhs){return entity==rhs.entity;}
};
inline bool operator==(const Entity&lhs,const Entity&rhs){return lhs.entity==rhs.entity;}
template <>
struct std::hash<Entity>
{
std::size_t operator()(const Entity&entity)const{
if(std::holds_alternative<Player*>(entity.entity))return std::hash<intptr_t>()(intptr_t(std::get<Player*>(entity.entity)));
if(std::holds_alternative<Monster*>(entity.entity))return std::hash<intptr_t>()(intptr_t(std::get<Monster*>(entity.entity)));
ERR("Entity is not a valid type! THIS SHOULD NOT BE HAPPENING!");
}
};