Skip to content

Commit

Permalink
Merge branch 'space-sunrise:master' into Loadout-new
Browse files Browse the repository at this point in the history
  • Loading branch information
Nrd-K authored Dec 17, 2024
2 parents 19a5466 + 48ea3a1 commit fa700c8
Show file tree
Hide file tree
Showing 204 changed files with 24,293 additions and 11,773 deletions.
285 changes: 161 additions & 124 deletions Content.Client/Chemistry/UI/ChemMasterWindow.xaml.cs

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Content.Client/Explosion/ScatteringGrenadeSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Content.Shared.Explosion.EntitySystems;

namespace Content.Client.Explosion;

public sealed class ScatteringGrenadeSystem : SharedScatteringGrenadeSystem
{

}
5 changes: 4 additions & 1 deletion Content.Client/Store/Ui/StoreMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void UpdateBalance(Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> ba
foreach (var ((_, amount), proto) in currency)
{
balanceStr += Loc.GetString("store-ui-balance-display", ("amount", amount),
("currency", Loc.GetString(proto.DisplayName, ("amount", 1))));
("currency", Loc.GetString(proto.DisplayName, ("amount", 1)))) + "\n";
}

BalanceInfo.SetMarkup(balanceStr.TrimEnd());
Expand All @@ -63,7 +63,10 @@ public void UpdateBalance(Dictionary<ProtoId<CurrencyPrototype>, FixedPoint2> ba
foreach (var type in currency)
{
if (type.Value.CanWithdraw && type.Value.Cash != null && type.Key.Item2 > 0)
{
disabled = false;
break;
}
}

WithdrawButton.Disabled = disabled;
Expand Down
17 changes: 10 additions & 7 deletions Content.Client/Store/Ui/StoreWithdrawWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public sealed partial class StoreWithdrawWindow : DefaultWindow
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

private Dictionary<FixedPoint2, CurrencyPrototype> _validCurrencies = new();
private Dictionary<CurrencyPrototype, FixedPoint2> _validCurrencies = new();
private HashSet<CurrencyWithdrawButton> _buttons = new();
public event Action<BaseButton.ButtonEventArgs, string, int>? OnWithdrawAttempt;

Expand All @@ -36,7 +36,7 @@ public void CreateCurrencyButtons(Dictionary<ProtoId<CurrencyPrototype>, FixedPo
if (!_prototypeManager.TryIndex(currency.Key, out var proto))
continue;

_validCurrencies.Add(currency.Value, proto);
_validCurrencies.Add(proto, currency.Value);
}

//this shouldn't ever happen but w/e
Expand All @@ -47,14 +47,17 @@ public void CreateCurrencyButtons(Dictionary<ProtoId<CurrencyPrototype>, FixedPo
_buttons.Clear();
foreach (var currency in _validCurrencies)
{
if (!currency.Key.CanWithdraw)
continue;

var button = new CurrencyWithdrawButton()
{
Id = currency.Value.ID,
Amount = currency.Key,
Id = currency.Key.ID,
Amount = currency.Value,
MinHeight = 20,
Text = Loc.GetString("store-withdraw-button-ui", ("currency",Loc.GetString(currency.Value.DisplayName, ("amount", currency.Key)))),
Text = Loc.GetString("store-withdraw-button-ui", ("currency",Loc.GetString(currency.Key.DisplayName, ("amount", currency.Value)))),
Disabled = false,
};
button.Disabled = false;
button.OnPressed += args =>
{
OnWithdrawAttempt?.Invoke(args, button.Id, WithdrawSlider.Value);
Expand All @@ -65,7 +68,7 @@ public void CreateCurrencyButtons(Dictionary<ProtoId<CurrencyPrototype>, FixedPo
ButtonContainer.AddChild(button);
}

var maxWithdrawAmount = _validCurrencies.Keys.Max().Int();
var maxWithdrawAmount = _validCurrencies.Values.Max().Int();

// setup withdraw slider
WithdrawSlider.MinValue = 1;
Expand Down
132 changes: 132 additions & 0 deletions Content.IntegrationTests/Tests/Lathe/LatheTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
using System.Collections.Generic;
using System.Linq;
using Content.Shared.Lathe;
using Content.Shared.Materials;
using Content.Shared.Prototypes;
using Content.Shared.Research.Prototypes;
using Content.Shared.Whitelist;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.Lathe;

[TestFixture]
public sealed class LatheTest
{
[Test]
public async Task TestLatheRecipeIngredientsFitLathe()
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;

var mapData = await pair.CreateTestMap();

var entMan = server.EntMan;
var protoMan = server.ProtoMan;
var compFactory = server.ResolveDependency<IComponentFactory>();
var materialStorageSystem = server.System<SharedMaterialStorageSystem>();
var whitelistSystem = server.System<EntityWhitelistSystem>();

await server.WaitAssertion(() =>
{
// Find all the lathes
var latheProtos = protoMan.EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract)
.Where(p => !pair.IsTestPrototype(p))
.Where(p => p.HasComponent<LatheComponent>());

// Find every EntityPrototype that can be inserted into a MaterialStorage
var materialEntityProtos = protoMan.EnumeratePrototypes<EntityPrototype>()
.Where(p => !p.Abstract)
.Where(p => !pair.IsTestPrototype(p))
.Where(p => p.HasComponent<PhysicalCompositionComponent>());

// Spawn all of the above material EntityPrototypes - we need actual entities to do whitelist checks
var materialEntities = new List<EntityUid>(materialEntityProtos.Count());
foreach (var materialEntityProto in materialEntityProtos)
{
materialEntities.Add(entMan.SpawnEntity(materialEntityProto.ID, mapData.GridCoords));
}

Assert.Multiple(() =>
{
// Check each lathe individually
foreach (var latheProto in latheProtos)
{
if (!latheProto.TryGetComponent<LatheComponent>(out var latheComp, compFactory))
continue;

if (!latheProto.TryGetComponent<MaterialStorageComponent>(out var storageComp, compFactory))
continue;

// Test which material-containing entities are accepted by this lathe
var acceptedMaterials = new HashSet<ProtoId<MaterialPrototype>>();
foreach (var materialEntity in materialEntities)
{
Assert.That(entMan.TryGetComponent<PhysicalCompositionComponent>(materialEntity, out var compositionComponent));
if (whitelistSystem.IsWhitelistFail(storageComp.Whitelist, materialEntity))
continue;

// Mark the lathe as accepting each material in the entity
foreach (var (material, _) in compositionComponent.MaterialComposition)
{
acceptedMaterials.Add(material);
}
}

// Collect all the recipes assigned to this lathe
var recipes = new List<ProtoId<LatheRecipePrototype>>();
recipes.AddRange(latheComp.StaticRecipes);
recipes.AddRange(latheComp.DynamicRecipes);
if (latheProto.TryGetComponent<EmagLatheRecipesComponent>(out var emagRecipesComp, compFactory))
{
recipes.AddRange(emagRecipesComp.EmagStaticRecipes);
recipes.AddRange(emagRecipesComp.EmagDynamicRecipes);
}

// Check each recipe assigned to this lathe
foreach (var recipeId in recipes)
{
Assert.That(protoMan.TryIndex(recipeId, out var recipeProto));

// Track the total material volume of the recipe
var totalQuantity = 0;
// Check each material called for by the recipe
foreach (var (materialId, quantity) in recipeProto.Materials)
{
Assert.That(protoMan.TryIndex(materialId, out var materialProto));
// Make sure the material is accepted by the lathe
Assert.That(acceptedMaterials, Does.Contain(materialId), $"Lathe {latheProto.ID} has recipe {recipeId} but does not accept any materials containing {materialId}");
totalQuantity += quantity;
}
// Make sure the recipe doesn't call for more material than the lathe can hold
if (storageComp.StorageLimit != null)
Assert.That(totalQuantity, Is.LessThanOrEqualTo(storageComp.StorageLimit), $"Lathe {latheProto.ID} has recipe {recipeId} which calls for {totalQuantity} units of materials but can only hold {storageComp.StorageLimit}");
}
}
});
});

await pair.CleanReturnAsync();
}

[Test]
public async Task AllLatheRecipesValidTest()
{
await using var pair = await PoolManager.GetServerClient();

var server = pair.Server;
var proto = server.ProtoMan;

Assert.Multiple(() =>
{
foreach (var recipe in proto.EnumeratePrototypes<LatheRecipePrototype>())
{
if (recipe.Result == null)
Assert.That(recipe.ResultReagents, Is.Not.Null, $"Recipe '{recipe.ID}' has no result or result reagents.");
}
});

await pair.CleanReturnAsync();
}
}
20 changes: 0 additions & 20 deletions Content.IntegrationTests/Tests/ResearchTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,4 @@ await server.WaitAssertion(() =>

await pair.CleanReturnAsync();
}

[Test]
public async Task AllLatheRecipesValidTest()
{
await using var pair = await PoolManager.GetServerClient();

var server = pair.Server;
var proto = server.ResolveDependency<IPrototypeManager>();

Assert.Multiple(() =>
{
foreach (var recipe in proto.EnumeratePrototypes<LatheRecipePrototype>())
{
if (recipe.Result == null)
Assert.That(recipe.ResultReagents, Is.Not.Null, $"Recipe '{recipe.ID}' has no result or result reagents.");
}
});

await pair.CleanReturnAsync();
}
}
42 changes: 23 additions & 19 deletions Content.Server/Animals/Components/EggLayerComponent.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Server.Animals.Systems;
using Content.Shared.Storage;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
Expand All @@ -9,44 +10,47 @@ namespace Content.Server.Animals.Components;
/// It also grants an action to players who are controlling these entities, allowing them to do it manually.
/// </summary>

[RegisterComponent]
[RegisterComponent, Access(typeof(EggLayerSystem)), AutoGenerateComponentPause]
public sealed partial class EggLayerComponent : Component
{
[DataField]
public EntProtoId EggLayAction = "ActionAnimalLayEgg";
/// <summary>
/// The item that gets laid/spawned, retrieved from animal prototype.
/// </summary>
[DataField(required: true)]
public List<EntitySpawnEntry> EggSpawn = new();

/// <summary>
/// The amount of nutrient consumed on update.
/// Player action.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public float HungerUsage = 60f;
[DataField]
public EntProtoId EggLayAction = "ActionAnimalLayEgg";

[DataField]
public SoundSpecifier EggLaySound = new SoundPathSpecifier("/Audio/Effects/pop.ogg");

/// <summary>
/// Minimum cooldown used for the automatic egg laying.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float EggLayCooldownMin = 60f;

/// <summary>
/// Maximum cooldown used for the automatic egg laying.
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
[DataField]
public float EggLayCooldownMax = 120f;

/// <summary>
/// Set during component init.
/// The amount of nutrient consumed on update.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float CurrentEggLayCooldown;

[DataField(required: true), ViewVariables(VVAccess.ReadWrite)]
public List<EntitySpawnEntry> EggSpawn = default!;

[DataField]
public SoundSpecifier EggLaySound = new SoundPathSpecifier("/Audio/Effects/pop.ogg");

[DataField]
public float AccumulatedFrametime;
public float HungerUsage = 60f;

[DataField] public EntityUid? Action;

/// <summary>
/// When to next try to produce.
/// </summary>
[DataField, AutoPausedField]
public TimeSpan NextGrowth = TimeSpan.Zero;
}
59 changes: 0 additions & 59 deletions Content.Server/Animals/Components/UdderComponent.cs

This file was deleted.

Loading

0 comments on commit fa700c8

Please sign in to comment.