Client LuaCsForBarotrauma
BarotraumaClient/ClientSource/Items/Components/GeneticMaterial.cs
2 using Microsoft.Xna.Framework;
3 using System.Linq;
4 
6 {
7  partial class GeneticMaterial : ItemComponent
8  {
9  [Serialize(0.0f, IsPropertySaveable.No)]
10  public float TooltipValueMin { get; set; }
11 
12  [Serialize(0.0f, IsPropertySaveable.No)]
13  public float TooltipValueMax { get; set; }
14 
15  public override void AddTooltipInfo(ref LocalizedString name, ref LocalizedString description)
16  {
17  if (!materialName.IsNullOrEmpty() && item.ContainedItems.Count() > 0)
18  {
19  LocalizedString mergedMaterialName = materialName;
20  foreach (Item containedItem in item.ContainedItems)
21  {
22  var containedMaterial = containedItem.GetComponent<GeneticMaterial>();
23  if (containedMaterial == null) { continue; }
24  mergedMaterialName += ", " + containedMaterial.materialName;
25  }
26  name = name.Replace(materialName, mergedMaterialName);
27  }
28 
29  if (Tainted)
30  {
31  name = TextManager.GetWithVariable("entityname.taintedgeneticmaterial", "[geneticmaterialname]", name);
32  }
33 
34  if (TextManager.ContainsTag("entitydescription." + Item.Prefab.Identifier))
35  {
36  int value = (int)MathHelper.Lerp(TooltipValueMin, TooltipValueMax, item.ConditionPercentage / 100.0f);
37  description = TextManager.GetWithVariable("entitydescription." + Item.Prefab.Identifier, "[value]", value.ToString());
38  }
39  foreach (Item containedItem in item.ContainedItems)
40  {
41  var containedGeneticMaterial = containedItem.GetComponent<GeneticMaterial>();
42  if (containedGeneticMaterial == null) { continue; }
43  LocalizedString _ = string.Empty;
44  LocalizedString containedDescription = containedItem.Description;
45  containedGeneticMaterial.AddTooltipInfo(ref _, ref containedDescription);
46  if (!containedDescription.IsNullOrEmpty())
47  {
48  description += '\n' + containedDescription;
49  }
50  }
51  }
52 
53  public void ModifyDeconstructInfo(Deconstructor deconstructor, ref LocalizedString buttonText, ref LocalizedString infoText)
54  {
55  if (deconstructor.InputContainer.Inventory.AllItems.Count() == 2)
56  {
57  var otherGeneticMaterial =
58  deconstructor.InputContainer.Inventory.AllItems.FirstOrDefault(it => it != item && it.Prefab == item.Prefab)?.GetComponent<GeneticMaterial>();
59  if (otherGeneticMaterial == null)
60  {
61  buttonText = TextManager.Get("researchstation.combine");
62  infoText = TextManager.Get("researchstation.combine.infotext");
63  }
64  else
65  {
66  buttonText = TextManager.Get("researchstation.refine");
67  int taintedProbability = (int)(GetTaintedProbabilityOnRefine(otherGeneticMaterial, Character.Controlled) * 100);
68  infoText = TextManager.GetWithVariable("researchstation.refine.infotext", "[taintedprobability]", taintedProbability.ToString());
69  }
70  }
71  }
72 
73  public void ClientEventRead(IReadMessage msg, float sendingTime)
74  {
75  Tainted = msg.ReadBoolean();
76  if (Tainted)
77  {
78  uint selectedTaintedEffectId = msg.ReadUInt32();
79  selectedTaintedEffect = AfflictionPrefab.Prefabs.Find(a => a.UintIdentifier == selectedTaintedEffectId);
80  }
81  else
82  {
83  uint selectedEffectId = msg.ReadUInt32();
84  selectedEffect = AfflictionPrefab.Prefabs.Find(a => a.UintIdentifier == selectedEffectId);
85  }
86  }
87  }
88 }
AfflictionPrefab is a prefab that defines a type of affliction that can be applied to a character....
static readonly PrefabCollection< AfflictionPrefab > Prefabs
virtual IEnumerable< Item > AllItems
All items contained in the inventory. Stacked items are returned as individual instances....
void ModifyDeconstructInfo(Deconstructor deconstructor, ref LocalizedString buttonText, ref LocalizedString infoText)
override void AddTooltipInfo(ref LocalizedString name, ref LocalizedString description)
readonly Identifier Identifier
Definition: Prefab.cs:34