diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-05-31 15:31:38 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2025-05-31 15:31:38 +1000 |
commit | 8e381cb362f8d40dffc3dca610bb70c9b3e7b94d (patch) | |
tree | 96b35cff1631aa2b120b33fb3fa657d26907fd41 /source/game | |
parent | 50a64f949a12f5e6db94724afa18b08b755eb5e7 (diff) |
armor: support for flipDirectives, fix activeItem arm frames with directives breaking on custom armor
Diffstat (limited to 'source/game')
-rw-r--r-- | source/game/StarArmorWearer.cpp | 33 | ||||
-rw-r--r-- | source/game/StarArmorWearer.hpp | 2 | ||||
-rw-r--r-- | source/game/StarHumanoid.cpp | 76 | ||||
-rw-r--r-- | source/game/StarHumanoid.hpp | 40 | ||||
-rw-r--r-- | source/game/StarPlayer.cpp | 22 | ||||
-rw-r--r-- | source/game/StarPlayerInventory.hpp | 2 | ||||
-rw-r--r-- | source/game/StarToolUser.cpp | 44 | ||||
-rw-r--r-- | source/game/items/StarArmors.cpp | 19 | ||||
-rw-r--r-- | source/game/items/StarArmors.hpp | 5 |
9 files changed, 138 insertions, 105 deletions
diff --git a/source/game/StarArmorWearer.cpp b/source/game/StarArmorWearer.cpp index ef67686..5f373ba 100644 --- a/source/game/StarArmorWearer.cpp +++ b/source/game/StarArmorWearer.cpp @@ -32,22 +32,30 @@ ArmorWearer::ArmorWearer() : m_lastNude(true) { void ArmorWearer::setupHumanoidClothingDrawables(Humanoid& humanoid, bool forceNude) { bool nudeChanged = m_lastNude != forceNude; auto gender = humanoid.identity().gender; - bool genderChanged = !m_lastGender || m_lastGender.value() != gender; + bool genderChanged = !m_lastGender || *m_lastGender != gender; + Direction direction = humanoid.facingDirection(); + bool dirChanged = !m_lastDirection || *m_lastDirection != direction; m_lastNude = forceNude; m_lastGender = gender; + m_lastDirection = direction; + + HeadArmorPtr const& headArmor = m_headCosmeticItem ? m_headCosmeticItem : m_headItem; + ChestArmorPtr const& chestArmor = m_chestCosmeticItem ? m_chestCosmeticItem : m_chestItem; + LegsArmorPtr const& legsArmor = m_legsCosmeticItem ? m_legsCosmeticItem : m_legsItem; + BackArmorPtr const& backArmor = m_backCosmeticItem ? m_backCosmeticItem : m_backItem; bool allNeedsSync = nudeChanged || genderChanged; - bool headNeedsSync = allNeedsSync || m_headNeedsSync; - bool chestNeedsSync = allNeedsSync || m_chestNeedsSync; - bool legsNeedsSync = allNeedsSync || m_legsNeedsSync; - bool backNeedsSync = allNeedsSync || m_backNeedsSync; + bool headNeedsSync = allNeedsSync || (dirChanged && headArmor && headArmor->flipping()) || m_headNeedsSync; + bool chestNeedsSync = allNeedsSync || (dirChanged && chestArmor && chestArmor->flipping()) || m_chestNeedsSync; + bool legsNeedsSync = allNeedsSync || (dirChanged && legsArmor && legsArmor->flipping()) || m_legsNeedsSync; + bool backNeedsSync = allNeedsSync || (dirChanged && backArmor && backArmor->flipping()) || m_backNeedsSync; + bool bodyFlipped = direction != Direction::Right; bool bodyHidden = false; - HeadArmorPtr const& headArmor = m_headCosmeticItem ? m_headCosmeticItem : m_headItem; if (headArmor && !forceNude) { if (headNeedsSync) { humanoid.setHeadArmorFrameset(headArmor->frameset(humanoid.identity().gender)); - humanoid.setHeadArmorDirectives(headArmor->directives()); + humanoid.setHeadArmorDirectives(headArmor->directives(bodyFlipped)); humanoid.setHelmetMaskDirectives(headArmor->maskDirectives()); } bodyHidden = bodyHidden || headArmor->hideBody(); @@ -67,13 +75,12 @@ void ArmorWearer::setupHumanoidClothingDrawables(Humanoid& humanoid, bool forceN } }; - ChestArmorPtr const& chestArmor = m_chestCosmeticItem ? m_chestCosmeticItem : m_chestItem; if (chestArmor && !forceNude) { if (chestNeedsSync) { humanoid.setBackSleeveFrameset(chestArmor->backSleeveFrameset(humanoid.identity().gender)); humanoid.setFrontSleeveFrameset(chestArmor->frontSleeveFrameset(humanoid.identity().gender)); humanoid.setChestArmorFrameset(chestArmor->bodyFrameset(humanoid.identity().gender)); - humanoid.setChestArmorDirectives(chestArmor->directives()); + humanoid.setChestArmorDirectives(chestArmor->directives(bodyFlipped)); addHumanoidConfig(*chestArmor); } bodyHidden = bodyHidden || chestArmor->hideBody(); @@ -83,11 +90,10 @@ void ArmorWearer::setupHumanoidClothingDrawables(Humanoid& humanoid, bool forceN humanoid.setChestArmorFrameset(""); } - LegsArmorPtr const& legsArmor = m_legsCosmeticItem ? m_legsCosmeticItem : m_legsItem; if (legsArmor && !forceNude) { if (legsNeedsSync) { humanoid.setLegsArmorFrameset(legsArmor->frameset(humanoid.identity().gender)); - humanoid.setLegsArmorDirectives(legsArmor->directives()); + humanoid.setLegsArmorDirectives(legsArmor->directives(bodyFlipped)); addHumanoidConfig(*legsArmor); } bodyHidden = bodyHidden || legsArmor->hideBody(); @@ -95,11 +101,10 @@ void ArmorWearer::setupHumanoidClothingDrawables(Humanoid& humanoid, bool forceN humanoid.setLegsArmorFrameset(""); } - BackArmorPtr const& backArmor = m_backCosmeticItem ? m_backCosmeticItem : m_backItem; if (backArmor && !forceNude) { if (backNeedsSync) { humanoid.setBackArmorFrameset(backArmor->frameset(humanoid.identity().gender)); - humanoid.setBackArmorDirectives(backArmor->directives()); + humanoid.setBackArmorDirectives(backArmor->directives(bodyFlipped)); humanoid.setBackRotatesWithHead(backArmor->instanceValue("rotateWithHead", false).optBool().value()); } bodyHidden = bodyHidden || backArmor->hideBody(); @@ -140,6 +145,8 @@ void ArmorWearer::effects(EffectEmitter& effectEmitter) { } void ArmorWearer::reset() { + m_lastGender.reset(); + m_lastDirection.reset(); m_headNeedsSync = m_chestNeedsSync = m_legsNeedsSync = m_backNeedsSync = true; m_headItem .reset(); m_chestItem.reset(); diff --git a/source/game/StarArmorWearer.hpp b/source/game/StarArmorWearer.hpp index ceb98b0..caee49e 100644 --- a/source/game/StarArmorWearer.hpp +++ b/source/game/StarArmorWearer.hpp @@ -87,11 +87,13 @@ private: // only works under the assumption that this ArmorWearer // will only ever touch one Humanoid (which is true!) Maybe<Gender> m_lastGender; + Maybe<Direction> m_lastDirection; bool m_lastNude; bool m_headNeedsSync; bool m_chestNeedsSync; bool m_legsNeedsSync; bool m_backNeedsSync; + Direction facingDirection; }; } diff --git a/source/game/StarHumanoid.cpp b/source/game/StarHumanoid.cpp index b56c432..9c818b8 100644 --- a/source/game/StarHumanoid.cpp +++ b/source/game/StarHumanoid.cpp @@ -524,57 +524,43 @@ bool Humanoid::movingBackwards() const { return m_movingBackwards; } -void Humanoid::setPrimaryHandParameters(bool holdingItem, float angle, float itemAngle, bool twoHanded, +void Humanoid::setHandParameters(ToolHand hand, bool holdingItem, float angle, float itemAngle, bool twoHanded, bool recoil, bool outsideOfHand) { - m_primaryHand.holdingItem = holdingItem; - m_primaryHand.angle = angle; - m_primaryHand.itemAngle = itemAngle; - m_twoHanded = twoHanded; - m_primaryHand.recoil = recoil; - m_primaryHand.outsideOfHand = outsideOfHand; + auto& handInfo = const_cast<HandDrawingInfo&>(getHand(hand)); + handInfo.holdingItem = holdingItem; + handInfo.angle = angle; + handInfo.itemAngle = itemAngle; + handInfo.recoil = recoil; + handInfo.outsideOfHand = outsideOfHand; + if (hand == ToolHand::Primary) + m_twoHanded = twoHanded; } -void Humanoid::setPrimaryHandFrameOverrides(String backFrameOverride, String frontFrameOverride) { - m_primaryHand.backFrame = !backFrameOverride.empty() ? std::move(backFrameOverride) : "rotation"; - m_primaryHand.frontFrame = !frontFrameOverride.empty() ? std::move(frontFrameOverride) : "rotation"; +void Humanoid::setHandFrameOverrides(ToolHand hand, StringView back, StringView front) { + auto& handInfo = const_cast<HandDrawingInfo&>(getHand(hand)); + // some users stick directives in these?? better make sure they don't break with custom clothing + size_t backEnd = back.utf8().find('?'); + size_t frontEnd = front.utf8().find('?'); + Directives backDirectives = backEnd == NPos ? Directives() : Directives( back.utf8().substr( backEnd)); + Directives frontDirectives = frontEnd == NPos ? Directives() : Directives(front.utf8().substr(frontEnd)); + if ( backEnd != NPos) back = back.utf8().substr(0, backEnd); + if (frontEnd != NPos) front = front.utf8().substr(0, frontEnd); + handInfo. backFrame = ! back.empty() ? std::move( back) : "rotation"; + handInfo.frontFrame = !front.empty() ? std::move(front) : "rotation"; + handInfo. backDirectives = ! backDirectives.empty() ? std::move( backDirectives) : Directives(); + handInfo.frontDirectives = !frontDirectives.empty() ? std::move(frontDirectives) : Directives(); } -void Humanoid::setPrimaryHandDrawables(List<Drawable> drawables) { - m_primaryHand.itemDrawables = std::move(drawables); +void Humanoid::setHandDrawables(ToolHand hand, List<Drawable> drawables) { + const_cast<HandDrawingInfo&>(getHand(hand)).itemDrawables = std::move(drawables); } -void Humanoid::setPrimaryHandNonRotatedDrawables(List<Drawable> drawables) { - m_primaryHand.nonRotatedDrawables = std::move(drawables); +void Humanoid::setHandNonRotatedDrawables(ToolHand hand, List<Drawable> drawables) { + const_cast<HandDrawingInfo&>(getHand(hand)).nonRotatedDrawables = std::move(drawables); } -bool Humanoid::primaryHandHoldingItem() const { - return m_primaryHand.holdingItem; -} - -void Humanoid::setAltHandParameters(bool holdingItem, float angle, float itemAngle, bool recoil, - bool outsideOfHand) { - m_altHand.holdingItem = holdingItem; - m_altHand.angle = angle; - m_altHand.itemAngle = itemAngle; - m_altHand.recoil = recoil; - m_altHand.outsideOfHand = outsideOfHand; -} - -void Humanoid::setAltHandFrameOverrides(String backFrameOverride, String frontFrameOverride) { - m_altHand.backFrame = !backFrameOverride.empty() ? std::move(backFrameOverride) : "rotation"; - m_altHand.frontFrame = !frontFrameOverride.empty() ? std::move(frontFrameOverride) : "rotation"; -} - -void Humanoid::setAltHandDrawables(List<Drawable> drawables) { - m_altHand.itemDrawables = std::move(drawables); -} - -void Humanoid::setAltHandNonRotatedDrawables(List<Drawable> drawables) { - m_altHand.nonRotatedDrawables = std::move(drawables); -} - -bool Humanoid::altHandHoldingItem() const { - return m_altHand.holdingItem; +bool Humanoid::handHoldingItem(ToolHand hand) const { + return getHand(hand).holdingItem; } void Humanoid::animate(float dt) { @@ -631,6 +617,7 @@ List<Drawable> Humanoid::render(bool withItems, bool withRotationAndScale) { String image = strf("{}:{}{}", frameSet, backHand.backFrame, directives.prefix()); Drawable backArm = Drawable::makeImage(std::move(image), 1.0f / TilePixels, true, backArmFrameOffset); backArm.imagePart().addDirectives(directives, true); + backArm.imagePart().addDirectives(backHand.backDirectives, true); backArm.rotate(backHand.angle, backArmFrameOffset + m_backArmRotationCenter + m_backArmOffset); return backArm; }; @@ -861,6 +848,7 @@ List<Drawable> Humanoid::render(bool withItems, bool withRotationAndScale) { String image = strf("{}:{}{}", frameSet, frontHand.frontFrame, directives.prefix()); Drawable frontArm = Drawable::makeImage(image, 1.0f / TilePixels, true, frontArmFrameOffset); frontArm.imagePart().addDirectives(directives, true); + frontArm.imagePart().addDirectives(frontHand.frontDirectives, true); frontArm.rotate(frontHand.angle, frontArmFrameOffset + m_frontArmRotationCenter); return frontArm; }; @@ -1233,6 +1221,10 @@ Vec2F Humanoid::altHandOffset(Direction facingDirection) const { return m_frontHandPosition - m_frontArmRotationCenter; } +Humanoid::HandDrawingInfo const& Humanoid::getHand(ToolHand hand) const { + return hand == ToolHand::Primary ? m_primaryHand : m_altHand; +} + String Humanoid::frameBase(State state) const { switch (state) { case State::Idle: diff --git a/source/game/StarHumanoid.hpp b/source/game/StarHumanoid.hpp index a3e9d19..a8162e7 100644 --- a/source/game/StarHumanoid.hpp +++ b/source/game/StarHumanoid.hpp @@ -36,6 +36,24 @@ enum class HumanoidEmote { extern EnumMap<HumanoidEmote> const HumanoidEmoteNames; size_t const EmoteSize = 14; +enum class HumanoidHand { + Idle, + Blabbering, + Shouting, + Happy, + Sad, + NEUTRAL, + Laugh, + Annoyed, + Oh, + OOOH, + Blink, + Wink, + Eat, + Sleep +}; +extern EnumMap<HumanoidEmote> const HumanoidEmoteNames; + struct Personality { String idle = "idle.1"; String armIdle = "idle.1"; @@ -194,20 +212,12 @@ public: // If not rotating, then the arms follow normal movement animation. The // angle parameter should be in the range [-pi/2, pi/2] (the facing direction // should not be included in the angle). - void setPrimaryHandParameters(bool holdingItem, float angle, float itemAngle, bool twoHanded, + void setHandParameters(ToolHand hand, bool holdingItem, float angle, float itemAngle, bool twoHanded, bool recoil, bool outsideOfHand); - void setPrimaryHandFrameOverrides(String backFrameOverride, String frontFrameOverride); - void setPrimaryHandDrawables(List<Drawable> drawables); - void setPrimaryHandNonRotatedDrawables(List<Drawable> drawables); - bool primaryHandHoldingItem() const; - - // Same as primary hand. - void setAltHandParameters(bool holdingItem, float angle, float itemAngle, bool recoil, - bool outsideOfHand); - void setAltHandFrameOverrides(String backFrameOverride, String frontFrameOverride); - void setAltHandDrawables(List<Drawable> drawables); - void setAltHandNonRotatedDrawables(List<Drawable> drawables); - bool altHandHoldingItem() const; + void setHandFrameOverrides(ToolHand hand, StringView back, StringView front); + void setHandDrawables(ToolHand hand, List<Drawable> drawables); + void setHandNonRotatedDrawables(ToolHand hand, List<Drawable> drawables); + bool handHoldingItem(ToolHand hand) const; // Updates the animation based on whatever the current animation state is, // wrapping or clamping animation time as appropriate. @@ -286,11 +296,15 @@ private: float itemAngle = 0.0f; String backFrame; String frontFrame; + Directives backDirectives; + Directives frontDirectives; float frameAngleAdjust = 0.0f; bool recoil = false; bool outsideOfHand = false; }; + HandDrawingInfo const& getHand(ToolHand hand) const; + String frameBase(State state) const; String emoteFrameBase(HumanoidEmote state) const; diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp index facde2e..151163f 100644 --- a/source/game/StarPlayer.cpp +++ b/source/game/StarPlayer.cpp @@ -1025,14 +1025,21 @@ void Player::update(float dt, uint64_t) { m_humanoid->setDance({}); bool isClient = world()->isClient(); - if (isClient) - m_armor->setupHumanoidClothingDrawables(*m_humanoid, forceNude()); m_tools->suppressItems(suppressedItems); m_tools->tick(dt, m_shifting, m_pendingMoves); - if (auto overrideFacingDirection = m_tools->setupHumanoidHandItems(*m_humanoid, position(), aimPosition())) - m_movementController->controlFace(*overrideFacingDirection); + Direction facingDirection = m_movementController->facingDirection(); + + auto overrideFacingDirection = m_tools->setupHumanoidHandItems(*m_humanoid, position(), aimPosition()); + if (overrideFacingDirection) + m_movementController->controlFace(facingDirection = *overrideFacingDirection); + + m_humanoid->setFacingDirection(facingDirection); + m_humanoid->setMovingBackwards(facingDirection != m_movementController->movingDirection()); + + if (isClient) + m_armor->setupHumanoidClothingDrawables(*m_humanoid, forceNude()); m_effectsAnimator->resetTransformationGroup("flip"); if (m_movementController->facingDirection() == Direction::Left) @@ -1074,7 +1081,7 @@ void Player::update(float dt, uint64_t) { m_effectEmitter->setSourcePosition("primary", handPosition(ToolHand::Primary) + position()); m_effectEmitter->setSourcePosition("alt", handPosition(ToolHand::Alt) + position()); - m_effectEmitter->setDirection(facingDirection()); + m_effectEmitter->setDirection(facingDirection); m_effectEmitter->tick(dt, *entityMode()); @@ -1089,7 +1096,7 @@ void Player::update(float dt, uint64_t) { } if (calculateHeadRotation) { // master or not an OpenStarbound player float headRotation = 0.f; - if (Humanoid::globalHeadRotation() && (m_humanoid->primaryHandHoldingItem() || m_humanoid->altHandHoldingItem() || m_humanoid->dance())) { + if (Humanoid::globalHeadRotation() && (m_humanoid->handHoldingItem(ToolHand::Primary) || m_humanoid->handHoldingItem(ToolHand::Alt) || m_humanoid->dance())) { auto primary = m_tools->primaryHandItem(); auto alt = m_tools->altHandItem(); String const disableFlag = "disableHeadRotation"; @@ -1108,9 +1115,6 @@ void Player::update(float dt, uint64_t) { } } - m_humanoid->setFacingDirection(m_movementController->facingDirection()); - m_humanoid->setMovingBackwards(m_movementController->facingDirection() != m_movementController->movingDirection()); - m_pendingMoves.clear(); if (isClient) diff --git a/source/game/StarPlayerInventory.hpp b/source/game/StarPlayerInventory.hpp index 911ffe3..fb5d531 100644 --- a/source/game/StarPlayerInventory.hpp +++ b/source/game/StarPlayerInventory.hpp @@ -158,7 +158,7 @@ public: void selectActionBarLocation(SelectedActionBarLocation selectedActionBarLocation); // Held items are either the items shortcutted to in the currently selected - // ActionBar primar / secondary locations, or if the swap slot is non-empty + // ActionBar primary / secondary locations, or if the swap slot is non-empty // then the swap slot. ItemPtr primaryHeldItem() const; ItemPtr secondaryHeldItem() const; diff --git a/source/game/StarToolUser.cpp b/source/game/StarToolUser.cpp index be239c1..8900bc7 100644 --- a/source/game/StarToolUser.cpp +++ b/source/game/StarToolUser.cpp @@ -207,8 +207,8 @@ List<Drawable> ToolUser::renderObjectPreviews(Vec2F aimPosition, Direction walki Maybe<Direction> ToolUser::setupHumanoidHandItems(Humanoid& humanoid, Vec2F position, Vec2F aimPosition) const { if (m_suppress.get() || !m_user) { - humanoid.setPrimaryHandParameters(false, 0.0f, 0.0f, false, false, false); - humanoid.setAltHandParameters(false, 0.0f, 0.0f, false, false); + humanoid.setHandParameters(ToolHand::Primary, false, 0.0f, 0.0f, false, false, false); + humanoid.setHandParameters(ToolHand::Alt, false, 0.0f, 0.0f, false, false, false); return {}; } @@ -216,10 +216,8 @@ Maybe<Direction> ToolUser::setupHumanoidHandItems(Humanoid& humanoid, Vec2F posi Maybe<Direction> overrideFacingDirection; auto setRotation = [&](bool holdingItem, float angle, float itemAngle, bool twoHanded, bool recoil, bool outsideOfHand) { - if (primary || twoHanded) - humanoid.setPrimaryHandParameters(holdingItem, angle, itemAngle, twoHanded, recoil, outsideOfHand); - else - humanoid.setAltHandParameters(holdingItem, angle, itemAngle, recoil, outsideOfHand); + ToolHand hand = primary || twoHanded ? ToolHand::Primary : ToolHand::Alt; + humanoid.setHandParameters(hand, holdingItem, angle, itemAngle, twoHanded, recoil, outsideOfHand); }; ItemPtr handItem = primary ? m_primaryHandItem.get() : m_altHandItem.get(); @@ -258,7 +256,7 @@ Maybe<Direction> ToolUser::setupHumanoidHandItems(Humanoid& humanoid, Vec2F posi Maybe<Direction> overrideFacingDirection; overrideFacingDirection = overrideFacingDirection.orMaybe(inner(true)); if (itemSafeTwoHanded(m_primaryHandItem.get())) - humanoid.setAltHandParameters(false, 0.0f, 0.0f, false, false); + humanoid.setHandParameters(ToolHand::Alt, false, 0.0f, 0.0f, false, false, false); else overrideFacingDirection = overrideFacingDirection.orMaybe(inner(false)); @@ -267,31 +265,31 @@ Maybe<Direction> ToolUser::setupHumanoidHandItems(Humanoid& humanoid, Vec2F posi void ToolUser::setupHumanoidHandItemDrawables(Humanoid& humanoid) const { if (m_suppress.get() || !m_user) { - humanoid.setPrimaryHandFrameOverrides("", ""); - humanoid.setAltHandFrameOverrides("", ""); - humanoid.setPrimaryHandDrawables({}); - humanoid.setAltHandDrawables({}); - humanoid.setPrimaryHandNonRotatedDrawables({}); - humanoid.setAltHandNonRotatedDrawables({}); + humanoid.setHandFrameOverrides(ToolHand::Primary, "", ""); + humanoid.setHandFrameOverrides(ToolHand::Alt, "", ""); + humanoid.setHandDrawables(ToolHand::Primary, {}); + humanoid.setHandDrawables(ToolHand::Alt, {}); + humanoid.setHandNonRotatedDrawables(ToolHand::Primary, {}); + humanoid.setHandNonRotatedDrawables(ToolHand::Alt, {}); return; } auto inner = [&](bool primary) { - auto setRotated = [&](String const& backFrameOverride, String const& frontFrameOverride, List<Drawable> drawables, bool twoHanded) { + auto setRotated = [&](String const& backFrame, String const& frontFrame, List<Drawable> drawables, bool twoHanded) { if (primary || twoHanded) { - humanoid.setPrimaryHandFrameOverrides(backFrameOverride, frontFrameOverride); - humanoid.setPrimaryHandDrawables(std::move(drawables)); + humanoid.setHandFrameOverrides(ToolHand::Primary, backFrame, frontFrame); + humanoid.setHandDrawables(ToolHand::Primary, std::move(drawables)); } else { - humanoid.setAltHandFrameOverrides(backFrameOverride, frontFrameOverride); - humanoid.setAltHandDrawables(std::move(drawables)); + humanoid.setHandFrameOverrides(ToolHand::Alt, backFrame, frontFrame); + humanoid.setHandDrawables(ToolHand::Alt, std::move(drawables)); } }; auto setNonRotated = [&](List<Drawable> drawables) { if (primary) - humanoid.setPrimaryHandNonRotatedDrawables(std::move(drawables)); + humanoid.setHandNonRotatedDrawables(ToolHand::Primary, std::move(drawables)); else - humanoid.setAltHandNonRotatedDrawables(std::move(drawables)); + humanoid.setHandNonRotatedDrawables(ToolHand::Alt, std::move(drawables)); }; ItemPtr handItem = primary ? m_primaryHandItem.get() : m_altHandItem.get(); @@ -321,9 +319,9 @@ void ToolUser::setupHumanoidHandItemDrawables(Humanoid& humanoid) const { inner(true); if (itemSafeTwoHanded(m_primaryHandItem.get())) { - humanoid.setAltHandFrameOverrides("", ""); - humanoid.setAltHandDrawables({}); - humanoid.setAltHandNonRotatedDrawables({}); + humanoid.setHandFrameOverrides(ToolHand::Alt, "", ""); + humanoid.setHandDrawables(ToolHand::Alt, {}); + humanoid.setHandNonRotatedDrawables(ToolHand::Alt, {}); } else { inner(false); } diff --git a/source/game/items/StarArmors.cpp b/source/game/items/StarArmors.cpp index 01ff4c4..97122b8 100644 --- a/source/game/items/StarArmors.cpp +++ b/source/game/items/StarArmors.cpp @@ -19,7 +19,16 @@ ArmorItem::ArmorItem(Json const& config, String const& directory, Json const& da else m_techModule = AssetPath::relativeTo(directory, *m_techModule); - m_directives = instanceValue("directives", "").toString(); + auto directives = instanceValue("directives", "").toString(); + m_directives = directives; + if (auto jFlipDirectives = instanceValue("flipDirectives"); jFlipDirectives.isType(Json::Type::String)) { + auto flipDirectives = jFlipDirectives.toString(); + if (flipDirectives.beginsWith('+')) + m_flipDirectives = Directives(directives + flipDirectives.substr(1)); + else + m_flipDirectives = Directives(std::move(flipDirectives)); + } + m_colorOptions = colorDirectivesFromConfig(config.getArray("colorOptions", JsonArray{""})); if (!m_directives) m_directives = "?" + m_colorOptions.wrap(instanceValue("colorIndex", 0).toUInt()); @@ -54,8 +63,12 @@ List<String> const& ArmorItem::colorOptions() { return m_colorOptions; } -Directives const& ArmorItem::directives() const { - return m_directives; +Directives const& ArmorItem::directives(bool flip) const { + return (flip && m_flipDirectives) ? *m_flipDirectives : m_directives; +} + +bool ArmorItem::flipping() const { + return m_flipDirectives.isValid(); } bool ArmorItem::hideBody() const { diff --git a/source/game/items/StarArmors.hpp b/source/game/items/StarArmors.hpp index 19847c7..a347ea9 100644 --- a/source/game/items/StarArmors.hpp +++ b/source/game/items/StarArmors.hpp @@ -29,9 +29,11 @@ public: virtual void fire(FireMode mode, bool shifting, bool edgeTriggered) override; virtual void fireTriggered() override; + List<String> const& colorOptions(); - Directives const& directives() const; + Directives const& directives(bool flip = false) const; + bool flipping() const; bool hideBody() const; @@ -45,6 +47,7 @@ private: List<PersistentStatusEffect> m_statusEffects; StringSet m_effectSources; Directives m_directives; + Maybe<Directives> m_flipDirectives; bool m_hideBody; Maybe<String> m_techModule; }; |