client-side NPCs
This commit is contained in:
parent
76f78c4b20
commit
aa220e7947
@ -246,6 +246,10 @@ PolyF const& MovementController::collisionPoly() const {
|
||||
return m_collisionPoly.get();
|
||||
}
|
||||
|
||||
void MovementController::setCollisionPoly(PolyF const& poly) {
|
||||
m_collisionPoly.set(poly);
|
||||
}
|
||||
|
||||
Vec2F MovementController::position() const {
|
||||
return {m_xPosition.get(), m_yPosition.get()};
|
||||
}
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
|
||||
// Currently active collisionPoly parameter
|
||||
PolyF const& collisionPoly() const;
|
||||
void setCollisionPoly(PolyF const& poly);
|
||||
|
||||
Vec2F position() const;
|
||||
float xPosition() const;
|
||||
|
@ -46,6 +46,8 @@ Npc::Npc(NpcVariant const& npcVariant)
|
||||
|
||||
m_questIndicatorOffset = jsonToVec2F(assets->json("/quests/quests.config:defaultIndicatorOffset"));
|
||||
|
||||
m_clientEntityMode = ClientEntityModeNames.getLeft(npcVariant.overrides.getString("clientEntityMode", "ClientSlaveOnly"));
|
||||
|
||||
m_isInteractive.set(false);
|
||||
|
||||
m_shifting.set(false);
|
||||
@ -157,6 +159,10 @@ EntityType Npc::entityType() const {
|
||||
return EntityType::Npc;
|
||||
}
|
||||
|
||||
ClientEntityMode Npc::clientEntityMode() const {
|
||||
return m_clientEntityMode;
|
||||
}
|
||||
|
||||
void Npc::init(World* world, EntityId entityId, EntityMode mode) {
|
||||
Entity::init(world, entityId, mode);
|
||||
m_movementController->init(world);
|
||||
@ -246,6 +252,18 @@ RectF Npc::collisionArea() const {
|
||||
}
|
||||
|
||||
pair<ByteArray, uint64_t> Npc::writeNetState(uint64_t fromVersion) {
|
||||
// client-side npcs error nearby vanilla NPC scripts because callScriptedEntity
|
||||
// for now, scrungle the collision poly to avoid their queries. hacky :(
|
||||
if (auto mode = entityMode()) {
|
||||
if (*mode == EntityMode::Master && connectionForEntity(entityId()) != ServerConnectionId) {
|
||||
PolyF poly = m_movementController->collisionPoly();
|
||||
m_movementController->setCollisionPoly({});
|
||||
auto result = m_netGroup.writeNetState(fromVersion);
|
||||
m_movementController->setCollisionPoly(poly);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return m_netGroup.writeNetState(fromVersion);
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
ByteArray netStore();
|
||||
|
||||
EntityType entityType() const override;
|
||||
ClientEntityMode clientEntityMode() const override;
|
||||
|
||||
void init(World* world, EntityId entityId, EntityMode mode) override;
|
||||
void uninit() override;
|
||||
@ -201,6 +202,8 @@ private:
|
||||
NetElementData<Maybe<String>> m_uniqueIdNetState;
|
||||
NetElementData<EntityDamageTeam> m_teamNetState;
|
||||
|
||||
ClientEntityMode m_clientEntityMode;
|
||||
|
||||
Humanoid m_humanoid;
|
||||
NetElementEnum<Humanoid::State> m_humanoidStateNetState;
|
||||
NetElementEnum<HumanoidEmote> m_humanoidEmoteStateNetState;
|
||||
|
Loading…
Reference in New Issue
Block a user