Recognizable chemicals (#16761)

This commit is contained in:
Kara
2023-05-24 16:08:05 -07:00
committed by GitHub
parent e93b1ad055
commit 04c975534b
16 changed files with 115 additions and 16 deletions

View File

@@ -1,5 +1,6 @@
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
using System.Text;
using Content.Server.Chemistry.Components.SolutionManager; using Content.Server.Chemistry.Components.SolutionManager;
using Content.Shared.Chemistry; using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Components; using Content.Shared.Chemistry.Components;
@@ -65,7 +66,9 @@ public sealed partial class SolutionContainerSystem : EntitySystem
SolutionContainerManagerComponent? solutionsManager = null; SolutionContainerManagerComponent? solutionsManager = null;
if (!Resolve(args.Examined, ref solutionsManager) if (!Resolve(args.Examined, ref solutionsManager)
|| !solutionsManager.Solutions.TryGetValue(examinableComponent.Solution, out var solutionHolder)) || !solutionsManager.Solutions.TryGetValue(examinableComponent.Solution, out var solutionHolder))
{
return; return;
}
var primaryReagent = solutionHolder.GetPrimaryReagentId(); var primaryReagent = solutionHolder.GetPrimaryReagentId();
@@ -75,7 +78,7 @@ public sealed partial class SolutionContainerSystem : EntitySystem
return; return;
} }
if (!_prototypeManager.TryIndex(primaryReagent, out ReagentPrototype? proto)) if (!_prototypeManager.TryIndex(primaryReagent, out ReagentPrototype? primary))
{ {
Logger.Error( Logger.Error(
$"{nameof(Solution)} could not find the prototype associated with {primaryReagent}."); $"{nameof(Solution)} could not find the prototype associated with {primaryReagent}.");
@@ -91,7 +94,53 @@ public sealed partial class SolutionContainerSystem : EntitySystem
("wordedAmount", Loc.GetString(solutionHolder.Contents.Count == 1 ("wordedAmount", Loc.GetString(solutionHolder.Contents.Count == 1
? "shared-solution-container-component-on-examine-worded-amount-one-reagent" ? "shared-solution-container-component-on-examine-worded-amount-one-reagent"
: "shared-solution-container-component-on-examine-worded-amount-multiple-reagents")), : "shared-solution-container-component-on-examine-worded-amount-multiple-reagents")),
("desc", proto.LocalizedPhysicalDescription))); ("desc", primary.LocalizedPhysicalDescription)));
// Add descriptions of immediately recognizable reagents, like water or beer
var recognized = new List<ReagentPrototype>();
foreach (var (id, _) in solutionHolder)
{
if (!_prototypeManager.TryIndex<ReagentPrototype>(id, out var proto))
{
continue;
}
if (!proto.Recognizable)
{
continue;
}
recognized.Add(proto);
}
// Skip if there's nothing recognizable
if (recognized.Count == 0)
return;
var msg = new StringBuilder();
foreach (var reagent in recognized)
{
string part;
if (reagent == recognized[0])
{
part = "examinable-solution-recognized-first";
}
else if (reagent == recognized[^1])
{
// this loc specifically requires space to be appended, fluent doesnt support whitespace
msg.Append(' ');
part = "examinable-solution-recognized-last";
}
else
{
part = "examinable-solution-recognized-next";
}
msg.Append(Loc.GetString(part, ("color", reagent.SubstanceColor.ToHexNoAlpha()),
("chemical", reagent.LocalizedName)));
}
args.PushMarkup(Loc.GetString("examinable-solution-has-recognizable-chemicals", ("recognizedString", msg.ToString())));
} }
public void UpdateAppearance(EntityUid uid, Solution solution, public void UpdateAppearance(EntityUid uid, Solution solution,

View File

@@ -52,6 +52,12 @@ namespace Content.Shared.Chemistry.Reagent
[ViewVariables(VVAccess.ReadOnly)] [ViewVariables(VVAccess.ReadOnly)]
public string LocalizedPhysicalDescription => Loc.GetString(PhysicalDescription); public string LocalizedPhysicalDescription => Loc.GetString(PhysicalDescription);
/// <summary>
/// Is this reagent recognizable to the average spaceman (water, welding fuel, ketchup, etc)?
/// </summary>
[DataField("recognizable")]
public bool Recognizable = false;
[DataField("flavor")] [DataField("flavor")]
public string Flavor { get; } = default!; public string Flavor { get; } = default!;

View File

@@ -1,4 +1,9 @@
shared-solution-container-component-on-examine-empty-container = Contains no chemicals. shared-solution-container-component-on-examine-empty-container = Contains no chemicals.
shared-solution-container-component-on-examine-main-text = It contains a [color={$color}]{$desc}[/color] {$wordedAmount} shared-solution-container-component-on-examine-main-text = It contains {INDEFINITE($desc)} [color={$color}]{$desc}[/color] {$wordedAmount}
shared-solution-container-component-on-examine-worded-amount-one-reagent = chemical. shared-solution-container-component-on-examine-worded-amount-one-reagent = chemical.
shared-solution-container-component-on-examine-worded-amount-multiple-reagents = mixture of chemicals. shared-solution-container-component-on-examine-worded-amount-multiple-reagents = mixture of chemicals.
examinable-solution-has-recognizable-chemicals = You can recognize {$recognizedString} in the solution.
examinable-solution-recognized-first = [color={$color}]{$chemical}[/color]
examinable-solution-recognized-next = , [color={$color}]{$chemical}[/color]
examinable-solution-recognized-last = and [color={$color}]{$chemical}[/color]

View File

@@ -158,3 +158,5 @@
transferAmount: 1 transferAmount: 1
solution: puddle solution: puddle
examinable: false examinable: false
- type: ExaminableSolution
solution: puddle

View File

@@ -75,6 +75,8 @@
- type: PhysicalComposition - type: PhysicalComposition
materialComposition: materialComposition:
Glass: 25 Glass: 25
- type: ExaminableSolution
solution: drink
# Transformable container - normal glass # Transformable container - normal glass
- type: entity - type: entity

View File

@@ -29,6 +29,7 @@
physicalDesc: reagent-physical-desc-bubbly physicalDesc: reagent-physical-desc-bubbly
flavor: ale flavor: ale
color: "#663100" color: "#663100"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/aleglass.rsi sprite: Objects/Consumable/Drinks/aleglass.rsi
state: icon state: icon
@@ -41,6 +42,7 @@
physicalDesc: reagent-physical-desc-bubbly physicalDesc: reagent-physical-desc-bubbly
flavor: beer flavor: beer
color: "#cfa85f" color: "#cfa85f"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/beerglass.rsi sprite: Objects/Consumable/Drinks/beerglass.rsi
state: icon state: icon
@@ -73,6 +75,7 @@
physicalDesc: reagent-physical-desc-strong-smelling physicalDesc: reagent-physical-desc-strong-smelling
flavor: alcohol flavor: alcohol
color: "#AB3C05" color: "#AB3C05"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/cognacglass.rsi sprite: Objects/Consumable/Drinks/cognacglass.rsi
state: icon state: icon
@@ -171,6 +174,7 @@
physicalDesc: reagent-physical-desc-strong-smelling physicalDesc: reagent-physical-desc-strong-smelling
flavor: alcohol flavor: alcohol
color: "#664300" color: "#664300"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/ginvodkaglass.rsi sprite: Objects/Consumable/Drinks/ginvodkaglass.rsi
state: icon state: icon
@@ -253,6 +257,7 @@
physicalDesc: reagent-physical-desc-strong-smelling physicalDesc: reagent-physical-desc-strong-smelling
flavor: rum flavor: rum
color: "#664300" color: "#664300"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/rumglass.rsi sprite: Objects/Consumable/Drinks/rumglass.rsi
state: icon state: icon
@@ -311,6 +316,7 @@
physicalDesc: reagent-physical-desc-strong-smelling physicalDesc: reagent-physical-desc-strong-smelling
flavor: vodka flavor: vodka
color: "#d1d1d155" color: "#d1d1d155"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/ginvodkaglass.rsi sprite: Objects/Consumable/Drinks/ginvodkaglass.rsi
state: icon state: icon
@@ -331,6 +337,7 @@
physicalDesc: reagent-physical-desc-strong-smelling physicalDesc: reagent-physical-desc-strong-smelling
flavor: whiskey flavor: whiskey
color: "#664300" color: "#664300"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/whiskeyglass.rsi sprite: Objects/Consumable/Drinks/whiskeyglass.rsi
state: icon state: icon
@@ -351,6 +358,7 @@
physicalDesc: reagent-physical-desc-translucent physicalDesc: reagent-physical-desc-translucent
flavor: shittywine flavor: shittywine
color: "#7E4043" color: "#7E4043"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/wineglass.rsi sprite: Objects/Consumable/Drinks/wineglass.rsi
state: icon state: icon

View File

@@ -6,6 +6,7 @@
physicalDesc: reagent-physical-desc-aromatic physicalDesc: reagent-physical-desc-aromatic
flavor: coffee flavor: coffee
color: "#664300" color: "#664300"
recognizable: true
metabolisms: metabolisms:
Drink: Drink:
effects: effects:
@@ -134,6 +135,7 @@
physicalDesc: reagent-physical-desc-opaque physicalDesc: reagent-physical-desc-opaque
flavor: milk flavor: milk
color: "#DFDFDF" color: "#DFDFDF"
recognizable: true
plantMetabolism: plantMetabolism:
- !type:PlantAdjustNutrition - !type:PlantAdjustNutrition
amount: 0.1 amount: 0.1
@@ -159,6 +161,7 @@
physicalDesc: reagent-physical-desc-refreshing physicalDesc: reagent-physical-desc-refreshing
flavor: oats flavor: oats
color: "#DEDACD" color: "#DEDACD"
recognizable: true
metabolisms: metabolisms:
Drink: Drink:
effects: effects:
@@ -256,6 +259,7 @@
physicalDesc: reagent-physical-desc-aromatic physicalDesc: reagent-physical-desc-aromatic
flavor: tea flavor: tea
color: "#8a5a3a" color: "#8a5a3a"
recognizable: true
metabolisms: metabolisms:
Drink: Drink:
effects: effects:
@@ -283,6 +287,7 @@
physicalDesc: reagent-physical-desc-translucent physicalDesc: reagent-physical-desc-translucent
flavor: water flavor: water
color: "#75b1f0" color: "#75b1f0"
recognizable: true
boilingPoint: 100.0 boilingPoint: 100.0
meltingPoint: 0.0 meltingPoint: 0.0
metabolisms: metabolisms:
@@ -298,6 +303,7 @@
physicalDesc: reagent-physical-desc-frosty physicalDesc: reagent-physical-desc-frosty
flavor: cold flavor: cold
color: "#bed8e6" color: "#bed8e6"
recognizable: true
meltingPoint: 0.0 meltingPoint: 0.0
boilingPoint: 100.0 boilingPoint: 100.0
plantMetabolism: plantMetabolism:

View File

@@ -6,6 +6,7 @@
physicalDesc: reagent-physical-desc-crisp physicalDesc: reagent-physical-desc-crisp
flavor: apple flavor: apple
color: "#FDAD01" color: "#FDAD01"
recognizable: true
- type: reagent - type: reagent
id: JuiceBanana id: JuiceBanana
@@ -43,17 +44,6 @@
types: types:
Poison: 1 Poison: 1
#TODO: restore eyesight
#if(..())
#return 1
# M.eye_blurry = max(M.eye_blurry - 1 , 0)
# M.eye_blind = max(M.eye_blind - 1 , 0)
# switch(data)
# if(21 to INFINITY)
# if(prob(data - 10))
# M.disabilities &= ~NEARSIGHTED
# data++
- type: reagent - type: reagent
id: JuiceCarrot id: JuiceCarrot
name: reagent-name-juice-carrot name: reagent-name-juice-carrot

View File

@@ -6,6 +6,7 @@
physicalDesc: reagent-physical-desc-fizzy physicalDesc: reagent-physical-desc-fizzy
flavor: soda flavor: soda
color: "#422912" color: "#422912"
recognizable: true
- type: reagent - type: reagent
id: ChangelingSting id: ChangelingSting
@@ -59,6 +60,7 @@
physicalDesc: reagent-physical-desc-creamy physicalDesc: reagent-physical-desc-creamy
flavor: icecream flavor: icecream
color: "#fffbd6" color: "#fffbd6"
recognizable: true
metamorphicSprite: metamorphicSprite:
sprite: Objects/Consumable/Drinks/icecreamglass.rsi sprite: Objects/Consumable/Drinks/icecreamglass.rsi
state: icon state: icon
@@ -101,7 +103,7 @@
name: reagent-name-root-beer-float name: reagent-name-root-beer-float
parent: BaseSoda parent: BaseSoda
desc: reagent-desc-root-beer-float desc: reagent-desc-root-beer-float
physicalDesc: reagent-physical-desc-fizzy and creamy physicalDesc: reagent-physical-desc-fizzy-and-creamy
flavor: soda flavor: soda
color: "#4f361f" color: "#4f361f"
metamorphicSprite: metamorphicSprite:

View File

@@ -6,6 +6,7 @@
physicalDesc: reagent-physical-desc-sugary physicalDesc: reagent-physical-desc-sugary
flavor: sweet flavor: sweet
color: aquamarine color: aquamarine
recognizable: true
- type: reagent - type: reagent
id: BbqSauce id: BbqSauce
@@ -15,6 +16,7 @@
physicalDesc: reagent-physical-desc-gloopy physicalDesc: reagent-physical-desc-gloopy
flavor: sweet flavor: sweet
color: darkred color: darkred
recognizable: true
- type: reagent - type: reagent
id: Cornoil id: Cornoil
@@ -24,6 +26,7 @@
physicalDesc: reagent-physical-desc-oily physicalDesc: reagent-physical-desc-oily
flavor: oily flavor: oily
color: yellow color: yellow
recognizable: true
- type: reagent - type: reagent
id: Frostoil id: Frostoil
@@ -42,6 +45,7 @@
physicalDesc: reagent-physical-desc-overpowering physicalDesc: reagent-physical-desc-overpowering
flavor: spicy flavor: spicy
color: gray color: gray
recognizable: true
- type: reagent - type: reagent
id: Hotsauce id: Hotsauce
@@ -51,6 +55,7 @@
physicalDesc: reagent-physical-desc-spicy physicalDesc: reagent-physical-desc-spicy
flavor: spicy flavor: spicy
color: red color: red
recognizable: true
- type: reagent - type: reagent
id: Ketchup id: Ketchup
@@ -60,6 +65,7 @@
physicalDesc: reagent-physical-desc-tangy physicalDesc: reagent-physical-desc-tangy
flavor: tomato flavor: tomato
color: red color: red
recognizable: true
- type: reagent - type: reagent
id: Ketchunaise id: Ketchunaise
@@ -69,6 +75,7 @@
physicalDesc: reagent-physical-desc-saucey physicalDesc: reagent-physical-desc-saucey
flavor: piquant flavor: piquant
color: "#fba399" color: "#fba399"
recognizable: true
- type: reagent - type: reagent
id: Mayo id: Mayo
@@ -78,6 +85,7 @@
physicalDesc: reagent-physical-desc-thick physicalDesc: reagent-physical-desc-thick
flavor: sour flavor: sour
color: "#f9f5e5" color: "#f9f5e5"
recognizable: true
- type: reagent - type: reagent
id: Vinaigrette id: Vinaigrette
@@ -87,6 +95,7 @@
physicalDesc: reagent-physical-desc-sour physicalDesc: reagent-physical-desc-sour
flavor: sour flavor: sour
color: "#efdaae" color: "#efdaae"
recognizable: true
- type: reagent - type: reagent
id: Soysauce id: Soysauce
@@ -96,6 +105,7 @@
physicalDesc: reagent-physical-desc-salty physicalDesc: reagent-physical-desc-salty
flavor: salty flavor: salty
color: saddlebrown color: saddlebrown
recognizable: true
metabolisms: metabolisms:
Food: Food:
effects: effects:
@@ -112,6 +122,7 @@
physicalDesc: reagent-physical-desc-grainy physicalDesc: reagent-physical-desc-grainy
flavor: salty flavor: salty
color: "#a1000b" color: "#a1000b"
recognizable: true
boilingPoint: 1465.0 boilingPoint: 1465.0
meltingPoint: 800.7 meltingPoint: 800.7
plantMetabolism: plantMetabolism:

View File

@@ -6,6 +6,7 @@
physicalDesc: reagent-physical-desc-powdery physicalDesc: reagent-physical-desc-powdery
flavor: chalky flavor: chalky
color: white color: white
recognizable: true
metabolisms: metabolisms:
Food: Food:
effects: effects:
@@ -70,6 +71,7 @@
physicalDesc: reagent-physical-desc-mucus-like physicalDesc: reagent-physical-desc-mucus-like
flavor: egg flavor: egg
color: white color: white
recognizable: true
metabolisms: metabolisms:
Food: Food:
effects: effects:
@@ -85,6 +87,7 @@
physicalDesc: reagent-physical-desc-grainy physicalDesc: reagent-physical-desc-grainy
flavor: peppery flavor: peppery
color: black color: black
recognizable: true
- type: reagent - type: reagent
id: Vinegar id: Vinegar
@@ -94,6 +97,7 @@
physicalDesc: reagent-physical-desc-sour physicalDesc: reagent-physical-desc-sour
flavor: bitter flavor: bitter
color: tan color: tan
recognizable: true
metabolisms: metabolisms:
Food: Food:
effects: effects:
@@ -117,6 +121,7 @@
physicalDesc: reagent-physical-desc-chewy physicalDesc: reagent-physical-desc-chewy
flavor: rice flavor: rice
color: white color: white
recognizable: true
metabolisms: metabolisms:
Food: Food:
effects: effects:
@@ -135,6 +140,7 @@
physicalDesc: reagent-physical-desc-oily physicalDesc: reagent-physical-desc-oily
flavor: oily flavor: oily
color: olive color: olive
recognizable: true
metabolisms: metabolisms:
Food: Food:
effects: effects:
@@ -149,6 +155,7 @@
desc: reagent-desc-oil desc: reagent-desc-oil
physicalDesc: reagent-physical-desc-oily physicalDesc: reagent-physical-desc-oily
flavor: oily flavor: oily
recognizable: true
color: "#b67823" color: "#b67823"
boilingPoint: 300.0 boilingPoint: 300.0
meltingPoint: -16.0 meltingPoint: -16.0
@@ -162,6 +169,7 @@
physicalDesc: reagent-physical-desc-oily physicalDesc: reagent-physical-desc-oily
flavor: spicy flavor: spicy
color: "#FF0000" color: "#FF0000"
recognizable: true
meltingPoint: 146 meltingPoint: 146
boilingPoint: 410 # Really high boiling point compared to its melting boilingPoint: 410 # Really high boiling point compared to its melting
metabolisms: metabolisms:

View File

@@ -5,6 +5,7 @@
desc: reagent-desc-blood desc: reagent-desc-blood
flavor: metallic flavor: metallic
color: "#800000" color: "#800000"
recognizable: true
physicalDesc: reagent-physical-desc-ferrous physicalDesc: reagent-physical-desc-ferrous
slippery: false slippery: false
metabolisms: metabolisms:
@@ -24,6 +25,7 @@
desc: reagent-desc-slime desc: reagent-desc-slime
flavor: slimy flavor: slimy
color: "#2cf274" color: "#2cf274"
recognizable: true
physicalDesc: reagent-physical-desc-viscous physicalDesc: reagent-physical-desc-viscous
slippery: false slippery: false
viscosity: 0.25 viscosity: 0.25
@@ -43,6 +45,7 @@
desc: reagent-desc-spider-blood desc: reagent-desc-spider-blood
flavor: metallic flavor: metallic
color: "#162581" color: "#162581"
recognizable: true
physicalDesc: reagent-physical-desc-ferrous physicalDesc: reagent-physical-desc-ferrous
slippery: false slippery: false
metabolisms: metabolisms:
@@ -63,6 +66,7 @@
physicalDesc: reagent-physical-desc-roaring physicalDesc: reagent-physical-desc-roaring
flavor: metallic flavor: metallic
color: "#f4692e" color: "#f4692e"
recognizable: true
metabolisms: metabolisms:
Drink: Drink:
effects: effects:

View File

@@ -27,6 +27,7 @@
physicalDesc: reagent-physical-desc-lemony-fresh physicalDesc: reagent-physical-desc-lemony-fresh
flavor: bitter flavor: bitter
color: "#c8ff69" color: "#c8ff69"
recognizable: true
boilingPoint: 147.0 # Made this up, loosely based on bleach boilingPoint: 147.0 # Made this up, loosely based on bleach
meltingPoint: -11.0 meltingPoint: -11.0
tileReactions: tileReactions:
@@ -41,6 +42,7 @@
physicalDesc: reagent-physical-desc-shiny physicalDesc: reagent-physical-desc-shiny
flavor: funny flavor: funny
color: "#77b58e" color: "#77b58e"
recognizable: true
boilingPoint: 290.0 # Glycerin boilingPoint: 290.0 # Glycerin
meltingPoint: 18.2 meltingPoint: 18.2
tileReactions: tileReactions:

View File

@@ -43,6 +43,7 @@
physicalDesc: reagent-physical-desc-gaseous physicalDesc: reagent-physical-desc-gaseous
flavor: bitter flavor: bitter
color: "#7e009e" color: "#7e009e"
recognizable: true
boilingPoint: -127.3 # Random values picked between the actual values for CO2 and O2 boilingPoint: -127.3 # Random values picked between the actual values for CO2 and O2
meltingPoint: -186.4 meltingPoint: -186.4
tileReactions: tileReactions:

View File

@@ -145,6 +145,7 @@
slippery: true slippery: true
flavor: bitter flavor: bitter
color: "#a76b1c" color: "#a76b1c"
recognizable: true
boilingPoint: -84.7 # Acetylene. Close enough. boilingPoint: -84.7 # Acetylene. Close enough.
meltingPoint: -80.7 meltingPoint: -80.7
tileReactions: tileReactions:

View File

@@ -84,6 +84,7 @@
desc: reagent-desc-mold desc: reagent-desc-mold
flavor: bitter flavor: bitter
color: "#8a9a5b" color: "#8a9a5b"
recognizable: true
physicalDesc: reagent-physical-desc-fuzzy physicalDesc: reagent-physical-desc-fuzzy
metabolisms: metabolisms:
Poison: Poison:
@@ -180,6 +181,7 @@
physicalDesc: reagent-physical-desc-oily physicalDesc: reagent-physical-desc-oily
flavor: acidic flavor: acidic
color: "#BF8C00" color: "#BF8C00"
recognizable: true
boilingPoint: 337.0 boilingPoint: 337.0
meltingPoint: 10.31 meltingPoint: 10.31
plantMetabolism: plantMetabolism: