Armor Item improvements (& other misc)
TODO: Make option to return to previewing with dummy
This commit is contained in:
parent
aa0ef06ac6
commit
0c2015118b
@ -939,28 +939,55 @@ Humanoid Humanoid::makeDummy(Gender gender) {
|
|||||||
return humanoid;
|
return humanoid;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Drawable> Humanoid::renderDummy(Gender gender, HeadArmor const* head, ChestArmor const* chest, LegsArmor const* legs, BackArmor const* back) {
|
List<Drawable> Humanoid::renderDummy(Gender gender, Maybe<HeadArmor const*> head, Maybe<ChestArmor const*> chest, Maybe<LegsArmor const*> legs, Maybe<BackArmor const*> back) {
|
||||||
if (head) {
|
if (head) {
|
||||||
setHeadArmorFrameset(head->frameset(gender));
|
if (auto headPtr = *head) {
|
||||||
setHeadArmorDirectives(head->directives());
|
setHeadArmorFrameset(headPtr->frameset(gender));
|
||||||
setHelmetMaskDirectives(head->maskDirectives());
|
setHeadArmorDirectives(headPtr->directives());
|
||||||
|
setHelmetMaskDirectives(headPtr->maskDirectives());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setHeadArmorFrameset("");
|
||||||
|
setHeadArmorDirectives("");
|
||||||
|
setHelmetMaskDirectives("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chest) {
|
if (chest) {
|
||||||
setBackSleeveFrameset(chest->backSleeveFrameset(gender));
|
if (auto chestPtr = *chest) {
|
||||||
setFrontSleeveFrameset(chest->frontSleeveFrameset(gender));
|
setBackSleeveFrameset(chestPtr->backSleeveFrameset(gender));
|
||||||
setChestArmorFrameset(chest->bodyFrameset(gender));
|
setFrontSleeveFrameset(chestPtr->frontSleeveFrameset(gender));
|
||||||
setChestArmorDirectives(chest->directives());
|
setChestArmorFrameset(chestPtr->bodyFrameset(gender));
|
||||||
|
setChestArmorDirectives(chestPtr->directives());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setBackSleeveFrameset("");
|
||||||
|
setFrontSleeveFrameset("");
|
||||||
|
setChestArmorFrameset("");
|
||||||
|
setChestArmorDirectives("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (legs) {
|
if (legs) {
|
||||||
setLegsArmorFrameset(legs->frameset(gender));
|
if (auto legsPtr = *legs) {
|
||||||
setLegsArmorDirectives(legs->directives());
|
setLegsArmorFrameset(legsPtr->frameset(gender));
|
||||||
|
setLegsArmorDirectives(legsPtr->directives());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setLegsArmorFrameset("");
|
||||||
|
setLegsArmorDirectives("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (back) {
|
if (back) {
|
||||||
setBackArmorFrameset(back->frameset(gender));
|
if (auto backPtr = *back) {
|
||||||
setBackArmorDirectives(back->directives());
|
setBackArmorFrameset(backPtr->frameset(gender));
|
||||||
|
setBackArmorDirectives(backPtr->directives());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setBackArmorFrameset("");
|
||||||
|
setBackArmorDirectives("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto drawables = render();
|
auto drawables = render();
|
||||||
|
@ -208,8 +208,8 @@ public:
|
|||||||
static Humanoid makeDummy(Gender gender);
|
static Humanoid makeDummy(Gender gender);
|
||||||
// Renders to centered drawables (centered on the normal image center for the
|
// Renders to centered drawables (centered on the normal image center for the
|
||||||
// player graphics), (in pixels, not world space)
|
// player graphics), (in pixels, not world space)
|
||||||
List<Drawable> renderDummy(Gender gender, HeadArmor const* head = nullptr, ChestArmor const* chest = nullptr,
|
List<Drawable> renderDummy(Gender gender, Maybe<HeadArmor const*> head = {}, Maybe<ChestArmor const*> chest = {},
|
||||||
LegsArmor const* legs = nullptr, BackArmor const* back = nullptr);
|
Maybe<LegsArmor const*> legs = {}, Maybe<BackArmor const*> back = {});
|
||||||
|
|
||||||
Vec2F primaryHandPosition(Vec2F const& offset) const;
|
Vec2F primaryHandPosition(Vec2F const& offset) const;
|
||||||
Vec2F altHandPosition(Vec2F const& offset) const;
|
Vec2F altHandPosition(Vec2F const& offset) const;
|
||||||
|
@ -382,7 +382,7 @@ void ItemDrop::updateTaken(bool master) {
|
|||||||
targetPosition += m_overheadOffset;
|
targetPosition += m_overheadOffset;
|
||||||
auto rect = owningEntity->collisionArea();
|
auto rect = owningEntity->collisionArea();
|
||||||
if (!rect.isNull())
|
if (!rect.isNull())
|
||||||
targetPosition[1] += rect.yMax() + 1.5;
|
targetPosition[1] += rect.yMax() + 1.5f;
|
||||||
else
|
else
|
||||||
targetPosition[1] += 1.5f;
|
targetPosition[1] += 1.5f;
|
||||||
}
|
}
|
||||||
|
@ -1151,7 +1151,7 @@ ItemPtr Player::pickupItems(ItemPtr const& items) {
|
|||||||
if (items->pickupSound().size()) {
|
if (items->pickupSound().size()) {
|
||||||
m_effectsAnimator->setSoundPool("pickup", {items->pickupSound()});
|
m_effectsAnimator->setSoundPool("pickup", {items->pickupSound()});
|
||||||
float pitch = 1.f - ((float)items->count() / (float)items->maxStack()) * 0.5f;
|
float pitch = 1.f - ((float)items->count() / (float)items->maxStack()) * 0.5f;
|
||||||
m_effectsAnimator->setSoundPitchMultiplier("pickup", clamp(pitch * Random::randf(0.9f, 1.1f), 0.f, 2.f));
|
m_effectsAnimator->setSoundPitchMultiplier("pickup", clamp(pitch * Random::randf(0.8f, 1.2f), 0.f, 2.f));
|
||||||
m_effectsAnimator->playSound("pickup");
|
m_effectsAnimator->playSound("pickup");
|
||||||
}
|
}
|
||||||
auto itemDb = Root::singleton().itemDatabase();
|
auto itemDb = Root::singleton().itemDatabase();
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
namespace Star {
|
namespace Star {
|
||||||
|
|
||||||
ArmorItem::ArmorItem(Json const& config, String const& directory, Json const& data) : Item(config, directory, data) {
|
ArmorItem::ArmorItem(Json const& config, String const& directory, Json const& data) : Item(config, directory, data), SwingableItem(config) {
|
||||||
refreshStatusEffects();
|
refreshStatusEffects();
|
||||||
m_effectSources = jsonToStringSet(instanceValue("effectSources", JsonArray()));
|
m_effectSources = jsonToStringSet(instanceValue("effectSources", JsonArray()));
|
||||||
m_techModule = instanceValue("techModule", "").toString();
|
m_techModule = instanceValue("techModule", "").toString();
|
||||||
@ -36,6 +36,20 @@ StringSet ArmorItem::effectSources() const {
|
|||||||
return m_effectSources;
|
return m_effectSources;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
List<Drawable> ArmorItem::drawables() const {
|
||||||
|
auto drawables = iconDrawables();
|
||||||
|
Drawable::scaleAll(drawables, 1.0f / TilePixels);
|
||||||
|
Drawable::translateAll(drawables, -handPosition() / TilePixels);
|
||||||
|
return drawables;
|
||||||
|
}
|
||||||
|
|
||||||
|
float ArmorItem::getAngle(float aimAngle) {
|
||||||
|
return -25.0f * Constants::deg2rad;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ArmorItem::fire(FireMode mode, bool shifting, bool edgeTriggered) {}
|
||||||
|
void ArmorItem::fireTriggered() {}
|
||||||
|
|
||||||
List<String> const& ArmorItem::colorOptions() {
|
List<String> const& ArmorItem::colorOptions() {
|
||||||
return m_colorOptions;
|
return m_colorOptions;
|
||||||
}
|
}
|
||||||
@ -113,9 +127,9 @@ Directives const& HeadArmor::maskDirectives() const {
|
|||||||
|
|
||||||
List<Drawable> HeadArmor::preview(PlayerPtr const& viewer) const {
|
List<Drawable> HeadArmor::preview(PlayerPtr const& viewer) const {
|
||||||
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
||||||
Humanoid humanoid = Humanoid::makeDummy(gender);
|
//Humanoid humanoid = Humanoid::makeDummy(gender);
|
||||||
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
||||||
return humanoid.renderDummy(gender, this);
|
return humanoid.renderDummy(gender, this, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
ChestArmor::ChestArmor(Json const& config, String const& directory, Json const& data)
|
ChestArmor::ChestArmor(Json const& config, String const& directory, Json const& data)
|
||||||
@ -158,9 +172,9 @@ String const& ChestArmor::backSleeveFrameset(Gender gender) const {
|
|||||||
|
|
||||||
List<Drawable> ChestArmor::preview(PlayerPtr const& viewer) const {
|
List<Drawable> ChestArmor::preview(PlayerPtr const& viewer) const {
|
||||||
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
||||||
Humanoid humanoid = Humanoid::makeDummy(gender);
|
//Humanoid humanoid = Humanoid::makeDummy(gender);
|
||||||
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
||||||
return humanoid.renderDummy(gender, nullptr, this);
|
return humanoid.renderDummy(gender, nullptr, this, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
LegsArmor::LegsArmor(Json const& config, String const& directory, Json const& data)
|
LegsArmor::LegsArmor(Json const& config, String const& directory, Json const& data)
|
||||||
@ -182,9 +196,9 @@ String const& LegsArmor::frameset(Gender gender) const {
|
|||||||
|
|
||||||
List<Drawable> LegsArmor::preview(PlayerPtr const& viewer) const {
|
List<Drawable> LegsArmor::preview(PlayerPtr const& viewer) const {
|
||||||
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
||||||
Humanoid humanoid = Humanoid::makeDummy(gender);
|
//Humanoid humanoid = Humanoid::makeDummy(gender);
|
||||||
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
||||||
return humanoid.renderDummy(gender, nullptr, nullptr, this);
|
return humanoid.renderDummy(gender, nullptr, nullptr, this, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
BackArmor::BackArmor(Json const& config, String const& directory, Json const& data)
|
BackArmor::BackArmor(Json const& config, String const& directory, Json const& data)
|
||||||
@ -206,8 +220,8 @@ String const& BackArmor::frameset(Gender gender) const {
|
|||||||
|
|
||||||
List<Drawable> BackArmor::preview(PlayerPtr const& viewer) const {
|
List<Drawable> BackArmor::preview(PlayerPtr const& viewer) const {
|
||||||
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
Gender gender = viewer ? viewer->gender() : Gender::Male;
|
||||||
Humanoid humanoid = Humanoid::makeDummy(gender);
|
//Humanoid humanoid = Humanoid::makeDummy(gender);
|
||||||
//Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
Humanoid humanoid = viewer ? *viewer->humanoid() : Humanoid::makeDummy(gender);
|
||||||
return humanoid.renderDummy(gender, nullptr, nullptr, nullptr, this);
|
return humanoid.renderDummy(gender, nullptr, nullptr, nullptr, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "StarStatusEffectItem.hpp"
|
#include "StarStatusEffectItem.hpp"
|
||||||
#include "StarEffectSourceItem.hpp"
|
#include "StarEffectSourceItem.hpp"
|
||||||
#include "StarPreviewableItem.hpp"
|
#include "StarPreviewableItem.hpp"
|
||||||
|
#include "StarSwingableItem.hpp"
|
||||||
namespace Star {
|
namespace Star {
|
||||||
|
|
||||||
STAR_CLASS(ArmorItem);
|
STAR_CLASS(ArmorItem);
|
||||||
@ -15,7 +15,7 @@ STAR_CLASS(ChestArmor);
|
|||||||
STAR_CLASS(LegsArmor);
|
STAR_CLASS(LegsArmor);
|
||||||
STAR_CLASS(BackArmor);
|
STAR_CLASS(BackArmor);
|
||||||
|
|
||||||
class ArmorItem : public Item, public StatusEffectItem, public EffectSourceItem {
|
class ArmorItem : public Item, public EffectSourceItem, public SwingableItem {
|
||||||
public:
|
public:
|
||||||
ArmorItem(Json const& config, String const& directory, Json const& data);
|
ArmorItem(Json const& config, String const& directory, Json const& data);
|
||||||
virtual ~ArmorItem() {}
|
virtual ~ArmorItem() {}
|
||||||
@ -23,6 +23,13 @@ public:
|
|||||||
virtual List<PersistentStatusEffect> statusEffects() const override;
|
virtual List<PersistentStatusEffect> statusEffects() const override;
|
||||||
virtual StringSet effectSources() const override;
|
virtual StringSet effectSources() const override;
|
||||||
|
|
||||||
|
virtual List<Drawable> drawables() const override;
|
||||||
|
|
||||||
|
virtual float getAngle(float aimAngle) override;
|
||||||
|
|
||||||
|
virtual void fire(FireMode mode, bool shifting, bool edgeTriggered) override;
|
||||||
|
virtual void fireTriggered() override;
|
||||||
|
|
||||||
List<String> const& colorOptions();
|
List<String> const& colorOptions();
|
||||||
|
|
||||||
Directives const& directives() const;
|
Directives const& directives() const;
|
||||||
|
@ -337,6 +337,14 @@ BeamMiningTool::BeamMiningTool(Json const& config, String const& directory, Json
|
|||||||
m_blockVolume = assets->json("/sfx.config:miningBlockVolume").toFloat();
|
m_blockVolume = assets->json("/sfx.config:miningBlockVolume").toFloat();
|
||||||
m_endType = EndType::Object;
|
m_endType = EndType::Object;
|
||||||
|
|
||||||
|
if (auto jRate = instanceValue("scaleRate")) {
|
||||||
|
if (jRate.canConvert(Json::Type::Float)) {
|
||||||
|
float rate = jRate.toFloat();
|
||||||
|
m_tileDamage /= rate;
|
||||||
|
m_cooldownTime /= rate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_inhandStatusEffects = instanceValue("inhandStatusEffects", JsonArray()).toArray().transformed(jsonToPersistentStatusEffect);
|
m_inhandStatusEffects = instanceValue("inhandStatusEffects", JsonArray()).toArray().transformed(jsonToPersistentStatusEffect);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +367,10 @@ List<PreviewTile> BeamMiningTool::preview(bool shifting) const {
|
|||||||
|
|
||||||
if (ownerp && worldp) {
|
if (ownerp && worldp) {
|
||||||
if (ownerp->isAdmin() || ownerp->inToolRange()) {
|
if (ownerp->isAdmin() || ownerp->inToolRange()) {
|
||||||
Vec3B light = Color::rgba(ownerp->favoriteColor()).toRgb();
|
Color lightColor = Color::rgba(ownerp->favoriteColor());
|
||||||
|
if (!ready())
|
||||||
|
lightColor *= Color::rgbaf(0.75f, 0.75f, 0.75f, 1.0f);
|
||||||
|
Vec3B light = lightColor.toRgb();
|
||||||
int radius = !shifting ? m_blockRadius : m_altBlockRadius;
|
int radius = !shifting ? m_blockRadius : m_altBlockRadius;
|
||||||
for (auto pos : tileAreaBrush(radius, ownerp->aimPosition(), true)) {
|
for (auto pos : tileAreaBrush(radius, ownerp->aimPosition(), true)) {
|
||||||
if (worldp->tileIsOccupied(pos, TileLayer::Foreground, true)) {
|
if (worldp->tileIsOccupied(pos, TileLayer::Foreground, true)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user