Skip to content

Commit

Permalink
Goblin FoodSystem Part1
Browse files Browse the repository at this point in the history
  • Loading branch information
dvir001 committed Jan 25, 2024
1 parent c1e263a commit 1b0891f
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Content.Server/Body/Components/StomachComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Content.Server.Body.Systems;
using Content.Server.Body.Systems;
using Content.Server.Nutrition.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
Expand Down Expand Up @@ -59,5 +59,11 @@ public ReagentDelta(ReagentQuantity reagentQuantity)

public void Increment(float delta) => Lifetime += delta;
}

/// <summary>
/// Frontier - Used by goblin for fliping the food quility effects
/// </summary>
[DataField]
public bool ReverseFoodQuality;
}
}
16 changes: 16 additions & 0 deletions Content.Server/Nutrition/Components/FoodComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

namespace Content.Server.Nutrition.Components;

public enum Quality : byte // Frontier
{
High,
Normal,
Junk,
Nasty,
Toxin
}

[RegisterComponent, Access(typeof(FoodSystem))]
public sealed partial class FoodComponent : Component
{
Expand Down Expand Up @@ -67,4 +76,11 @@ public sealed partial class FoodComponent : Component
/// </summary>
[DataField]
public float ForceFeedDelay = 3;

/// <summary>
/// Frontier - Nasty food, used for goblins to know if they can eat it or not
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("quality")] // Frontier
[AutoNetworkedField]
public Quality Quality = Quality.Normal;
}
90 changes: 90 additions & 0 deletions Content.Server/Nutrition/EntitySystems/FoodSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
using Robust.Shared.Player;
using Robust.Shared.Utility;

using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Content.Shared.Chemistry.Components.SolutionManager;

namespace Content.Server.Nutrition.EntitySystems;

/// <summary>
Expand Down Expand Up @@ -228,6 +232,7 @@ private void OnDoAfter(EntityUid uid, FoodComponent component, ConsumeDoAfterEve
// Get the stomach with the highest available solution volume
var highestAvailable = FixedPoint2.Zero;
StomachComponent? stomachToUse = null;
var reverseFoodQuality = false; // Frontier
foreach (var (stomach, _) in stomachs)
{
var owner = stomach.Owner;
Expand All @@ -243,6 +248,7 @@ private void OnDoAfter(EntityUid uid, FoodComponent component, ConsumeDoAfterEve

stomachToUse = stomach;
highestAvailable = stomachSol.AvailableVolume;
reverseFoodQuality = stomachToUse.ReverseFoodQuality; // Frontier
}

// No stomach so just popup a message that they can't eat.
Expand All @@ -253,9 +259,93 @@ private void OnDoAfter(EntityUid uid, FoodComponent component, ConsumeDoAfterEve
return;
}

/// Frontier - Goblin food system
if (reverseFoodQuality)
{
if (component.Quality == Quality.High)
component.Quality = Quality.Toxin;
else if (component.Quality == Quality.Normal)
component.Quality = Quality.Nasty;
else if (component.Quality == Quality.Nasty)
component.Quality = Quality.Normal;
else if (component.Quality == Quality.Toxin)
component.Quality = Quality.High;
}

_reaction.DoEntityReaction(args.Target.Value, solution, ReactionMethod.Ingestion);
_stomach.TryTransferSolution(stomachToUse.Owner, split, stomachToUse);

switch (component.Quality)
{
case Quality.High:
//_popup.PopupEntity(Loc.GetString("food-system-food-quality-user", ("quality", component.Quality)), args.User, args.User);
if (reverseFoodQuality)
{
string[] toxins = { "Toxin", "CarpoToxin", "Mold" };

var prototypeMan = IoCManager.Resolve<IPrototypeManager>();
foreach (var reagent in toxins)
{
_solutionContainer.TryGetSolution(stomachToUse.Owner, StomachSystem.DefaultSolutionName, out var stomachSol);
_solutionContainer.RemoveReagent(stomachToUse.Owner, stomachSol, reagent, transferAmount);
//_solutionContainer.TryAddReagent(uid, solution, reagent, -transferAmount, out _);


}
}
else
{

}
break;
case Quality.Normal:
//_popup.PopupEntity(Loc.GetString("food-system-food-quality-user", ("quality", component.Quality)), args.User, args.User);
if (reverseFoodQuality)
{

}
else
{

}
break;
case Quality.Junk:
//_popup.PopupEntity(Loc.GetString("food-system-food-quality-user", ("quality", component.Quality)), args.User, args.User);
if (reverseFoodQuality)
{

}
else
{

}
break;
case Quality.Nasty:
//_popup.PopupEntity(Loc.GetString("food-system-food-quality-user", ("quality", component.Quality)), args.User, args.User);
if (reverseFoodQuality)
{

}
else
{

}
break;
case Quality.Toxin:
//_popup.PopupEntity(Loc.GetString("food-system-food-quality-user", ("quality", component.Quality)), args.User, args.User);
if (reverseFoodQuality)
{

}
else
{

}
break;
default:
throw new ArgumentOutOfRangeException($"No implemented mask radio behavior for {component.Quality}!");
} /// Frontier

var flavors = args.FlavorMessage;

if (forceFeed)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## System

food-system-food-quality-user = Food quality is {$quality}
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,12 @@
reagents:
- ReagentId: UncookedAnimalProteins
Quantity: 5
- ReagentId: ToxinGoblinSafe #Frontier: allows goblins to eat rotten meat without takin damage, while dealing damage to other species
- ReagentId: Toxin
Quantity: 4
- ReagentId: Fat
Quantity: 4
- type: Food
quality: Toxin

- type: entity
name: raw spider meat
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/_NF/Body/Organs/goblin_organs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@
- ReagentId: UncookedAnimalProteins
Quantity: 5
- type: Stomach
reverseFoodQuality: true
# specialDigestible:
# tags:
# - Meat
Expand Down

0 comments on commit 1b0891f

Please sign in to comment.