Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put Senior Roles on Every Map (Except Edge and Glacier) #290

Merged
merged 22 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions Content.IntegrationTests/Tests/MaterialArbitrageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public async Task NoMaterialArbitrage()
var pricing = entManager.System<PricingSystem>();
var stackSys = entManager.System<StackSystem>();
var mapSystem = server.System<SharedMapSystem>();
var latheSys = server.System<SharedLatheSystem>();
var compFact = server.ResolveDependency<IComponentFactory>();

Assert.That(mapSystem.IsInitialized(testMap.MapId));
Expand All @@ -53,15 +54,12 @@ public async Task NoMaterialArbitrage()
var materialName = compFact.GetComponentName(typeof(MaterialComponent));
var destructibleName = compFact.GetComponentName(typeof(DestructibleComponent));

// construct inverted lathe recipe dictionary
Dictionary<string, List<LatheRecipePrototype>> latheRecipes = new();
foreach (var proto in protoManager.EnumeratePrototypes<LatheRecipePrototype>())
{
latheRecipes.GetOrNew(proto.Result).Add(proto);
}
// get the inverted lathe recipe dictionary
var latheRecipes = latheSys.InverseRecipes;

// Lets assume the possible lathe for resource multipliers:
var multiplier = MathF.Pow(LatheComponent.DefaultPartRatingMaterialUseMultiplier, MachinePartComponent.MaxRating - 1);
// TODO: each recipe can technically have its own cost multiplier associated with it, so this test needs redone to factor that in.
var multiplier = MathF.Pow(0.85f, 3);

// create construction dictionary
Dictionary<string, ConstructionComponent> constructionRecipes = new();
Expand Down Expand Up @@ -104,7 +102,7 @@ public async Task NoMaterialArbitrage()
continue;

var stackProto = protoManager.Index<StackPrototype>(materialStep.MaterialPrototypeId);
var spawnProto = protoManager.Index<EntityPrototype>(stackProto.Spawn);
var spawnProto = protoManager.Index(stackProto.Spawn);

if (!spawnProto.Components.ContainsKey(materialName) ||
!spawnProto.Components.TryGetValue(compositionName, out var compositionReg))
Expand Down
9 changes: 5 additions & 4 deletions Content.IntegrationTests/Tests/PostMapInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,16 @@ public async Task AllMapsTested()
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
var pool = protoMan.Index<GameMapPoolPrototype>("DefaultMapPool");

var gameMaps = protoMan.EnumeratePrototypes<GameMapPrototype>()
.Where(x => !pair.IsTestPrototype(x))
var gameMapsProtos = protoMan.EnumeratePrototypes<GameMapPrototype>()
.Where(x => !pair.IsTestPrototype(x) && pool.Maps.Contains(x.ID))
.Select(x => x.ID)
.ToHashSet();

Assert.That(gameMaps.Remove(PoolManager.TestMap));
var maps = GameMaps.Where(x => pool.Maps.Contains(x)).ToHashSet();

Assert.That(gameMaps, Is.EquivalentTo(GameMaps.ToHashSet()), "Game map prototype missing from test cases.");
Assert.That(gameMapsProtos, Is.EquivalentTo(maps), "Game map prototype missing from test cases.");

await pair.CleanReturnAsync();
}
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/IgnitionSource/IgnitionSourceSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private void OnItemToggle(Entity<ItemToggleHotComponent> ent, ref ItemToggledEve
/// </summary>
public void SetIgnited(Entity<IgnitionSourceComponent?> ent, bool ignited = true)
{
if (!Resolve(ent, ref ent.Comp))
if (!Resolve(ent, ref ent.Comp, false))
return;

ent.Comp.Ignited = ignited;
Expand Down
14 changes: 7 additions & 7 deletions Content.Shared/Lathe/SharedLatheSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public abstract class SharedLatheSystem : EntitySystem
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly SharedMaterialStorageSystem _materialStorage = default!;

private readonly Dictionary<string, List<LatheRecipePrototype>> _inverseRecipeDictionary = new();
public readonly Dictionary<string, List<LatheRecipePrototype>> InverseRecipes = new();

public override void Initialize()
{
Expand Down Expand Up @@ -83,20 +83,20 @@ private void OnPrototypesReloaded(PrototypesReloadedEventArgs obj)

private void BuildInverseRecipeDictionary()
{
_inverseRecipeDictionary.Clear();
InverseRecipes.Clear();
foreach (var latheRecipe in _proto.EnumeratePrototypes<LatheRecipePrototype>())
{
if (latheRecipe.Result == null)
if (latheRecipe.Result is not {} result)
continue;

_inverseRecipeDictionary.GetOrNew(latheRecipe.Result).Add(latheRecipe);
InverseRecipes.GetOrNew(result).Add(latheRecipe);
}
}

public bool TryGetRecipesFromEntity(string prototype, [NotNullWhen(true)] out List<LatheRecipePrototype>? recipes)
{
recipes = new();
if (_inverseRecipeDictionary.TryGetValue(prototype, out var r))
if (InverseRecipes.TryGetValue(prototype, out var r))
recipes.AddRange(r);
return recipes.Count != 0;
}
Expand All @@ -111,7 +111,7 @@ public string GetRecipeName(LatheRecipePrototype proto)
if (!string.IsNullOrWhiteSpace(proto.Name))
return Loc.GetString(proto.Name);

if (proto.Result is { } result)
if (proto.Result is {} result)
{
return _proto.Index(result).Name;
}
Expand All @@ -137,7 +137,7 @@ public string GetRecipeDescription(LatheRecipePrototype proto)
if (!string.IsNullOrWhiteSpace(proto.Description))
return Loc.GetString(proto.Description);

if (proto.Result is { } result)
if (proto.Result is {} result)
{
return _proto.Index(result).Description;
}
Expand Down
Loading
Loading