Salvage magnet revamp (#23119)
* Generic offering window * More work * weh * Parity * Progression meter * magnet * rona * PG asteroid work * code red * Asteroid spawnings * clams * a * Marker fixes * More fixes * Workings of biome asteroids * A * Fix this loading code * a * Fix masking * weh * Fixes * Magnet claiming * toe * petogue * magnet * Bunch of fixes * Fix default * Fixes * asteroids * Fix offerings * Localisation and a bunch of fixes * a * Fixes * Preliminary draft * Announcement fixes * Fixes and bump spawn rate * Fix asteroid spawns and UI * More fixes * Expeditions fix * fix * Gravity * Fix announcement rounding * a * Offset tweak * sus * jankass * Fix merge
This commit is contained in:
16
Content.Shared/Salvage/Magnet/AsteroidOffering.cs
Normal file
16
Content.Shared/Salvage/Magnet/AsteroidOffering.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Content.Shared.Procedural;
|
||||
|
||||
namespace Content.Shared.Salvage.Magnet;
|
||||
|
||||
/// <summary>
|
||||
/// Asteroid offered for the magnet.
|
||||
/// </summary>
|
||||
public record struct AsteroidOffering : ISalvageMagnetOffering
|
||||
{
|
||||
public DungeonConfigPrototype DungeonConfig;
|
||||
|
||||
/// <summary>
|
||||
/// Calculated marker layers for the asteroid.
|
||||
/// </summary>
|
||||
public Dictionary<string, int> MarkerLayers;
|
||||
}
|
||||
6
Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs
Normal file
6
Content.Shared/Salvage/Magnet/ISalvageMagnetOffering.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Content.Shared.Salvage.Magnet;
|
||||
|
||||
public interface ISalvageMagnetOffering
|
||||
{
|
||||
|
||||
}
|
||||
12
Content.Shared/Salvage/Magnet/MagnetClaimOfferEvent.cs
Normal file
12
Content.Shared/Salvage/Magnet/MagnetClaimOfferEvent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Salvage.Magnet;
|
||||
|
||||
/// <summary>
|
||||
/// Claim an offer from the magnet UI.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class MagnetClaimOfferEvent : BoundUserInterfaceMessage
|
||||
{
|
||||
public int Index;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Salvage.Magnet;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class SalvageMagnetBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public TimeSpan? EndTime;
|
||||
public TimeSpan NextOffer;
|
||||
|
||||
public TimeSpan Cooldown;
|
||||
public TimeSpan Duration;
|
||||
|
||||
public int ActiveSeed;
|
||||
|
||||
public List<int> Offers;
|
||||
|
||||
public SalvageMagnetBoundUserInterfaceState(List<int> offers)
|
||||
{
|
||||
Offers = offers;
|
||||
}
|
||||
}
|
||||
6
Content.Shared/Salvage/Magnet/SalvageMagnetUiKey.cs
Normal file
6
Content.Shared/Salvage/Magnet/SalvageMagnetUiKey.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Salvage.Magnet;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum SalvageMagnetUiKey : byte { Key }
|
||||
9
Content.Shared/Salvage/Magnet/SalvageOffering.cs
Normal file
9
Content.Shared/Salvage/Magnet/SalvageOffering.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Content.Shared.Salvage.Magnet;
|
||||
|
||||
/// <summary>
|
||||
/// Asteroid offered for the magnet.
|
||||
/// </summary>
|
||||
public record struct SalvageOffering : ISalvageMagnetOffering
|
||||
{
|
||||
public SalvageMapPrototype SalvageMap;
|
||||
}
|
||||
15
Content.Shared/Salvage/SalvageMapPrototype.cs
Normal file
15
Content.Shared/Salvage/SalvageMapPrototype.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Salvage;
|
||||
|
||||
[Prototype]
|
||||
public sealed class SalvageMapPrototype : IPrototype
|
||||
{
|
||||
[ViewVariables] [IdDataField] public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Relative directory path to the given map, i.e. `Maps/Salvage/template.yml`
|
||||
/// </summary>
|
||||
[DataField(required: true)] public ResPath MapPath;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Shared.Salvage;
|
||||
|
||||
public abstract partial class SharedSalvageMagnetComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The machine part that affects the attaching and cooldown times
|
||||
/// </summary>
|
||||
[DataField("machinePartDelay", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>)), ViewVariables(VVAccess.ReadWrite)]
|
||||
public string MachinePartDelay = "Capacitor";
|
||||
|
||||
/// <summary>
|
||||
/// A multiplier applied to the attaching and cooldown times for each level of <see cref="MachinePartDelay"/>
|
||||
/// </summary>
|
||||
[DataField("partRatingDelay"), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float PartRatingDelay = 0.75f;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum SalvageMagnetVisuals : byte
|
||||
{
|
||||
ChargeState,
|
||||
Ready,
|
||||
ReadyBlinking,
|
||||
Unready,
|
||||
UnreadyBlinking
|
||||
}
|
||||
69
Content.Shared/Salvage/SharedSalvageSystem.Magnet.cs
Normal file
69
Content.Shared/Salvage/SharedSalvageSystem.Magnet.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using Content.Shared.Procedural;
|
||||
using Content.Shared.Procedural.PostGeneration;
|
||||
using Content.Shared.Random.Helpers;
|
||||
using Content.Shared.Salvage.Magnet;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Salvage;
|
||||
|
||||
public abstract partial class SharedSalvageSystem
|
||||
{
|
||||
private readonly List<SalvageMapPrototype> _salvageMaps = new();
|
||||
|
||||
private readonly List<ProtoId<DungeonConfigPrototype>> _asteroidConfigs = new()
|
||||
{
|
||||
"BlobAsteroid",
|
||||
"ClusterAsteroid",
|
||||
"SpindlyAsteroid",
|
||||
"SwissCheeseAsteroid"
|
||||
};
|
||||
|
||||
public ISalvageMagnetOffering GetSalvageOffering(int seed)
|
||||
{
|
||||
var rand = new System.Random(seed);
|
||||
|
||||
// Asteroid seed
|
||||
if (seed % 2 == 0)
|
||||
{
|
||||
var config = _asteroidConfigs[rand.Next(_asteroidConfigs.Count)];
|
||||
var layerRand = new System.Random(seed);
|
||||
var configProto = _proto.Index(config);
|
||||
var layers = new Dictionary<string, int>();
|
||||
|
||||
// If we ever add more random layers will need to Next on these.
|
||||
foreach (var layer in configProto.PostGeneration)
|
||||
{
|
||||
switch (layer)
|
||||
{
|
||||
case BiomeMarkerLayerPostGen marker:
|
||||
for (var i = 0; i < marker.Count; i++)
|
||||
{
|
||||
var proto = _proto.Index(marker.MarkerTemplate).Pick(layerRand);
|
||||
var layerCount = layers.GetOrNew(proto);
|
||||
layerCount++;
|
||||
layers[proto] = layerCount;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return new AsteroidOffering
|
||||
{
|
||||
DungeonConfig = configProto,
|
||||
MarkerLayers = layers,
|
||||
};
|
||||
}
|
||||
|
||||
// Salvage map seed
|
||||
_salvageMaps.Clear();
|
||||
_salvageMaps.AddRange(_proto.EnumeratePrototypes<SalvageMapPrototype>());
|
||||
var mapIndex = rand.Next(_salvageMaps.Count);
|
||||
var map = _salvageMaps[mapIndex];
|
||||
|
||||
return new SalvageOffering()
|
||||
{
|
||||
SalvageMap = map,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Salvage;
|
||||
|
||||
public abstract class SharedSalvageSystem : EntitySystem
|
||||
public abstract partial class SharedSalvageSystem : EntitySystem
|
||||
{
|
||||
[Dependency] protected readonly IConfigurationManager CfgManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
Reference in New Issue
Block a user