-
Notifications
You must be signed in to change notification settings - Fork 643
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Доабвление комментов, перенесение изменение в папки корвакс
- Loading branch information
p.krasnoshchekov
committed
Apr 27, 2024
1 parent
9815fe8
commit 585150c
Showing
6 changed files
with
129 additions
and
96 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
Content.Server/Corvax/GuideGenerator/MixingCategoryEntry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Content.Shared.Chemistry.Reaction; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Content.Server.Corvax.GuideGenerator; | ||
|
||
public sealed class MixingCategoryEntry | ||
{ | ||
[JsonPropertyName("name")] | ||
public string Name { get; } | ||
|
||
[JsonPropertyName("id")] | ||
public string Id { get; } | ||
|
||
public MixingCategoryEntry(MixingCategoryPrototype proto) | ||
{ | ||
Name = Loc.GetString(proto.VerbText); | ||
Id = proto.ID; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
Content.Server/Corvax/GuideGenerator/ReactionJsonGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Content.Server.Corvax.GuideGenerator; | ||
using Content.Shared.Chemistry.Reaction; | ||
using Robust.Shared.Prototypes; | ||
|
||
namespace Content.Server.GuideGenerator; | ||
public sealed partial class ReactionJsonGenerator | ||
{ | ||
[ValidatePrototypeId<MixingCategoryPrototype>] | ||
private const string DefaultMixingCategory = "DummyMix"; | ||
|
||
private static void AddMixingCategories(Dictionary<String, ReactionEntry> reactions, IPrototypeManager prototype) | ||
{ | ||
foreach (var reaction in reactions) | ||
{ | ||
var reactionPrototype = prototype.Index<ReactionPrototype>(reaction.Key); | ||
var mixingCategories = new List<MixingCategoryPrototype>(); | ||
if (reactionPrototype.MixingCategories != null) | ||
{ | ||
foreach (var category in reactionPrototype.MixingCategories) | ||
{ | ||
mixingCategories.Add(prototype.Index(category)); | ||
} | ||
} | ||
else | ||
{ | ||
mixingCategories.Add(prototype.Index<MixingCategoryPrototype>(DefaultMixingCategory)); | ||
} | ||
|
||
foreach (var mixingCategory in mixingCategories) | ||
{ | ||
reactions[reaction.Key].MixingCategories.Add(new MixingCategoryEntry(mixingCategory)); | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Content.Server/Corvax/GuideGenerator/ReagentEffectEntry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Content.Shared.Chemistry.Reagent; | ||
using Robust.Shared.Prototypes; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Content.Server.Corvax.GuideGenerator; | ||
public sealed class ReagentEffectEntry | ||
{ | ||
[JsonPropertyName("id")] | ||
public string Id { get; } | ||
|
||
[JsonPropertyName("description")] | ||
public string Description { get; } | ||
|
||
public ReagentEffectEntry(ReagentEffect proto) | ||
{ | ||
var prototype = IoCManager.Resolve<IPrototypeManager>(); | ||
var entSys = IoCManager.Resolve<IEntitySystemManager>(); | ||
|
||
Id = proto.GetType().Name; | ||
Description = GuidebookEffectDescriptionToWeb(proto.GuidebookEffectDescription(prototype, entSys) ?? ""); | ||
} | ||
|
||
private string GuidebookEffectDescriptionToWeb(string guideBookText) | ||
{ | ||
guideBookText = guideBookText.Replace("[", "<"); | ||
guideBookText = guideBookText.Replace("]", ">"); | ||
guideBookText = guideBookText.Replace("color", "span"); | ||
|
||
while (guideBookText.IndexOf("<span=") != -1) | ||
{ | ||
var first = guideBookText.IndexOf("<span=") + "<span=".Length - 1; | ||
var last = guideBookText.IndexOf(">", first); | ||
var replacementString = guideBookText.Substring(first, last - first); | ||
var color = replacementString.Substring(1); | ||
guideBookText = guideBookText.Replace(replacementString, string.Format(" style=\"color: {0};\"", color)); | ||
} | ||
|
||
return guideBookText; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Content.Server/Corvax/GuideGenerator/ReagentEffectsEntry.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Content.Shared.FixedPoint; | ||
using System.Linq; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Content.Server.Corvax.GuideGenerator; | ||
public sealed class ReagentEffectsEntry | ||
{ | ||
[JsonPropertyName("rate")] | ||
public FixedPoint2 MetabolismRate { get; } = FixedPoint2.New(0.5f); | ||
|
||
[JsonPropertyName("effects")] | ||
public List<ReagentEffectEntry> Effects { get; } = new(); | ||
|
||
public ReagentEffectsEntry(Shared.Chemistry.Reagent.ReagentEffectsEntry proto) | ||
{ | ||
MetabolismRate = proto.MetabolismRate; | ||
Effects = proto.Effects.Select(x => new ReagentEffectEntry(x)).ToList(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters