New event: Approaching unknown shuttle (#24490)
* setup codebase * Add first shuttle * tak * sync striker * sync 2 * pipipi * Preloaded roundstart shuttles! * Make it abstract "PreloaderGrid" not "PreloaderShuttle" * to do * added china cuisin shuttle * fixes * add disaster evacpod * remove enemy * final shuttles * weight 5 -> 10 * move data to component * remove autotrailer touching * doc, respath * fix frozen positioning * fixes + cvar * finally * fix evacpod * remove blacklistrules * remove `UnknownShuttleSpawnRule`, refactor `LoadMapRule` to support preloaded grids * use tryload * cleanup * fixes * use preloadedgrid for loneops * weight unknown shuttles differently (preliminal) * leftover * cleanup and raffling * partial review * singleton gridpreloader no station coupling * fix grid atmoses * `roleLoadout` support for `LoadoutComponent`, fix missing gear * weighting changes * init logic fix --------- Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -1375,6 +1375,12 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<bool> GridFill =
|
||||
CVarDef.Create("shuttle.grid_fill", true, CVar.SERVERONLY);
|
||||
|
||||
/// <summary>
|
||||
/// Whether to automatically preloading grids by GridPreloaderSystem
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> PreloadGrids =
|
||||
CVarDef.Create("shuttle.preload_grids", true, CVar.SERVERONLY);
|
||||
|
||||
/*
|
||||
* Emergency
|
||||
*/
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Shared.Preferences.Loadouts;
|
||||
using Content.Shared.Roles;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Clothing.Components;
|
||||
|
||||
@@ -10,7 +11,20 @@ public sealed partial class LoadoutComponent : Component
|
||||
/// <summary>
|
||||
/// A list of starting gears, of which one will be given.
|
||||
/// All elements are weighted the same in the list.
|
||||
///
|
||||
/// If not specified, <see cref="RoleLoadout"/> will be used instead.
|
||||
/// </summary>
|
||||
[DataField("prototypes", required: true, customTypeSerializer: typeof(PrototypeIdListSerializer<StartingGearPrototype>)), AutoNetworkedField]
|
||||
public List<string>? Prototypes;
|
||||
[DataField("prototypes")]
|
||||
[AutoNetworkedField]
|
||||
public List<ProtoId<StartingGearPrototype>>? StartingGear;
|
||||
|
||||
/// <summary>
|
||||
/// A list of role loadouts, of which one will be given.
|
||||
/// All elements are weighted the same in the list.
|
||||
///
|
||||
/// If not specified, <see cref="StartingGear"/> will be used instead.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
[AutoNetworkedField]
|
||||
public List<ProtoId<RoleLoadoutPrototype>>? RoleLoadout;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ using Robust.Shared.Random;
|
||||
namespace Content.Shared.Clothing;
|
||||
|
||||
/// <summary>
|
||||
/// Assigns a loadout to an entity based on the startingGear prototype
|
||||
/// Assigns a loadout to an entity based on the RoleLoadout prototype
|
||||
/// </summary>
|
||||
public sealed class LoadoutSystem : EntitySystem
|
||||
{
|
||||
@@ -110,10 +110,22 @@ public sealed class LoadoutSystem : EntitySystem
|
||||
|
||||
private void OnMapInit(EntityUid uid, LoadoutComponent component, MapInitEvent args)
|
||||
{
|
||||
if (component.Prototypes == null)
|
||||
// Use starting gear if specified
|
||||
if (component.StartingGear != null)
|
||||
{
|
||||
var gear = _protoMan.Index(_random.Pick(component.StartingGear));
|
||||
_station.EquipStartingGear(uid, gear);
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.RoleLoadout == null)
|
||||
return;
|
||||
|
||||
var proto = _protoMan.Index<StartingGearPrototype>(_random.Pick(component.Prototypes));
|
||||
_station.EquipStartingGear(uid, proto);
|
||||
// ...otherwise equip from role loadout
|
||||
var id = _random.Pick(component.RoleLoadout);
|
||||
var proto = _protoMan.Index(id);
|
||||
var loadout = new RoleLoadout(id);
|
||||
loadout.SetDefault(_protoMan, true);
|
||||
_station.EquipRoleLoadout(uid, loadout, proto);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.GridPreloader.Prototypes;
|
||||
|
||||
/// <summary>
|
||||
/// Creating this prototype will automatically load the grid at the specified path at the beginning of the round,
|
||||
/// and allow the GridPreloader system to load them in the middle of the round. This is needed for optimization,
|
||||
/// because loading grids in the middle of a round causes the server to lag.
|
||||
/// </summary>
|
||||
[Prototype("preloadedGrid")]
|
||||
public sealed partial class PreloadedGridPrototype : IPrototype
|
||||
{
|
||||
[IdDataField] public string ID { get; } = string.Empty;
|
||||
|
||||
[DataField(required: true)]
|
||||
public ResPath Path;
|
||||
|
||||
[DataField]
|
||||
public int Copies = 1;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
namespace Content.Shared.GridPreloader.Systems;
|
||||
public abstract class SharedGridPreloaderSystem : EntitySystem
|
||||
{
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
using System.Linq;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Preferences.Loadouts;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Storage;
|
||||
using Content.Shared.Storage.EntitySystems;
|
||||
@@ -31,6 +33,34 @@ public abstract class SharedStationSpawningSystem : EntitySystem
|
||||
_xformQuery = GetEntityQuery<TransformComponent>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Equips the given starting gears from a `RoleLoadout` onto an entity.
|
||||
/// </summary>
|
||||
public void EquipRoleLoadout(EntityUid entity, RoleLoadout loadout, RoleLoadoutPrototype roleProto)
|
||||
{
|
||||
// Order loadout selections by the order they appear on the prototype.
|
||||
foreach (var group in loadout.SelectedLoadouts.OrderBy(x => roleProto.Groups.FindIndex(e => e == x.Key)))
|
||||
{
|
||||
foreach (var items in group.Value)
|
||||
{
|
||||
if (!PrototypeManager.TryIndex(items.Prototype, out var loadoutProto))
|
||||
{
|
||||
Log.Error($"Unable to find loadout prototype for {items.Prototype}");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!PrototypeManager.TryIndex(loadoutProto.Equipment, out var startingGear))
|
||||
{
|
||||
Log.Error($"Unable to find starting gear {loadoutProto.Equipment} for loadout {loadoutProto}");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle any extra data here.
|
||||
EquipStartingGear(entity, startingGear, raiseEvent: false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="EquipStartingGear(Robust.Shared.GameObjects.EntityUid,System.Nullable{Robust.Shared.Prototypes.ProtoId{Content.Shared.Roles.StartingGearPrototype}},bool)"/>
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user