Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft one of plant metabolism guidebook #4

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Content.Client/Guidebook/Controls/GuideReagentEmbed.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,16 @@ private void GenerateControl(ReagentPrototype reagent)
continue;

var groupLabel = new RichTextLabel();
groupLabel.SetMarkup(Loc.GetString("guidebook-reagent-effects-metabolism-group-rate",
("group", _prototype.Index<MetabolismGroupPrototype>(group).LocalizedName), ("rate", effect.MetabolismRate)));
if (effect.MetabolismRate >= 0)
{
groupLabel.SetMarkup(Loc.GetString("guidebook-reagent-effects-metabolism-group-rate",
("group", _prototype.Index<MetabolismGroupPrototype>(group).LocalizedName), ("rate", effect.MetabolismRate)));
}
else
{
groupLabel.SetMarkup(Loc.GetString("guidebook-reagent-effects-metabolism-group-norate",
("group", _prototype.Index<MetabolismGroupPrototype>(group).LocalizedName)));
}
var descriptionLabel = new RichTextLabel
{
Margin = new Thickness(25, 0, 10, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ public abstract partial class PlantAdjustAttribute : ReagentEffect
[DataField]
public float Prob { get; protected set; } = 1; // = (80);

/// <summary>
/// Localisation key for the name of the adjusted attribute. Used for guidebook description.
/// </summary>
[DataField]
public string Attribute { get; protected set; } = "missing";

/// <summary>
/// Whether the attribute in question is a good thing. Used for guidebook description to determine the color of the number.
/// </summary>
[DataField]
public bool Positive = true;

/// <summary>
/// Checks if the plant holder can metabolize the reagent or not. Checks if it has an alive plant by default.
/// </summary>
Expand All @@ -40,6 +52,18 @@ public bool CanMetabolize(EntityUid plantHolder, [NotNullWhen(true)] out PlantHo
return !(Prob <= 0f) && IoCManager.Resolve<IRobustRandom>().Prob(Prob);
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
{
string color;
if (Positive ^ Amount < 0.0)
{
color = "green";
}
else
{
color = "red";
}
return Loc.GetString("reagent-effect-guidebook-plant-attribute", ("attribute", Loc.GetString(Attribute)), ("amount", Amount.ToString("0.00")), ("colorName", color), ("chance", Probability));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
{
public sealed partial class PlantAdjustHealth : PlantAdjustAttribute
{
public PlantAdjustHealth()
{
Attribute = "plant-attribute-health";
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
{
public sealed partial class PlantAdjustMutationLevel : PlantAdjustAttribute
{
public PlantAdjustMutationLevel()
{
Attribute = "plant-attribute-mutation-level";
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAdjustMutationMod : PlantAdjustAttribute
{
public PlantAdjustMutationMod()
{
Attribute = "plant-attribute-mutation-mod";
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAdjustNutrition : PlantAdjustAttribute
{
public PlantAdjustNutrition()
{
Attribute = "plant-attribute-nutrition";
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAdjustPests : PlantAdjustAttribute
{
public PlantAdjustPests()
{
Attribute = "plant-attribute-pests";
Positive = false;
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAdjustToxins : PlantAdjustAttribute
{
public PlantAdjustToxins()
{
Attribute = "plant-attribute-toxins";
Positive = false;
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAdjustWater : PlantAdjustAttribute
{
public PlantAdjustWater()
{
Attribute = "plant-attribute-water";
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager, mustHaveAlivePlant: false))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAdjustWeeds : PlantAdjustAttribute
{
public PlantAdjustWeeds()
{
Attribute = "plant-attribute-weeds";
Positive = false;
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ namespace Content.Server.Chemistry.ReagentEffects.PlantMetabolism
[UsedImplicitly]
public sealed partial class PlantAffectGrowth : PlantAdjustAttribute
{
public PlantAffectGrowth()
{
Attribute = "plant-attribute-growth";
}

public override void Effect(ReagentEffectArgs args)
{
if (!CanMetabolize(args.SolutionEntity, out var plantHolderComp, args.EntityManager))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ public override void Effect(ReagentEffectArgs args)
plantHolderComp.ForceUpdate = true;
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-cryoxadone", ("chance", Probability));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ public override void Effect(ReagentEffectArgs args)
}
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-diethylamine", ("chance", Probability));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ public override void Effect(ReagentEffectArgs args)
plantHolderComp.Seed.Viable = true;
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-phalanximine", ("chance", Probability));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public override void Effect(ReagentEffectArgs args)
}
}

protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-missing", ("chance", Probability));
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("reagent-effect-guidebook-plant-robust-harvest", ("seedlesstreshold", PotencySeedlessThreshold), ("limit", PotencyLimit), ("increase", PotencyIncrease), ("chance", Probability));
}
}
10 changes: 10 additions & 0 deletions Content.Shared/Chemistry/Reagent/ReagentPrototype.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,16 @@ public ReagentGuideEntry(ReagentPrototype proto, IPrototypeManager prototype, IE
GuideEntries = proto.Metabolisms?
.Select(x => (x.Key, x.Value.MakeGuideEntry(prototype, entSys)))
.ToDictionary(x => x.Key, x => x.Item2);
if (proto.PlantMetabolisms.Count > 0)
{
if (GuideEntries == null)
GuideEntries = new Dictionary<ProtoId<MetabolismGroupPrototype>, ReagentEffectsGuideEntry>();
GuideEntries["PlantMetabolisms"] = new ReagentEffectsGuideEntry(-1.0f, proto.PlantMetabolisms
.Select(x => x.GuidebookEffectDescription(prototype, entSys))
.Where(x => x is not null)
.Select(x => x!)
.ToArray());
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/guidebook/chemistry/core.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ guidebook-reagent-sources-ent-wrapper = [bold]{$name}[/bold] \[1\]
guidebook-reagent-sources-gas-wrapper = [bold]{$name} (gas)[/bold] \[1\]
guidebook-reagent-effects-header = Effects
guidebook-reagent-effects-metabolism-group-rate = [bold]{$group}[/bold] [color=gray]({$rate} units per second)[/color]
guidebook-reagent-effects-metabolism-group-norate = [bold]{$group}[/bold]
guidebook-reagent-physical-description = [italic]Seems to be {$description}.[/italic]
guidebook-reagent-recipes-mix-info = {$minTemp ->
[0] {$hasMax ->
Expand Down
32 changes: 31 additions & 1 deletion Resources/Locale/en-US/guidebook/chemistry/effects.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ reagent-effect-guidebook-innoculate-zombie-infection =
*[other] cure
} an ongoing zombie infection, and provides immunity to future infections

reagent-effect-guidebook-reduce-rotting =
reagent-effect-guidebook-reduce-rotting =
{ $chance ->
[1] Regenerates
*[other] regenerate
Expand All @@ -350,3 +350,33 @@ reagent-effect-guidebook-missing =
[1] Causes
*[other] cause
} an unknown effect as nobody has written this effect yet

reagent-effect-guidebook-plant-attribute =
{ $chance ->
[1] Adjusts
*[other] adjust
} {$attribute} by [color={$colorName}]{$amount}[/color]

reagent-effect-guidebook-plant-cryoxadone =
{ $chance ->
[1] Ages back
*[other] age back
} the plant, depending on the plant's age and time to grow

reagent-effect-guidebook-plant-phalanximine =
{ $chance ->
[1] Makes
*[other] make
} a plant not viable due to mutation viable again

reagent-effect-guidebook-plant-diethylamine =
{ $chance ->
[1] Increases
*[other] increase
} the plant's lifespan and/or base health with 10% chance for each.

reagent-effect-guidebook-plant-robust-harvest =
{ $chance ->
[1] Increases
*[other] increase
} the plant's potency by {$increase} up to a maximum of {$limit}. Causes the plant to lose its seeds once the potency reaches {$seedlesstreshold}. Trying to add potency over {$limit} may cause decrease in yield at a 10% chance.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
plant-attribute-growth = age
plant-attribute-water = water level
plant-attribute-weeds = weeds level
plant-attribute-toxins = toxins level
plant-attribute-nutrition = nutrition level
plant-attribute-mutation-level = mutation level
plant-attribute-pests = pests level
plant-attribute-mutation-mod = mutation modifier
plant-attribute-health = health
1 change: 1 addition & 0 deletions Resources/Locale/en-US/metabolism/metabolism-groups.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ metabolism-group-alcohol = Alcohol
metabolism-group-food = Food
metabolism-group-drink = Drink
metabolism-group-gas = Gas
metabolism-group-plant-metabolisms = Plant Metabolism
5 changes: 5 additions & 0 deletions Resources/Prototypes/Chemistry/metabolism_groups.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@
- type: metabolismGroup
id: Gas
name: metabolism-group-gas

# Dummy for the guide
- type: metabolismGroup
id: PlantMetabolisms
name: metabolism-group-plant-metabolisms
Loading