Add loadout names (#31303)
* Add loadout names Did it for AI, breaking change for pgsql + migrations in general. Nothing atm uses it. * the box * Spawning cherry pick * Fix nit * revert * Final cleanup * Real * Name UI fix * Migrations * a * Review * Re-run migrations --------- Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
This commit is contained in:
@@ -22,6 +22,11 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
||||
[DataField]
|
||||
public Dictionary<ProtoId<LoadoutGroupPrototype>, List<Loadout>> SelectedLoadouts = new();
|
||||
|
||||
/// <summary>
|
||||
/// Loadout specific name.
|
||||
/// </summary>
|
||||
public string? EntityName;
|
||||
|
||||
/*
|
||||
* Loadout-specific data used for validation.
|
||||
*/
|
||||
@@ -42,6 +47,8 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
||||
weh.SelectedLoadouts.Add(selected.Key, new List<Loadout>(selected.Value));
|
||||
}
|
||||
|
||||
weh.EntityName = EntityName;
|
||||
|
||||
return weh;
|
||||
}
|
||||
|
||||
@@ -55,10 +62,34 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
||||
|
||||
if (!protoManager.TryIndex(Role, out var roleProto))
|
||||
{
|
||||
EntityName = null;
|
||||
SelectedLoadouts.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove name not allowed.
|
||||
if (!roleProto.CanCustomizeName)
|
||||
{
|
||||
EntityName = null;
|
||||
}
|
||||
|
||||
// Validate name length
|
||||
// TODO: Probably allow regex to be supplied?
|
||||
if (EntityName != null)
|
||||
{
|
||||
var name = EntityName.Trim();
|
||||
|
||||
if (name.Length > HumanoidCharacterProfile.MaxNameLength)
|
||||
{
|
||||
EntityName = name[..HumanoidCharacterProfile.MaxNameLength];
|
||||
}
|
||||
|
||||
if (name.Length == 0)
|
||||
{
|
||||
EntityName = null;
|
||||
}
|
||||
}
|
||||
|
||||
// In some instances we might not have picked up a new group for existing data.
|
||||
foreach (var groupProto in roleProto.Groups)
|
||||
{
|
||||
@@ -322,7 +353,8 @@ public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
||||
|
||||
if (!Role.Equals(other.Role) ||
|
||||
SelectedLoadouts.Count != other.SelectedLoadouts.Count ||
|
||||
Points != other.Points)
|
||||
Points != other.Points ||
|
||||
EntityName != other.EntityName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user