Skip to content

Commit

Permalink
Merge branch 'master' into NightVision(try2)
Browse files Browse the repository at this point in the history
  • Loading branch information
AwareFoxy authored Dec 1, 2024
2 parents a214b4e + 7a08a7f commit d189543
Show file tree
Hide file tree
Showing 35 changed files with 987 additions and 141 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using Content.Shared._CorvaxNext.PlantAnalyzer;
using JetBrains.Annotations;

namespace Content.Client._CorvaxNext.PlantAnalyzer.UI;

[UsedImplicitly]
public sealed class PlantAnalyzerBoundUserInterface : BoundUserInterface
{
[ViewVariables]
private PlantAnalyzerWindow? _window;

public PlantAnalyzerBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
}

protected override void Open()
{
base.Open();
_window = new PlantAnalyzerWindow(this)
{
Title = Loc.GetString("plant-analyzer-interface-title"),
};
_window.OnClose += Close;
_window.OpenCenteredLeft();
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
{
if (_window == null)
return;

if (message is not PlantAnalyzerScannedSeedPlantInformation cast)
return;
_window.Populate(cast);
}

public void AdvPressed(bool scanMode)
{
SendMessage(new PlantAnalyzerSetMode(scanMode));
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (!disposing)
return;

if (_window != null)
_window.OnClose -= Close;

_window?.Dispose();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<controls:FancyWindow xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
Title="{Loc 'plant-analyzer-interface-title'}">
<!-- Margin="left,top,right,bottom" -->
<GridContainer Rows="3" Name ="GridCont" Margin="10 5 10 5" VerticalAlignment="Stretch" HorizontalExpand="True">
<BoxContainer Name="Toggle">
<Label Name="AdvMode" Text="{Loc 'plant-analyzer-window-scanmode'}" Margin="5 0 5 0"/>
<Button Name="OnButton" Text="{Loc 'plant-analyzer-window-mode-on'}" StyleClasses="OpenRight"/>
<Button Name="OffButton" Text="{Loc 'plant-analyzer-window-mode-off'}" StyleClasses="OpenLeft"/>
</BoxContainer>
<BoxContainer Name="Top">
<Label Name="NoData" Text="{Loc 'plant-analyzer-window-no-seed-information-text'}" Margin="10 0 0 0"/>
</BoxContainer>
<TabContainer Name="Tabs" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" HorizontalExpand="True">
<BoxContainer Name ="{Loc 'plant-analyzer-window-tab-basics'}" Orientation="Vertical" VerticalAlignment="Stretch" Margin="10 0 5 0">
<Label Name="PlantName" Margin="0 5 0 5"/>
<Label Name="PlantYield" Margin="0 5 0 5"/>
<Label Name="Potency" Margin="0 5 0 5"/>
<Label Name="Repeat" Margin="0 5 0 5"/>
<Label Name="Chemicals" Margin="0 5 0 5"/>
<Label Name="ConsumeGases" Margin="0 5 0 5" />
<Label Name="ExudeGases" Margin="0 5 0 5" />
<Label Name="Lifespan" Margin="0 5 0 5"/>
<Label Name="Maturation" Margin="0 5 0 5"/>
<Label Name="Production" Margin="0 5 0 5"/>
<Label Name="GrowthStages" Margin="0 5 0 5"/>
<Label Name="Endurance" Margin="0 5 0 5"/>
</BoxContainer>
<BoxContainer Name="{Loc 'plant-analyzer-window-tab-tolerances'}" Orientation="Vertical" VerticalAlignment="Stretch" Margin="10 0 5 0">
<Label Name="NutrientUsage" Margin="0 5 0 5"/>
<Label Name="WaterUsage" Margin="0 5 0 5"/>
<Label Name="IdealHeat" Margin="0 5 0 5"/>
<Label Name="HeatTolerance" Margin="0 5 0 5"/>
<Label Name="IdealLight" Margin="0 5 0 5"/>
<Label Name="LightTolerance" Margin="0 5 0 5"/>
<Label Name="ToxinsTolerance" Margin="0 5 0 5"/>
<Label Name="LowPressureTolerance" Margin="0 5 0 5"/>
<Label Name="HighPressureTolerance" Margin="0 5 0 5"/>
<Label Name="PestTolerance" Margin="0 5 0 5"/>
<Label Name="WeedTolerance" Margin="0 5 0 5"/>
</BoxContainer>
<BoxContainer Name="{Loc 'plant-analyzer-window-tab-mutations'}" Orientation="Vertical" VerticalAlignment="Stretch" Margin="10 0 5 0">
<Label Name="PlantSpeciation" Margin="0 5 0 5"/>
<Label Name="Traits" Margin="0 5 0 5"/>
<Label Name="ExtraInfo" Margin="0 5 0 5"/>
</BoxContainer>
</TabContainer>
</GridContainer>
</controls:FancyWindow>
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
using Content.Shared._CorvaxNext.PlantAnalyzer;
using Robust.Client.AutoGenerated;
using Robust.Client.GameObjects;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Prototypes;
using System.Linq;
using System.Text;
using FancyWindow = Content.Client.UserInterface.Controls.FancyWindow;

namespace Content.Client._CorvaxNext.PlantAnalyzer.UI;

[GenerateTypedNameReferences]
public sealed partial class PlantAnalyzerWindow : FancyWindow
{
private readonly IEntityManager _entityManager;
private readonly ButtonGroup _buttonGroup = new();

private const string IndentedNewline = "\n ";

public PlantAnalyzerWindow(PlantAnalyzerBoundUserInterface owner)
{
RobustXamlLoader.Load(this);

var dependencies = IoCManager.Instance!;
_entityManager = dependencies.Resolve<IEntityManager>();

OnButton.Group = _buttonGroup;
OnButton.ToggleMode = true;
OffButton.Group = _buttonGroup;
OffButton.ToggleMode = true;

OnButton.OnPressed += _ => owner.AdvPressed(true);
OffButton.OnPressed += _ => owner.AdvPressed(false);
}

public void Populate(PlantAnalyzerScannedSeedPlantInformation msg)
{
var target = _entityManager.GetEntity(msg.TargetEntity);
Title = Loc.GetString("plant-analyzer-interface-title");

if (target is null)
{
NoData.Visible = true;
return;
}
NoData.Visible = false;

if (msg.AdvancedInfo is not null)
{
OnButton.Pressed = true;
}
else
{
OffButton.Pressed = true;
}

// Process message fields into strings.
StringBuilder chemString = new();
if (msg.SeedChem is not null)
{
foreach (var chem in msg.SeedChem)
{
chemString.Append(IndentedNewline);
chemString.Append(chem);
}
}

StringBuilder exudeGases = GetStringFromGasFlags(msg.ExudeGases);
StringBuilder consudeGases = GetStringFromGasFlags(msg.ConsumeGases);

if (msg.IsTray)
PlantName.Text = Loc.GetString("plant-analyzer-window-label-name-scanned-plant", ("seedName", Loc.GetString(string.IsNullOrEmpty(msg.SeedName) ? "plant-analyzer-unknown-plant" : msg.SeedName)));
else
PlantName.Text = Loc.GetString("plant-analyzer-window-label-name-scanned-seed", ("seedName", Loc.GetString(string.IsNullOrEmpty(msg.SeedName) ? "plant-analyzer-unknown-plant" : msg.SeedName)));
// Basics
PlantYield.Text = Loc.GetString("plant-analyzer-plant-yield-text", ("seedYield", $"{msg.SeedYield:D0}"));
Potency.Text = Loc.GetString("plant-analyzer-plant-potency-text", ("seedPotency", $"{msg.SeedPotency:F0}"));
Repeat.Text = Loc.GetString("plant-analyzer-plant-harvest-text", ("plantHarvestType", Loc.GetString($"plant-analyzer-harvest-{msg.HarvestType}").ToString()));
Endurance.Text = Loc.GetString("plant-analyzer-plant-endurance-text", ("seedEndurance", $"{msg.Endurance:F0}"));
Chemicals.Text = Loc.GetString("plant-analyzer-plant-chemistry-text", ("seedChem", chemString));
ExudeGases.Text = Loc.GetString("plant-analyzer-plant-exude-text", ("gases", exudeGases.Length == 0 ? Loc.GetString("plant-analyzer-plant-gases-none") : exudeGases.ToString()));
ConsumeGases.Text = Loc.GetString("plant-analyzer-plant-consume-text", ("gases", consudeGases.Length == 0 ? Loc.GetString("plant-analyzer-plant-gases-none") : consudeGases.ToString()));
Lifespan.Text = Loc.GetString("plant-analyzer-plant-lifespan-text", ("lifespan", $"{msg.Lifespan:F1}"));
Maturation.Text = Loc.GetString("plant-analyzer-plant-maturation-text", ("maturation", $"{msg.Maturation:F1}"));
Production.Text = Loc.GetString("plant-analyzer-plant-production-text", ("production", $"{msg.Production:F1}"));
GrowthStages.Text = Loc.GetString("plant-analyzer-plant-growthstages-text", ("growthStages", $"{msg.GrowthStages:D0}"));
// Tolerances
var adv = msg.AdvancedInfo;
NutrientUsage.Text = Loc.GetString("plant-analyzer-tolerance-nutrient-usage", ("nutrientUsage", adv is null ? "-" : $"{adv.Value.NutrientConsumption:F2}"));
WaterUsage.Text = Loc.GetString("plant-analyzer-tolerance-water-usage", ("waterUsage", adv is null ? "-" : $"{adv.Value.WaterConsumption:F2}"));
IdealHeat.Text = Loc.GetString("plant-analyzer-tolerance-ideal-heat", ("idealHeat", adv is null ? "-" : $"{adv.Value.IdealHeat:F0}"));
HeatTolerance.Text = Loc.GetString("plant-analyzer-tolerance-heat-tolerance", ("heatTolerance", adv is null ? "-" : $"{adv.Value.HeatTolerance:F1}"));
IdealLight.Text = Loc.GetString("plant-analyzer-tolerance-ideal-light", ("idealLight", adv is null ? "-" : $"{adv.Value.IdealLight:F1}"));
LightTolerance.Text = Loc.GetString("plant-analyzer-tolerance-light-tolerance", ("lightTolerance", adv is null ? "-" : $"{adv.Value.LightTolerance:F1}"));
ToxinsTolerance.Text = Loc.GetString("plant-analyzer-tolerance-toxin-tolerance", ("toxinsTolerance", adv is null ? "-" : $"{adv.Value.ToxinsTolerance:F1}"));
LowPressureTolerance.Text = Loc.GetString("plant-analyzer-tolerance-low-pressure", ("lowPressureTolerance", adv is null ? "-" : $"{adv.Value.LowPressureTolerance:F1}")); ;
HighPressureTolerance.Text = Loc.GetString("plant-analyzer-tolerance-high-pressure", ("highPressureTolerance", adv is null ? "-" : $"{adv.Value.HighPressureTolerance:F1}"));
PestTolerance.Text = Loc.GetString("plant-analyzer-tolerance-pest-tolerance", ("pestTolerance", adv is null ? "-" : $"{adv.Value.PestTolerance:F1}"));
WeedTolerance.Text = Loc.GetString("plant-analyzer-tolerance-weed-tolerance", ("weedTolerance", adv is null ? "-" : $"{adv.Value.WeedTolerance:F1}"));
// Misc

if (adv is not null)
{
var advInst = adv.Value;
StringBuilder mutations = new();
if (advInst.Mutations.HasFlag(MutationFlags.TurnIntoKudzu))
{
mutations.Append(IndentedNewline);
mutations.Append(Loc.GetString("plant-analyzer-mutation-turnintokudzu"));
}
if (advInst.Mutations.HasFlag(MutationFlags.Seedless))
{
mutations.Append(IndentedNewline);
mutations.Append(Loc.GetString("plant-analyzer-mutation-seedless"));
}
if (advInst.Mutations.HasFlag(MutationFlags.Ligneous))
{
mutations.Append(IndentedNewline);
mutations.Append(Loc.GetString("plant-analyzer-mutation-ligneous"));
}
if (advInst.Mutations.HasFlag(MutationFlags.CanScream))
{
mutations.Append(IndentedNewline);
mutations.Append(Loc.GetString("plant-analyzer-mutation-canscream"));
}

Traits.Text = Loc.GetString("plant-analyzer-plant-mutations-text", ("traits", mutations.ToString()));
}
else
{
Traits.Text = Loc.GetString("plant-analyzer-plant-mutations-text", ("traits", "-"));
}

StringBuilder speciation = new();
if (msg.Speciation is null)
{
speciation.Append("-");
}
else
{
foreach (var species in msg.Speciation)
{
speciation.Append(IndentedNewline);
speciation.Append(Loc.GetString(species));
}
}

PlantSpeciation.Text = Loc.GetString("plant-analyzer-plant-speciation-text", ("speciation", speciation.ToString()));
}

private StringBuilder GetStringFromGasFlags(GasFlags flags)
{
StringBuilder output = new();
if (flags.HasFlag(GasFlags.Nitrogen))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-nitrogen"));
}
if (flags.HasFlag(GasFlags.Oxygen))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-oxygen"));
}
if (flags.HasFlag(GasFlags.CarbonDioxide))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-co2"));
}
if (flags.HasFlag(GasFlags.Plasma))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-plasma"));
}
if (flags.HasFlag(GasFlags.Tritium))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-tritium"));
}
if (flags.HasFlag(GasFlags.WaterVapor))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-water-vapor"));
}
if (flags.HasFlag(GasFlags.Ammonia))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-ammonia"));
}
if (flags.HasFlag(GasFlags.NitrousOxide))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-n2o"));
}
if (flags.HasFlag(GasFlags.Frezon))
{
output.Append(IndentedNewline);
output.Append(Loc.GetString("gases-frezon"));
}
return output;
}
}
9 changes: 7 additions & 2 deletions Content.Server/Fluids/EntitySystems/PuddleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ private void OnSolutionUpdate(Entity<PuddleComponent> entity, ref SolutionContai

_deletionQueue.Remove(entity);
UpdateSlip(entity, entity.Comp, args.Solution);
UpdateSlow(entity, args.Solution);
UpdateSlow(entity, args.Solution, entity.Comp); // Corvax-Next-Footprints
UpdateEvaporation(entity, args.Solution);
UpdateAppearance(entity, entity.Comp);
}
Expand Down Expand Up @@ -421,8 +421,13 @@ private void UpdateSlip(EntityUid entityUid, PuddleComponent component, Solution
}
}

private void UpdateSlow(EntityUid uid, Solution solution)
private void UpdateSlow(EntityUid uid, Solution solution, PuddleComponent component) // Corvax-Next-Footprints
{
// Corvax-Next-Footprints-Start
if (!component.ViscosityAffectsMovement)
return;
// Corvax-Next-Footprints-End

var maxViscosity = 0f;
foreach (var (reagent, _) in solution.Contents)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using Content.Shared.DoAfter;
using Robust.Shared.Audio;

namespace Content.Server.Botany.Components; // This is how it supposed to be

/// <summary>
/// After scanning, retrieves the target Uid to use with its related UI.
/// </summary>
[RegisterComponent]
public sealed partial class PlantAnalyzerComponent : Component
{
[DataDefinition]
public partial struct PlantAnalyzerSettings
{
[DataField]
public bool AdvancedScan;

[DataField]
public float ScanDelay;

[DataField]
public float AdvScanDelay;
}

[DataField, ViewVariables]
public PlantAnalyzerSettings Settings = new();

[DataField, ViewVariables(VVAccess.ReadOnly)]
public DoAfterId? DoAfter;

[DataField]
public SoundSpecifier? ScanningEndSound;
}
Loading

0 comments on commit d189543

Please sign in to comment.