From bd4b1ed45c373a77cb717936a87f9515817a6a05 Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Mon, 21 Aug 2023 21:10:43 +1000 Subject: [PATCH] Update StarMaterialItem.cpp --- source/game/items/StarMaterialItem.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/source/game/items/StarMaterialItem.cpp b/source/game/items/StarMaterialItem.cpp index 42f2973..ca7b2de 100644 --- a/source/game/items/StarMaterialItem.cpp +++ b/source/game/items/StarMaterialItem.cpp @@ -35,12 +35,12 @@ MaterialItem::MaterialItem(Json const& config, String const& directory, Json con auto defaultParameters = Root::singleton().assets()->json("/items/defaultParameters.config"); setCooldownTime(config.queryFloat("materialItems.cooldown", defaultParameters.queryFloat("materialItems.cooldown"))); - m_blockRadius = instanceValue("blockRadius", defaultParameters.getFloat("blockRadius")).toFloat(); - m_altBlockRadius = instanceValue("altBlockRadius", defaultParameters.getFloat("altBlockRadius")).toFloat(); + m_blockRadius = config.getFloat("blockRadius", defaultParameters.getFloat("blockRadius")); + m_altBlockRadius = config.getFloat("altBlockRadius", defaultParameters.getFloat("altBlockRadius")); + m_collisionOverride = TileCollisionOverrideNames.maybeLeft(config.getString("collisionOverride", "None")).value(TileCollisionOverride::None); + //TODO: Work out a vanilla-compatible way to network the 3 above for visual reasons without storing as a parameter, because that prevents stacking. - auto multiplace = instanceValue("allowMultiplace", BlockCollisionSet.contains(materialDatabase->materialCollisionKind(m_material))); - if (multiplace.isType(Json::Type::Bool)) - m_multiplace = multiplace.toBool(); + m_multiplace = config.getBool("allowMultiplace", BlockCollisionSet.contains(materialDatabase->materialCollisionKind(m_material))); m_placeSounds = jsonToStringList(config.get("placeSounds", JsonArray())); if (m_placeSounds.empty()) { auto miningSound = materialDatabase->miningSound(m_material); @@ -54,7 +54,6 @@ MaterialItem::MaterialItem(Json const& config, String const& directory, Json con } m_shifting = false; m_lastTileAreaRadiusCache = 0.0f; - m_collisionOverride = TileCollisionOverrideNames.maybeLeft(instanceValue("collisionOverride", "None").toString()).value(TileCollisionOverride::None); } ItemPtr MaterialItem::clone() const { @@ -89,7 +88,6 @@ void MaterialItem::update(float dt, FireMode fireMode, bool shifting, HashSetaddSound("/sfx/tools/buildradiusgrow.wav", 1.0f, 1.0f + m_blockRadius / BlockRadiusLimit); } if (auto presses = input.bindDown("opensb", "buildingRadiusShrink")) { m_blockRadius = max(1, int(m_blockRadius - *presses)); - setInstanceValue("blockRadius", m_blockRadius); owner()->addSound("/sfx/tools/buildradiusshrink.wav", 1.0f, 1.0f + m_blockRadius / BlockRadiusLimit); } }