Botany composting & shovel/spade (or, make botany sustainable) (#3064)

* Botany: Introduce shovel and spade into hydro\_tools

* Botany: Add shovel/spade (just removes plants)

* Botany: Add shovel/spade lathe recipes and make all botany lathe recipes accessible

* Botany: Add spade into Saltern

* Botany: Give Saltern a bucket for the botanist

* Botany: Plant produce can be composted for nutriment/etc.

* Botany: Bye-bye duplicated force update code, hello ForceUpdateByExternalCause

* Botany: Shovel identity crisis resolved (thanks Paul)
This commit is contained in:
20kdc
2021-02-01 22:46:20 +00:00
committed by GitHub
parent 633a6b3ab9
commit 80ad2ef5b7
9 changed files with 126 additions and 7 deletions

View File

@@ -639,6 +639,13 @@ namespace Content.Server.GameObjects.Components.Botany
Seed = Seed.Diverge(modified);
}
private void ForceUpdateByExternalCause()
{
SkipAging++; // We're forcing an update cycle, so one age hasn't passed.
ForceUpdate = true;
Update();
}
public async Task<bool> InteractUsing(InteractUsingEventArgs eventArgs)
{
var user = eventArgs.User;
@@ -695,6 +702,22 @@ namespace Content.Server.GameObjects.Components.Botany
return true;
}
if (usingItem.HasComponent<ShovelComponent>())
{
if (Seed != null)
{
user.PopupMessageCursor(Loc.GetString("You remove the plant from the {0}.", Owner.Name));
user.PopupMessageOtherClients(Loc.GetString("{0} removes the plant.", user.Name));
RemovePlant();
}
else
{
user.PopupMessageCursor(Loc.GetString("There is no plant to remove."));
}
return true;
}
if (usingItem.TryGetComponent(out SolutionContainerComponent? solution) && solution.CanRemoveSolutions)
{
var amount = 5f;
@@ -715,9 +738,7 @@ namespace Content.Server.GameObjects.Components.Botany
_solutionContainer?.TryAddSolution(split);
SkipAging++; // We're forcing an update cycle, so one age hasn't passed.
ForceUpdate = true;
Update();
ForceUpdateByExternalCause();
return true;
}
@@ -752,9 +773,7 @@ namespace Content.Server.GameObjects.Components.Botany
// Just in case.
CheckLevelSanity();
SkipAging++; // We're forcing an update cycle, so one age hasn't passed.
ForceUpdate = true;
Update();
ForceUpdateByExternalCause();
return true;
}
@@ -764,6 +783,24 @@ namespace Content.Server.GameObjects.Components.Botany
return DoHarvest(user);
}
if (usingItem.HasComponent<ProduceComponent>())
{
user.PopupMessageCursor(Loc.GetString("You compost {1:theName} into {0:theName}.", Owner, usingItem));
user.PopupMessageOtherClients(Loc.GetString("{0:TheName} composts {1:theName} into {2:theName}.", user, usingItem, Owner));
if (usingItem.TryGetComponent(out SolutionContainerComponent? solution2))
{
// This deliberately discards overfill.
_solutionContainer?.TryAddSolution(solution2.SplitSolution(solution2.Solution.TotalVolume));
ForceUpdateByExternalCause();
}
usingItem.Delete();
return true;
}
return false;
}

View File

@@ -0,0 +1,11 @@
#nullable enable
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.Components.Botany
{
[RegisterComponent]
public class ShovelComponent : Component
{
public override string Name => "Shovel";
}
}