Added repair fires feature - v1.2.2
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoRefillFires
|
||||
{
|
||||
@@ -130,55 +130,11 @@ namespace AutoRefillFires
|
||||
|
||||
private bool ShouldRefillFireplace(Fireplace fireplace)
|
||||
{
|
||||
string objectName = fireplace.gameObject.name.Replace("(Clone)", "").ToLowerInvariant();
|
||||
|
||||
bool result;
|
||||
string matchedRule;
|
||||
|
||||
if (objectName.Contains("candle"))
|
||||
{
|
||||
result = false;
|
||||
matchedRule = "IgnoredCandle";
|
||||
}
|
||||
if (objectName.Contains("fire_pit") || objectName.Contains("firepit"))
|
||||
{
|
||||
result = _config.FillCampfires.Value;
|
||||
matchedRule = "FillCampfires";
|
||||
}
|
||||
else if (objectName.Contains("hearth"))
|
||||
{
|
||||
result = _config.FillHearths.Value;
|
||||
matchedRule = "FillHearths";
|
||||
}
|
||||
else if (objectName.Contains("groundtorch"))
|
||||
{
|
||||
result = _config.FillStandingTorches.Value;
|
||||
matchedRule = "FillStandingTorches";
|
||||
}
|
||||
else if (objectName.Contains("walltorch"))
|
||||
{
|
||||
result = _config.FillWallTorches.Value;
|
||||
matchedRule = "FillWallTorches";
|
||||
}
|
||||
else if (objectName.Contains("brazier"))
|
||||
{
|
||||
result = _config.FillBraziers.Value;
|
||||
matchedRule = "FillBraziers";
|
||||
}
|
||||
else if (objectName.Contains("bonfire"))
|
||||
{
|
||||
result = _config.FillBonfires.Value;
|
||||
matchedRule = "FillBonfires";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = _config.FillOtherFireplaces.Value;
|
||||
matchedRule = "FillOtherFireplaces";
|
||||
}
|
||||
bool result = FireplaceTypeFilter.IsEnabled(_config, fireplace, out string matchedRule);
|
||||
|
||||
_log.Debug(
|
||||
$"ShouldRefillFireplace: name='{fireplace.gameObject.name}', " +
|
||||
$"normalized='{objectName}', matchedRule={matchedRule}, result={result}"
|
||||
$"matchedRule={matchedRule}, result={result}"
|
||||
);
|
||||
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace AutoRefillFires
|
||||
{
|
||||
internal static class FireplaceTypeFilter
|
||||
{
|
||||
public static bool IsEnabled(ModConfig config, Fireplace fireplace, out string matchedRule)
|
||||
{
|
||||
string objectName = fireplace.gameObject.name.Replace("(Clone)", "").ToLowerInvariant();
|
||||
|
||||
if (objectName.Contains("candle"))
|
||||
{
|
||||
matchedRule = "IgnoredCandle";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (objectName.Contains("fire_pit") || objectName.Contains("firepit"))
|
||||
{
|
||||
matchedRule = "FillCampfires";
|
||||
return config.FillCampfires.Value;
|
||||
}
|
||||
|
||||
if (objectName.Contains("hearth"))
|
||||
{
|
||||
matchedRule = "FillHearths";
|
||||
return config.FillHearths.Value;
|
||||
}
|
||||
|
||||
if (objectName.Contains("groundtorch"))
|
||||
{
|
||||
matchedRule = "FillStandingTorches";
|
||||
return config.FillStandingTorches.Value;
|
||||
}
|
||||
|
||||
if (objectName.Contains("walltorch"))
|
||||
{
|
||||
matchedRule = "FillWallTorches";
|
||||
return config.FillWallTorches.Value;
|
||||
}
|
||||
|
||||
if (objectName.Contains("brazier"))
|
||||
{
|
||||
matchedRule = "FillBraziers";
|
||||
return config.FillBraziers.Value;
|
||||
}
|
||||
|
||||
if (objectName.Contains("bonfire"))
|
||||
{
|
||||
matchedRule = "FillBonfires";
|
||||
return config.FillBonfires.Value;
|
||||
}
|
||||
|
||||
matchedRule = "FillOtherFireplaces";
|
||||
return config.FillOtherFireplaces.Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoRefillFires
|
||||
{
|
||||
@@ -6,12 +6,14 @@ namespace AutoRefillFires
|
||||
{
|
||||
private readonly ModConfig _config;
|
||||
private readonly FuelManager _fuelManager;
|
||||
private readonly RepairManager _repairManager;
|
||||
private readonly ModLogger _log;
|
||||
|
||||
public HotTubRefiller(ModConfig config, FuelManager fuelManager, ModLogger log)
|
||||
public HotTubRefiller(ModConfig config, FuelManager fuelManager, RepairManager repairManager, ModLogger log)
|
||||
{
|
||||
_config = config;
|
||||
_fuelManager = fuelManager;
|
||||
_repairManager = repairManager;
|
||||
_log = log;
|
||||
}
|
||||
|
||||
@@ -41,6 +43,7 @@ namespace AutoRefillFires
|
||||
$"distance={distance:0.0}m"
|
||||
);
|
||||
|
||||
_repairManager.TryRepair(player, smelter, "hot tub");
|
||||
TryRefillHotTub(player, smelter, containers);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AutoRefillFires
|
||||
@@ -8,6 +8,7 @@ namespace AutoRefillFires
|
||||
private readonly ModConfig _config;
|
||||
private readonly FireplaceRefiller _fireplaceRefiller;
|
||||
private readonly HotTubRefiller _hotTubRefiller;
|
||||
private readonly RepairManager _repairManager;
|
||||
private readonly ModLogger _log;
|
||||
|
||||
public RefillManager(ModConfig config, ModLogger log)
|
||||
@@ -17,7 +18,8 @@ namespace AutoRefillFires
|
||||
|
||||
FuelManager fuelManager = new FuelManager(_config, _log);
|
||||
_fireplaceRefiller = new FireplaceRefiller(_config, fuelManager, _log);
|
||||
_hotTubRefiller = new HotTubRefiller(_config, fuelManager, _log);
|
||||
_repairManager = new RepairManager(_config, _log);
|
||||
_hotTubRefiller = new HotTubRefiller(_config, fuelManager, _repairManager, _log);
|
||||
}
|
||||
|
||||
public void Run(Player player)
|
||||
@@ -100,6 +102,9 @@ namespace AutoRefillFires
|
||||
$"distance={candidate.Distance:0.0}m"
|
||||
);
|
||||
|
||||
if (FireplaceTypeFilter.IsEnabled(_config, candidate.Fireplace, out string matchedRule))
|
||||
_repairManager.TryRepair(player, candidate.Fireplace, matchedRule);
|
||||
|
||||
_fireplaceRefiller.TryRefill(player, candidate.Fireplace, containers);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user