Skip to content

Commit

Permalink
Merge branch 'master' into radial-menu-settings
Browse files Browse the repository at this point in the history
  • Loading branch information
KashRas2 authored Aug 20, 2024
2 parents c814886 + ffcde0f commit 9ce6b0c
Show file tree
Hide file tree
Showing 717 changed files with 282,993 additions and 1,732 deletions.
111 changes: 111 additions & 0 deletions Content.Client/ADT/UI/AnimatedBackground/AnimatedBackgroundControl.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using System.Linq;
using Content.Shared.ADT;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Graphics.RSI;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;

namespace Content.Client.ADT.UI.AnimatedBackground;

public sealed class AnimatedBackgroundControl : TextureRect
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IClyde _clyde = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

private string _rsiPath = "/Textures/ADT/LobbyScreens/backgrounds/native.rsi";
public RSI? _RSI;
private const int States = 1;

private IRenderTexture? _buffer;

private readonly float[] _timer = new float[States];
private readonly float[][] _frameDelays = new float[States][];
private readonly int[] _frameCounter = new int[States];
private readonly Texture[][] _frames = new Texture[States][];

public AnimatedBackgroundControl()
{
IoCManager.InjectDependencies(this);

InitializeStates();
}

private void InitializeStates()
{
_RSI ??= _resourceCache.GetResource<RSIResource>(_rsiPath).RSI;

for (var i = 0; i < States; i++)
{
if (!_RSI.TryGetState((i + 1).ToString(), out var state))
continue;

_frames[i] = state.GetFrames(RsiDirection.South);
_frameDelays[i] = state.GetDelays();
_frameCounter[i] = 0;
}
}

public void SetRSI(RSI? rsi)
{
_RSI = rsi;
InitializeStates();
}

protected override void FrameUpdate(FrameEventArgs args)
{
base.FrameUpdate(args);

for (var i = 0; i < _frames.Length; i++)
{
var delays = _frameDelays[i];
if (delays.Length == 0)
continue;

_timer[i] += args.DeltaSeconds;

var currentFrameIndex = _frameCounter[i];

if (!(_timer[i] >= delays[currentFrameIndex]))
continue;

_timer[i] -= delays[currentFrameIndex];
_frameCounter[i] = (currentFrameIndex + 1) % _frames[i].Length;
Texture = _frames[i][_frameCounter[i]];
}
}

protected override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);

if (_buffer is null)
return;

handle.DrawTextureRect(_buffer.Texture, PixelSizeBox);
}

protected override void Resized()
{
base.Resized();
_buffer?.Dispose();
_buffer = _clyde.CreateRenderTarget(PixelSize, RenderTargetColorFormat.Rgba8Srgb);
}

protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_buffer?.Dispose();
}

public void RandomizeBackground()
{
var backgroundsProto = _prototypeManager.EnumeratePrototypes<AnimatedLobbyScreenPrototype>().ToList();
var random = new Random();
var index = random.Next(backgroundsProto.Count);
_rsiPath = $"/Textures/{backgroundsProto[index].Path}";
InitializeStates();
}
}
2 changes: 1 addition & 1 deletion Content.Client/Lobby/LobbyState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void UpdateLobbyBackground()
{
if (_gameTicker.LobbyBackground != null)
{
Lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
Lobby!.Background.SetRSI(_resourceCache.GetResource<RSIResource>(_gameTicker.LobbyBackground).RSI); // ADT Tweak
}
else
{
Expand Down
8 changes: 5 additions & 3 deletions Content.Client/Lobby/UI/LobbyGui.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
xmlns:style="clr-namespace:Content.Client.Stylesheets"
xmlns:lobbyUi="clr-namespace:Content.Client.Lobby.UI"
xmlns:info="clr-namespace:Content.Client.Info"
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets">
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets"
xmlns:ui="clr-namespace:Content.Client.ADT.UI"
xmlns:animatedBackground="clr-namespace:Content.Client.ADT.UI.AnimatedBackground">
<!-- Background -->
<TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name="Background"
Stretch="KeepAspectCovered" />
<animatedBackground:AnimatedBackgroundControl Access="Public" Name="Background" VerticalExpand="True" HorizontalExpand="True"
Stretch="KeepAspectCovered" />
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal"
Margin="10 10 10 10" SeparationOverride="2">
<SplitContainer State="Auto" HorizontalExpand="True">
Expand Down
18 changes: 15 additions & 3 deletions Content.Client/VendingMachines/UI/VendingMachineMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected override void Dispose(bool disposing)
/// Populates the list of available items on the vending machine interface
/// and sets icons based on their prototypes
/// </summary>
public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int> filteredInventory, double priceMultiplier, int credits, string? filter = null) //ADT-Economy
public void Populate(EntityUid entityUid, List<VendingMachineInventoryEntry> inventory, out List<int> filteredInventory, double priceMultiplier, int credits, string? filter = null) //ADT-Economy
{
//ADT-Economy-Start
CreditsLabel.Text = Loc.GetString("vending-ui-credits-amount", ("credits", credits));
Expand All @@ -72,6 +72,7 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int>
return;
OnWithdraw?.Invoke(new VendingMachineWithdrawMessage());
};
var vendComp = _entityManager.GetComponent<VendingMachineComponent>(entityUid); //ADT-Economy
//ADT-Economy-End
filteredInventory = new();

Expand Down Expand Up @@ -99,7 +100,6 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int>
for (var i = 0; i < inventory.Count; i++)
{
var entry = inventory[i];
var price = (int)(entry.Price * priceMultiplier); //ADT-Economy
var vendingItem = VendingContents[i - filterCount];
vendingItem.Text = string.Empty;
vendingItem.Icon = null;
Expand All @@ -110,6 +110,18 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int>
_dummies.Add(entry.ID, dummy);
}

//ADT-Economy-Start
var price = 0;
if (!vendComp.AllForFree)
{
price = (int)(entry.Price * priceMultiplier);
}
else
{
price = 0; // Это работает только если заспавненный вендомат уже был с этим значением. Спасибо визардам и их bounduserinterface емае.
}
//ADT-Economy-Start

var itemName = Identity.Name(dummy, _entityManager);
Texture? icon = null;
if (_prototypeManager.TryIndex<EntityPrototype>(entry.ID, out var prototype))
Expand All @@ -129,7 +141,7 @@ public void Populate(List<VendingMachineInventoryEntry> inventory, out List<int>
if (itemName.Length > longestEntry.Length)
longestEntry = itemName;

vendingItem.Text = $" [{price}$] {itemName} [{entry.Amount}]"; //ADT-Economy
vendingItem.Text = $"[{price}$] {itemName} [{entry.Amount}]"; //ADT-Economy
vendingItem.Icon = icon;
filteredInventory.Add(i);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected override void Open()
_menu.OnSearchChanged += OnSearchChanged;
_menu.OnWithdraw += SendMessage; //ADT-Economy

_menu.Populate(_cachedInventory, out _cachedFilteredIndex, component.PriceMultiplier, component.Credits); //ADT-Economy
_menu.Populate(Owner, _cachedInventory, out _cachedFilteredIndex, component.PriceMultiplier, component.Credits); //ADT-Economy
}

protected override void UpdateState(BoundUserInterfaceState state)
Expand All @@ -51,7 +51,7 @@ protected override void UpdateState(BoundUserInterfaceState state)

_cachedInventory = newState.Inventory;

_menu?.Populate(_cachedInventory, out _cachedFilteredIndex, newState.PriceMultiplier, newState.Credits); //ADT-Economy
_menu?.Populate(Owner, _cachedInventory, out _cachedFilteredIndex, newState.PriceMultiplier, newState.Credits, _menu.SearchBar.Text); //ADT-Economy
}

private void OnItemSelected(ItemList.ItemListSelectedEventArgs args)
Expand Down Expand Up @@ -85,7 +85,7 @@ private void OnSearchChanged(string? filter)
{
//ADT-Economy-Start
var component = EntMan.GetComponent<VendingMachineComponent>(Owner);
_menu?.Populate(_cachedInventory, out _cachedFilteredIndex, component.PriceMultiplier, component.Credits, filter);
_menu?.Populate(Owner, _cachedInventory, out _cachedFilteredIndex, component.PriceMultiplier, component.Credits, filter);
//ADT-Economy-End
}
}
Expand Down
1 change: 1 addition & 0 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public sealed class PostMapInitTest
"ADT_Cluster",
"ADT_Core",
"ADT_Fland",
"ADT_Delta",
"ADT_Marathon",
"ADT_Meta",
"ADT_Oasis",
Expand Down
51 changes: 51 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/BZProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class BZProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialNitrousOxide = mixture.GetMoles(Gas.NitrousOxide);
var initialPlasma = mixture.GetMoles(Gas.Plasma);

var environmentEfficiency = mixture.Volume / mixture.Pressure;
var ratioEfficiency = Math.Min(initialNitrousOxide / initialPlasma, 1);

var bZFormed = Math.Min(0.01f * ratioEfficiency * environmentEfficiency, Math.Min(initialNitrousOxide * 0.4f, initialPlasma * 0.8f));

if (initialNitrousOxide - bZFormed * 0.4f < 0 || initialPlasma - (0.8f - bZFormed) < 0 || bZFormed <= 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

var amountDecomposed = 0.0f;
var nitrousOxideDecomposedFactor = Math.Max(4.0f * (initialPlasma / (initialNitrousOxide + initialPlasma) - 0.75f), 0);
if (nitrousOxideDecomposedFactor > 0)
{
amountDecomposed = 0.4f * bZFormed * nitrousOxideDecomposedFactor;
mixture.AdjustMoles(Gas.Oxygen, amountDecomposed);
mixture.AdjustMoles(Gas.Nitrogen, 0.5f * amountDecomposed);
}

mixture.AdjustMoles(Gas.BZ, Math.Max(0f, bZFormed * (1.0f - nitrousOxideDecomposedFactor)));
mixture.AdjustMoles(Gas.NitrousOxide, -0.4f * bZFormed);
mixture.AdjustMoles(Gas.Plasma, -0.8f * bZFormed * (1.0f - nitrousOxideDecomposedFactor));

var energyReleased = bZFormed * (Atmospherics.BZFormationEnergy + nitrousOxideDecomposedFactor * (Atmospherics.NitrousOxideDecompositionEnergy - Atmospherics.BZFormationEnergy));

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class HalonOxygenAbsorptionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialHalon = mixture.GetMoles(Gas.Halon);
var initialOxygen = mixture.GetMoles(Gas.Oxygen);

var temperature = mixture.Temperature;

var heatEfficiency = Math.Min(temperature / (Atmospherics.FireMinimumTemperatureToExist * 10f), Math.Min(initialHalon, initialOxygen * 20f));
if (heatEfficiency <= 0f || initialHalon - heatEfficiency < 0f || initialOxygen - heatEfficiency * 20f < 0f)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

mixture.AdjustMoles(Gas.Halon, -heatEfficiency);
mixture.AdjustMoles(Gas.Oxygen, -heatEfficiency * 20f);
mixture.AdjustMoles(Gas.CarbonDioxide, heatEfficiency * 5f);

var energyUsed = heatEfficiency * Atmospherics.HalonCombustionEnergy;
var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyUsed) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
40 changes: 40 additions & 0 deletions Content.Server/ADT/Atmos/Reactions/HealiumProductionReaction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Content.Server.Atmos.EntitySystems;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Reactions;
using JetBrains.Annotations;

namespace Content.Server.Atmos.Reactions;

[UsedImplicitly]
public sealed partial class HealiumProductionReaction : IGasReactionEffect
{
public ReactionResult React(GasMixture mixture, IGasMixtureHolder? holder, AtmosphereSystem atmosphereSystem, float heatScale)
{
var initialHyperNoblium = mixture.GetMoles(Gas.HyperNoblium);
if (initialHyperNoblium >= 5.0f && mixture.Temperature > 20f)
return ReactionResult.NoReaction;

var initialBZ = mixture.GetMoles(Gas.BZ);
var initialFrezon = mixture.GetMoles(Gas.Frezon);

var temperature = mixture.Temperature;
var heatEfficiency = Math.Min(temperature * 0.3f, Math.Min(initialFrezon * 2.75f, initialBZ * 0.25f));

if (heatEfficiency <= 0 || initialFrezon - heatEfficiency * 2.75f < 0 || initialBZ - heatEfficiency * 0.25f < 0)
return ReactionResult.NoReaction;

var oldHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);

mixture.AdjustMoles(Gas.Frezon, -heatEfficiency * 2.75f);
mixture.AdjustMoles(Gas.BZ, -heatEfficiency * 0.25f);
mixture.AdjustMoles(Gas.Healium, heatEfficiency * 3);

var energyReleased = heatEfficiency * Atmospherics.HealiumFormationEnergy;

var newHeatCapacity = atmosphereSystem.GetHeatCapacity(mixture, true);
if (newHeatCapacity > Atmospherics.MinimumHeatCapacity)
mixture.Temperature = Math.Max((mixture.Temperature * oldHeatCapacity + energyReleased) / newHeatCapacity, Atmospherics.TCMB);

return ReactionResult.Reacting;
}
}
Loading

0 comments on commit 9ce6b0c

Please sign in to comment.