Let players use tools in lounges

This commit is contained in:
Kae 2023-07-20 15:27:28 +10:00
parent c1ae238086
commit b964668a38
5 changed files with 17 additions and 4 deletions

View File

@ -879,11 +879,13 @@ void Player::update(uint64_t) {
p.second->update(WorldTimestep * p.second->updateDelta()); p.second->update(WorldTimestep * p.second->updateDelta());
if (edgeTriggeredUse) { if (edgeTriggeredUse) {
if (canUseTool()) { auto anchor = as<LoungeAnchor>(m_movementController->entityAnchor());
bool useTool = canUseTool();
if (anchor && (!useTool || anchor->controllable))
m_movementController->resetAnchorState();
else if (useTool) {
if (auto ie = bestInteractionEntity(true)) if (auto ie = bestInteractionEntity(true))
interactWithEntity(ie); interactWithEntity(ie);
} else if (loungingIn()) {
m_movementController->resetAnchorState();
} }
} }
@ -1393,7 +1395,13 @@ void Player::playEmote(HumanoidEmote emote) {
} }
bool Player::canUseTool() const { bool Player::canUseTool() const {
return !isDead() && !isTeleporting() && !m_techController->toolUsageSuppressed() && m_state != State::Lounge; bool canUse = !isDead() && !isTeleporting() && !m_techController->toolUsageSuppressed();
if (canUse) {
if (auto loungeAnchor = as<LoungeAnchor>(m_movementController->entityAnchor()))
if (loungeAnchor->suppressTools)
return false;
}
return canUse;
} }
void Player::beginPrimaryFire() { void Player::beginPrimaryFire() {

View File

@ -46,6 +46,7 @@ Vehicle::Vehicle(Json baseConfig, String path, Json dynamicConfig)
loungePosition.dance.set(pair.second.optString("dance")); loungePosition.dance.set(pair.second.optString("dance"));
loungePosition.directives.set(pair.second.optString("directives")); loungePosition.directives.set(pair.second.optString("directives"));
loungePosition.statusEffects.set(pair.second.getArray("statusEffects", {}).transformed(jsonToPersistentStatusEffect)); loungePosition.statusEffects.set(pair.second.getArray("statusEffects", {}).transformed(jsonToPersistentStatusEffect));
loungePosition.suppressTools = pair.second.getBool("suppressTools", false);
} }
for (auto const& pair : configValue("physicsCollisions", JsonObject()).iterateObject()) { for (auto const& pair : configValue("physicsCollisions", JsonObject()).iterateObject()) {
@ -465,6 +466,7 @@ LoungeAnchorConstPtr Vehicle::loungeAnchor(size_t positionIndex) const {
loungePosition->armorCosmeticOverrides = positionConfig.armorCosmeticOverrides; loungePosition->armorCosmeticOverrides = positionConfig.armorCosmeticOverrides;
loungePosition->cursorOverride = positionConfig.cursorOverride; loungePosition->cursorOverride = positionConfig.cursorOverride;
loungePosition->cameraFocus = positionConfig.cameraFocus; loungePosition->cameraFocus = positionConfig.cameraFocus;
loungePosition->suppressTools = positionConfig.suppressTools;
return loungePosition; return loungePosition;
} }

View File

@ -96,6 +96,7 @@ private:
Maybe<Vec2F> exitBottomOffset; Maybe<Vec2F> exitBottomOffset;
JsonObject armorCosmeticOverrides; JsonObject armorCosmeticOverrides;
Maybe<String> cursorOverride; Maybe<String> cursorOverride;
bool suppressTools;
bool cameraFocus; bool cameraFocus;
NetElementBool enabled; NetElementBool enabled;

View File

@ -31,6 +31,7 @@ struct LoungeAnchor : EntityAnchor {
Maybe<Directives> directives; Maybe<Directives> directives;
JsonObject armorCosmeticOverrides; JsonObject armorCosmeticOverrides;
Maybe<String> cursorOverride; Maybe<String> cursorOverride;
bool suppressTools;
bool cameraFocus; bool cameraFocus;
}; };

View File

@ -51,6 +51,7 @@ LoungeAnchorConstPtr LoungeableObject::loungeAnchor(size_t positionIndex) const
auto loungeAnchor = make_shared<LoungeAnchor>(); auto loungeAnchor = make_shared<LoungeAnchor>();
loungeAnchor->suppressTools = false;
loungeAnchor->controllable = false; loungeAnchor->controllable = false;
loungeAnchor->direction = m_sitFlipDirection ? -direction() : direction(); loungeAnchor->direction = m_sitFlipDirection ? -direction() : direction();