osb/source/game/interfaces/StarLoungingEntities.hpp

70 lines
2.4 KiB
C++
Raw Permalink Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarDrawable.hpp"
#include "StarAnchorableEntity.hpp"
#include "StarStatusTypes.hpp"
#include "StarEntityRenderingTypes.hpp"
namespace Star {
STAR_CLASS(World);
STAR_STRUCT(LoungeAnchor);
STAR_CLASS(LoungeableEntity);
STAR_CLASS(LoungingEntity);
enum class LoungeOrientation { None, Sit, Lay, Stand };
extern EnumMap<LoungeOrientation> const LoungeOrientationNames;
enum class LoungeControl { Left, Right, Down, Up, Jump, PrimaryFire, AltFire, Special1, Special2, Special3 };
extern EnumMap<LoungeControl> const LoungeControlNames;
struct LoungeAnchor : EntityAnchor {
LoungeOrientation orientation;
EntityRenderLayer loungeRenderLayer;
bool controllable;
List<PersistentStatusEffect> statusEffects;
StringSet effectEmitters;
Maybe<String> emote;
Maybe<String> dance;
2023-06-25 08:12:54 +00:00
Maybe<Directives> directives;
2023-06-20 04:33:09 +00:00
JsonObject armorCosmeticOverrides;
Maybe<String> cursorOverride;
Maybe<bool> suppressTools;
2023-06-20 04:33:09 +00:00
bool cameraFocus;
};
// Extends an AnchorableEntity to have more specific effects when anchoring,
// such as status effects and lounge controls. All LoungeableEntity methods
// may be called on both the master and slave.
class LoungeableEntity : public AnchorableEntity {
public:
virtual size_t anchorCount() const override = 0;
EntityAnchorConstPtr anchor(size_t anchorPositionIndex) const override;
virtual LoungeAnchorConstPtr loungeAnchor(size_t anchorPositionIndex) const = 0;
// Default does nothing.
virtual void loungeControl(size_t anchorPositionIndex, LoungeControl loungeControl);
virtual void loungeAim(size_t anchorPositionIndex, Vec2F const& aimPosition);
// Queries around this entity's metaBoundBox for any LoungingEntities
// reporting that they are lounging in this entity, and returns ones that are
// lounging in the given position.
Set<EntityId> entitiesLoungingIn(size_t anchorPositionIndex) const;
// Returns pairs of entity ids, and the position they are lounging in.
Set<pair<EntityId, size_t>> entitiesLounging() const;
};
// Any lounging entity should report the entity it is lounging in on both
// master and slave, so that lounging entities can cooperate and avoid lounging
// in the same spot.
class LoungingEntity : public virtual Entity {
public:
virtual Maybe<EntityAnchorState> loungingIn() const = 0;
// Returns true if the entity is in a lounge achor, but other entities are
// also reporting being in that lounge anchor.
bool inConflictingLoungeAnchor() const;
};
}