osb/source/game/StarNpc.hpp

262 lines
8.5 KiB
C++
Raw Normal View History

#pragma once
2023-06-20 04:33:09 +00:00
#include "StarNpcDatabase.hpp"
#include "StarEntity.hpp"
#include "StarNetElementSystem.hpp"
#include "StarActorMovementController.hpp"
#include "StarHumanoid.hpp"
#include "StarEffectEmitter.hpp"
#include "StarEntitySplash.hpp"
#include "StarDamageBarEntity.hpp"
#include "StarNametagEntity.hpp"
#include "StarPortraitEntity.hpp"
#include "StarScriptedEntity.hpp"
#include "StarChattyEntity.hpp"
#include "StarEmoteEntity.hpp"
#include "StarInteractiveEntity.hpp"
#include "StarLoungingEntities.hpp"
#include "StarToolUserEntity.hpp"
#include "StarLuaComponents.hpp"
#include "StarLuaActorMovementComponent.hpp"
#include "StarItemBag.hpp"
#include "StarArmorWearer.hpp"
#include "StarToolUser.hpp"
#include "StarPhysicsEntity.hpp"
namespace Star {
STAR_CLASS(Item);
STAR_CLASS(RenderCallback);
STAR_CLASS(Npc);
STAR_CLASS(StatusController);
class Npc
: public virtual DamageBarEntity,
public virtual PortraitEntity,
public virtual NametagEntity,
public virtual ScriptedEntity,
public virtual ChattyEntity,
public virtual InteractiveEntity,
public virtual LoungingEntity,
public virtual ToolUserEntity,
public virtual PhysicsEntity,
public virtual EmoteEntity {
public:
Npc(NpcVariant const& npcVariant);
Npc(NpcVariant const& npcVariant, Json const& initialState);
Json diskStore() const;
ByteArray netStore();
EntityType entityType() const override;
2023-07-26 06:45:01 +00:00
ClientEntityMode clientEntityMode() const override;
2023-06-20 04:33:09 +00:00
void init(World* world, EntityId entityId, EntityMode mode) override;
void uninit() override;
Vec2F position() const override;
RectF metaBoundBox() const override;
Vec2F mouthOffset(bool ignoreAdjustments = true) const;
2023-06-20 04:33:09 +00:00
Vec2F feetOffset() const;
Vec2F headArmorOffset() const;
Vec2F chestArmorOffset() const;
Vec2F legsArmorOffset() const;
Vec2F backArmorOffset() const;
RectF collisionArea() const override;
pair<ByteArray, uint64_t> writeNetState(uint64_t fromVersion = 0) override;
void readNetState(ByteArray data, float interpolationTime = 0.0f) override;
void enableInterpolation(float extrapolationHint = 0.0f) override;
void disableInterpolation() override;
String description() const override;
String species() const override;
Gender gender() const;
String npcType() const;
Json scriptConfigParameter(String const& parameterName, Json const& defaultValue = Json()) const;
Maybe<HitType> queryHit(DamageSource const& source) const override;
Maybe<PolyF> hitPoly() const override;
void damagedOther(DamageNotification const& damage) override;
List<DamageNotification> applyDamage(DamageRequest const& damage) override;
List<DamageNotification> selfDamageNotifications() override;
bool shouldDestroy() const override;
void destroy(RenderCallback* renderCallback) override;
void update(float dt, uint64_t currentVersion) override;
2023-06-20 04:33:09 +00:00
void render(RenderCallback* renderCallback) override;
void renderLightSources(RenderCallback* renderCallback) override;
2023-06-20 04:33:09 +00:00
void setPosition(Vec2F const& pos);
float maxHealth() const override;
float health() const override;
DamageBarType damageBar() const override;
List<Drawable> portrait(PortraitMode mode) const override;
String name() const override;
Maybe<String> statusText() const override;
bool displayNametag() const override;
Vec3B nametagColor() const override;
Vec2F nametagOrigin() const override;
2023-06-20 04:33:09 +00:00
bool aggressive() const;
Maybe<LuaValue> callScript(String const& func, LuaVariadic<LuaValue> const& args) override;
Maybe<LuaValue> evalScript(String const& code) override;
Vec2F mouthPosition() const override;
Vec2F mouthPosition(bool ignoreAdjustments) const override;
2023-06-20 04:33:09 +00:00
List<ChatAction> pullPendingChatActions() override;
bool isInteractive() const override;
InteractAction interact(InteractRequest const& request) override;
RectF interactiveBoundBox() const override;
Maybe<EntityAnchorState> loungingIn() const override;
List<QuestArcDescriptor> offeredQuests() const override;
StringSet turnInQuests() const override;
Vec2F questIndicatorPosition() const override;
List<LightSource> lightSources() const override;
Maybe<Json> receiveMessage(ConnectionId sendingConnection, String const& message, JsonArray const& args) override;
Vec2F armPosition(ToolHand hand, Direction facingDirection, float armAngle, Vec2F offset = {}) const override;
Vec2F handOffset(ToolHand hand, Direction facingDirection) const override;
Vec2F handPosition(ToolHand hand, Vec2F const& handOffset = {}) const override;
ItemPtr handItem(ToolHand hand) const override;
Vec2F armAdjustment() const override;
Vec2F velocity() const override;
Vec2F aimPosition() const override;
float interactRadius() const override;
Direction facingDirection() const override;
Direction walkingDirection() const override;
bool isAdmin() const override;
2024-03-19 14:53:34 +00:00
Color favoriteColor() const override;
2023-06-20 04:33:09 +00:00
float beamGunRadius() const override;
void addParticles(List<Particle> const& particles) override;
void addSound(String const& sound, float volume = 1.0f, float pitch = 1.0f) override;
2023-06-20 04:33:09 +00:00
bool inToolRange() const override;
bool inToolRange(Vec2F const& position) const override;
void addEphemeralStatusEffects(List<EphemeralStatusEffect> const& statusEffects) override;
ActiveUniqueStatusEffectSummary activeUniqueStatusEffectSummary() const override;
float powerMultiplier() const override;
bool fullEnergy() const override;
float energy() const override;
bool energyLocked() const override;
bool consumeEnergy(float energy) override;
void queueUIMessage(String const& message) override;
bool instrumentPlaying() override;
void instrumentEquipped(String const& instrumentKind) override;
void interact(InteractAction const& action) override;
void addEffectEmitters(StringSet const& emitters) override;
void requestEmote(String const& emote) override;
ActorMovementController* movementController() override;
StatusController* statusController() override;
void setCameraFocusEntity(Maybe<EntityId> const& cameraFocusEntity) override;
void playEmote(HumanoidEmote emote) override;
List<DamageSource> damageSources() const override;
List<PhysicsForceRegion> forceRegions() const override;
using Entity::setUniqueId;
private:
Vec2F getAbsolutePosition(Vec2F relativePosition) const;
void tickShared(float dt);
2023-06-20 04:33:09 +00:00
LuaCallbacks makeNpcCallbacks();
void setupNetStates();
void getNetStates(bool initial);
void setNetStates();
void addChatMessage(String const& message, Json const& config, String const& portrait = "");
void addEmote(HumanoidEmote const& emote);
void setDance(Maybe<String> const& danceName);
bool setItemSlot(String const& slot, ItemDescriptor itemDescriptor);
bool canUseTool() const;
void disableWornArmor(bool disable);
NpcVariant m_npcVariant;
NetElementTopGroup m_netGroup;
NetElementData<StringList> m_dropPools;
NetElementData<Maybe<String>> m_uniqueIdNetState;
NetElementData<EntityDamageTeam> m_teamNetState;
2023-07-26 06:45:01 +00:00
ClientEntityMode m_clientEntityMode;
2023-06-20 04:33:09 +00:00
Humanoid m_humanoid;
NetElementEnum<Humanoid::State> m_humanoidStateNetState;
NetElementEnum<HumanoidEmote> m_humanoidEmoteStateNetState;
NetElementData<Maybe<String>> m_humanoidDanceNetState;
NetElementData<Maybe<String>> m_deathParticleBurst;
ActorMovementControllerPtr m_movementController;
StatusControllerPtr m_statusController;
EffectEmitterPtr m_effectEmitter;
NetElementBool m_aggressive;
List<BehaviorStatePtr> m_behaviors;
mutable LuaMessageHandlingComponent<LuaStorableComponent<LuaActorMovementComponent<LuaUpdatableComponent<LuaWorldComponent<LuaBaseComponent>>>>> m_scriptComponent;
List<ChatAction> m_pendingChatActions;
NetElementEvent m_newChatMessageEvent;
NetElementString m_chatMessage;
NetElementString m_chatPortrait;
NetElementData<Json> m_chatConfig;
bool m_chatMessageUpdated;
NetElementData<Maybe<String>> m_statusText;
NetElementBool m_displayNametag;
HumanoidEmote m_emoteState;
GameTimer m_emoteCooldownTimer;
Maybe<String> m_dance;
GameTimer m_danceCooldownTimer;
GameTimer m_blinkCooldownTimer;
Vec2F m_blinkInterval;
NetElementBool m_isInteractive;
NetElementData<List<QuestArcDescriptor>> m_offeredQuests;
NetElementData<StringSet> m_turnInQuests;
Vec2F m_questIndicatorOffset;
ArmorWearerPtr m_armor;
ToolUserPtr m_tools;
NetElementBool m_disableWornArmor;
NetElementFloat m_xAimPosition;
NetElementFloat m_yAimPosition;
NetElementBool m_shifting;
NetElementBool m_damageOnTouch;
int m_hitDamageNotificationLimiter;
int m_hitDamageNotificationLimit;
};
}