A player asked to build below vanilla size for small details. The new Shrink Hammer, craftable by any race, builds from 0.25 to 1; Trol's Hammer keeps 1 to 3. With either hammer, Alt + scroll in build mode changes the size in steps of 0.05, an Alt: Size row joins the build hints, and the size floats over the ghost when it is not the default. With the repair tool, the aimed piece shows the size it was built at. Both hammers get icons of their own.
52 lines
2.7 KiB
C#
52 lines
2.7 KiB
C#
using BepInEx.Configuration;
|
|
|
|
namespace RacesOfValheim
|
|
{
|
|
/// <summary>
|
|
/// The two numbers behind Trol's Hammer, bound as BepInEx ConfigEntry so they can be dragged in
|
|
/// Configuration Manager rather than recompiled - the same shape as WarVultureConfig.
|
|
///
|
|
/// Note what the switch does NOT do: turning the hammer off never un-scales anything already
|
|
/// standing. A piece carries its own size on its ZDO, and that is read back on load whatever
|
|
/// the config says, so a house built at 1.2 stays a house and not a pile of clipping walls.
|
|
/// The switch only decides whether NEW placements are enlarged.
|
|
/// </summary>
|
|
public static class TrolsHammerConfig
|
|
{
|
|
public static ConfigEntry<bool> Enabled;
|
|
public static ConfigEntry<float> ScaleFactor;
|
|
|
|
public static void Bind(ConfigFile config)
|
|
{
|
|
// No apostrophe, and not a typo: BepInEx rejects ' in a section name outright, and this
|
|
// Bind runs from the plugin's Awake - so "Trol's Hammer" did not merely fail to appear
|
|
// in Configuration Manager, it threw and took the whole mod's startup with it.
|
|
const string section = "Trols Hammer";
|
|
|
|
Enabled = config.Bind(section, "Enabled", true,
|
|
new ConfigDescription("Whether pieces placed with Trol's Hammer come out enlarged. " +
|
|
"Switching this off leaves every piece already built at the size " +
|
|
"it was built at; only new placements are affected."));
|
|
|
|
// Smaller than vanilla is the Shrink Hammer's job, so this one starts at 1.
|
|
ScaleFactor = config.Bind(section, "Scale factor", 1.2f,
|
|
new ConfigDescription("How much bigger than the vanilla piece. 1.2 is the +20% the " +
|
|
"hammer exists for. Hold Alt and scroll in build mode to change " +
|
|
"it in steps of 0.05. Cost and drop never change - this is size " +
|
|
"only.", new AcceptableValueRange<float>(1f, 3f)));
|
|
}
|
|
|
|
/// <summary>
|
|
/// The multiplier a new placement should use, or 1 when the hammer is switched off. Clamped
|
|
/// against a zero or negative value typed straight into the .cfg file, which the
|
|
/// Configuration Manager slider cannot produce but a text editor can - and a piece scaled to
|
|
/// zero is a piece that cannot be seen, hit or removed.
|
|
/// </summary>
|
|
public static float ActiveFactor()
|
|
{
|
|
if (Enabled == null || ScaleFactor == null) return 1f;
|
|
if (!Enabled.Value) return 1f;
|
|
return ScaleFactor.Value > 0.01f ? ScaleFactor.Value : 1f;
|
|
}
|
|
}
|
|
}
|