Skip to content

Commit

Permalink
Allow goblin to eat open mail only
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed May 3, 2024
1 parent d009322 commit f890786
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 21 deletions.
12 changes: 6 additions & 6 deletions Content.Server/Body/Components/StomachComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,24 +74,24 @@ public ReagentDelta(ReagentQuantity reagentQuantity)
/// Frontier - Used by goblin for fliping the food quility effects
/// </summary>
[DataField]
public bool ReverseFoodQuality;
public bool ReverseFoodQuality = false;

/// <summary>
/// Frontier - Allow eating trash
/// Frontier - Allow eating mail TODO: Move this to a switch before fully added.
/// </summary>
[DataField]
public bool TrashDigestion;
public bool MailDigestion = false;

/// <summary>
/// Frontier - Allow eating fiber like food (Moth food)
/// </summary>
[DataField]
public bool FiberDigestion;
public bool FiberDigestion = false;

/// <summary>
/// Frontier - Allow eating mail TODO: Move this to a switch before fully added.
/// Frontier - Allow eating trash
/// </summary>
[DataField]
public bool MailDigestion;
public bool TrashDigestion = false;
}
}
3 changes: 2 additions & 1 deletion Content.Server/Nutrition/Components/FoodComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
using Content.Shared.FixedPoint;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Content.Server.Mail; // Frontier

using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array;

namespace Content.Server.Nutrition.Components;

[RegisterComponent, Access(typeof(FoodSystem))]
[RegisterComponent, Access(typeof(FoodSystem), typeof(MailSystem))] // Frontier
public sealed partial class FoodComponent : Component
{
[DataField]
Expand Down
40 changes: 27 additions & 13 deletions Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg

/// Frontier - Food quality system
var foodQuality = entity.Comp.Quality;
//var showFlavors = true; // Frontier
var showFlavors = true;

foreach (var quality in foodQuality)
{
Expand All @@ -289,7 +289,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
entity.Comp.FinalQuality = "Nasty";
else if (quality == "Toxin")
entity.Comp.FinalQuality = "Toxin";
else if (quality == "Trash")
else if ((quality == "Trash") || (quality == "Mail") || (quality == "Fiber"))
entity.Comp.FinalQuality = "Trash";

if (reverseFoodQuality)
Expand All @@ -312,8 +312,8 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
var damagingRegent = "Toxin";
var emoteId = "Laugh";

//var msgNasty = Loc.GetString("food-system-nasty", ("used", args.Used), ("target", args.Target));
//var msgToxin = Loc.GetString("food-system-toxin", ("used", args.Used), ("target", args.Target));
var msgNasty = Loc.GetString("food-system-nasty", ("used", args.Used), ("target", args.Target));
var msgToxin = Loc.GetString("food-system-toxin", ("used", args.Used), ("target", args.Target));

TryComp<BloodstreamComponent>(args.Target.Value, out var bloodStream);

Expand Down Expand Up @@ -363,8 +363,8 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
{
if (reverseFoodQuality)
{
//showFlavors = false; // Frontier
//_popup.PopupEntity(msgNasty, args.Target.Value, args.User);
showFlavors = false;
_popup.PopupEntity(msgNasty, args.Target.Value, args.User);

if (_solutionContainer.ResolveSolution(stomachToUse.Owner, stomachToUse.BodySolutionName, ref stomachToUse.Solution))
_solutionContainer.RemoveReagent(stomachToUse.Solution.Value, "Flavorol", FixedPoint2.New((int) transferAmount)); // Remove from body before it goes to blood
Expand All @@ -378,8 +378,8 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
{
if (reverseFoodQuality)
{
//showFlavors = false; // Frontier
//_popup.PopupEntity(msgToxin, args.Target.Value, args.User);
showFlavors = false;
_popup.PopupEntity(msgToxin, args.Target.Value, args.User);

if (_solutionContainer.ResolveSolution(stomachToUse.Owner, stomachToUse.BodySolutionName, ref stomachToUse.Solution))
_solutionContainer.RemoveReagent(stomachToUse.Solution.Value, "Flavorol", FixedPoint2.New((int) transferAmount)); // Remove from body before it goes to blood
Expand All @@ -405,14 +405,15 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
_solutionContainer.TryAddReagent(bloodStream.ChemicalSolution.Value, speedRegent, FixedPoint2.New((int) transferAmount), out _); // Add to blood
}
}
/// Frontier - Food quality system end

var flavors = args.FlavorMessage;

if (forceFeed)
{
var targetName = Identity.Entity(args.Target.Value, EntityManager);
var userName = Identity.Entity(args.User, EntityManager);
//if (showFlavors) // Frontier
if (showFlavors) // Frontier
_popup.PopupEntity(Loc.GetString("food-system-force-feed-success", ("user", userName), ("flavors", flavors)), entity.Owner, entity.Owner);

_popup.PopupEntity(Loc.GetString("food-system-force-feed-success-user", ("target", targetName)), args.User, args.User);
Expand All @@ -422,7 +423,7 @@ private void OnDoAfter(Entity<FoodComponent> entity, ref ConsumeDoAfterEvent arg
}
else
{
//if (showFlavors) // Frontier
if (showFlavors) // Frontier
_popup.PopupEntity(Loc.GetString(entity.Comp.EatMessage, ("food", entity.Owner), ("flavors", flavors)), args.User, args.User);

// log successful voluntary eating
Expand Down Expand Up @@ -553,10 +554,23 @@ private bool IsDigestibleBy(EntityUid food, FoodComponent component, List<(Stoma
// Run through the mobs' stomachs
foreach (var (comp, _) in stomachs)
{
// Frontier - Allow trash eating
if (!comp.TrashDigestion && component.Quality.Contains("Trash"))
// Frontier - Food system hack job
var foodQuality = component.Quality;
var allowEating = true;
foreach (var quality in foodQuality)
{
if (!comp.MailDigestion && quality == "Mail")
allowEating = true;
else if (!comp.FiberDigestion && quality == "Fiber")
allowEating = true;
else if (!comp.TrashDigestion && quality == "Trash")
allowEating = true;
else
allowEating = false;
}
if (allowEating)
return false;
// Frontier - Allow trash eating
// Frontier - Food system hack job

// Find a stomach with a SpecialDigestible
if (comp.SpecialDigestible == null)
Expand Down
3 changes: 3 additions & 0 deletions Content.Server/Nyanotrasen/Mail/MailSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,9 @@ public void OpenMail(EntityUid uid, MailComponent? component = null, EntityUid?
_handsSystem.PickupOrDrop(user, entity);
}

if (TryComp<FoodComponent>(uid, out var food)) // Frontier
food.Quality = new string[] { "Mail", "Fiber", "Trash" };

_tagSystem.AddTag(uid, "Trash");
_tagSystem.AddTag(uid, "Recyclable");
component.IsEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
Blunt: 10
- type: CargoSellBlacklist
- type: Food # Frontier
quality: Trash # Frontier, New Food Quality System
quality: Mail # Frontier, New Food Quality System
- type: SolutionContainerManager
solutions:
food:
Expand Down

0 comments on commit f890786

Please sign in to comment.