* Revert "Buff the AME until somebody fixes engineering" (#28419) * Automatic changelog update * hand teleport portals now may start in the same grid. (#28556) * Microwave recipes now uses stacktype id instead of entity prototype id for stacked entities (#28225) * Automatic changelog update * Add "fill level" sprites to mops and damp rag (#28590) * Automatic changelog update * Reword some criminal records text (#28597) * Update criminal-records.ftl * Update criminal-records.ftl * Update criminal-records.ftl * Remove obsolete VisibilitySystem functions (#28610) Remove obsolete visibility functions Co-authored-by: plykiya <plykiya@protonmail.com> * Prayable datafield typo (#28622) * notifiactionPrefix -> notificationPrefix * notifiactionPrefix -> notificationPrefix * Update engine to v224.1.0 (#28624) * Use dummy sessions in NukeOpsTest (#28549) * Add dummy sessions * Update NukeOpsTest * Fix PvsBenchmark * Update engine to v224.1.1 (#28632) * Add Job preference tests (#28625) * Misc Job related changes * Add JobTest * A * Aa * Lets not confuse the yaml linter * fixes * a * Add logs that provide session to player admin logs (#28628) * Cluster Update (#28627) done here * Automatic changelog update * minor banner changes (#28636) * minor banner changes * Uhrmm actchually it's you're, not your * Update banners.yml props Hyenh * Revenant spell catalog locale (#28638) locale * Make cuff default range again (#28576) * Make cuff default range again * uncuff distance * how about ONE --------- Co-authored-by: plykiya <plykiya@protonmail.com> * Automatic changelog update * Machine-code cleanup (#28489) * Make Projectiles Only Hit a Variety of Station Objects Unless Clicked on (#28571) * Automatic changelog update * Fix Smoke-grenade.ogg not being mono (#28593) * Fix Cigars Sprites + YAML fix for Inhand unlit cigars/cigs (#28641) * Automatic changelog update * Clean up Eva and Hardsuit helm yml + Lets atmos firesuit helm work as a BreathMask (#28602) * Shifts borgs hats to the right a bit (#28600) * Fix mouse inhands (#28623) * Adjust some touch reaction damage levels (#28591) * Automatic changelog update * Add closing storage UIs to StorageInteractionTest (#28633) * Update rules (#28452) * Add support for LocalizedDatasets to RandomMetadata (#28601) * Fix Admin Object tab sorting and search (#28609) * Automatic changelog update * Internals are kept on as long as any breathing tool is on (#28595) * Automatic changelog update * Convert rules to use guidebook parsing (#28647) * Gives Insulation and NoSlip to all bots (#28621) * Gives Insulation and NoSlip to all bots * remove NoSlip from children * Automatic changelog update * Nerfs welderbombing (#28650) nerf welderbombing * Automatic changelog update * Give jobs & antags prototypes a guide field (#28614) * Give jobs & antags prototypes a guide field * A * space Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> * Add todo * Fix merge errors --------- Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> * Automatic changelog update * Fix typo in Space Law's restricted gear (#28668) This typo was included in the wiki as well. Reported-by: Bobberson in the Discord * Automatic changelog update * fixed "silicones" typo in new rules (#28671) fixed all appearances of silicone where it should have been silicon * fix janitor not spawning with a survival box (#28669) hi * Automatic changelog update * Fix typo in slime naming conventions (#28682) * Flatpacker fixes (#28417) * Return medicine recipe solid material costs to 1 (#28679) Set material costs of medicine recipes to 1 * Automatic changelog update * Update Core (#28689) add * Fixed the guidebook listing every single rule (#28680) * Well i tried this way * New approach (start) * Did it * makes spacelaw available, put it under sec * Automatic changelog update * rule fixes first pass (#28701) update * Add JobRequirementOverride prototypes (#28607) * Add JobRequirementOverride prototypes * a * invert if * Add override that takes in prototypes directly * Tweak chapel salvage wreck (#28703) add * Fixes client having authority over rules popup cvars (#28655) * Fixes client having authority over rules popup cvars * Delete duplicate migration * Pre-update * Post-update * Add locale support for booze and soda jugs labels (#28708) * Swap some InRangeUnobstructed for InRangeUnoccluded (#28706) Swap InRangeUnobstructed to InRangeUnoccluded Co-authored-by: plykiya <plykiya@protonmail.com> * Automatic changelog update * Ports the singularity's values from vgstation (#28720) * ports the singularity values from vgstation * guidebook fix * 5000 energy level 6 singulo * Fix action icons when dragging an active action to another slot (#28692) * Add DoPopup data field to OnUseTimerTrigger (#28691) * Dropping Corpses Devoured by Space Dragons on Gib/Butcher. (#28709) * Update DevourSystem.cs * Update DevourSystem.cs * Update Content.Server/Devour/DevourSystem.cs --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Automatic changelog update * Improve grammar of various petting messages (#28715) Improve grammar of various petting message * Fix DamageOtherOnHit.OnDoHit when the target is terminating or deleted (#28690) * Update Core (#28735) add * Fix flatpacker (#28736) * Fix flatpacker * a * rn, atp (#28674) * Update speech-chatsan.ftl * Update word_replacements.yml * Atm-at the moment * Atm * Update Resources/Locale/en-US/speech/speech-chatsan.ftl * Update Resources/Prototypes/Accents/word_replacements.yml --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Add loadout group check for role proto (#28731) MFW same bug twice at 2 layers because I'm stupid. * Automatic changelog update * Try fix RGBee (#28741) * Automatic changelog update * Ensure packager creates a release folder (#28426) I was screaming at the github actions runner before i noticed something i had done before caused me to never have a release folder and thus fail. * allow ' in character names (#28652) * Automatic changelog update * Make freeze, freeze & mute, and unmute verbs work on disconnected players. (#28664) * Automatic changelog update * fix singulo decay (#28743) * Automatic changelog update * Don't use invalid defaults for loadouts (#28729) At the time it made more sense but now with species specific stuff it's better to have nothing. * Maybe fix invalid loadout prototypes (#28734) * Maybe fix invalid loadout prototypes So if we have existing data SetDefault is not normally called iirc. So what I think is happening is that if we have old loadout groups that get saved to DB and loaded these get dropped entirely and nothing is used to replace the group unless the person specifically looks at their loadout. Need someone affected to send me their loadout to confirm it's fixed. * Better fix * Automatic changelog update * Fix null ref exception in PrayerSystem (#28712) * Fix null ref exception in PrayerSystem * Also check that prayable ent/comp still exist * Guidebook Updates for the Amateur Spessman (#28603) * Created NewPlayer.xml * Created NewPlayer.yml and added it to guides.ftl * shifted some controls from Space Station 14 to New? Start here!, as well as made a character creation xml to be written later * switched some stuff between the New? entry and the Space Station 14 entry * Made everything so nice!!!!!!!!!!!!!! * fixed formatting inconsistencies * added a How to use this guidebook section * build correction and guidebook clarification for other servers * wrote character creation ig probs fo shizzle * added new terms to the glossary and alphabetized it * meh this seems important enough to add * okay no more shitsec bad idea * I HATED Roleplaying.xml ANYWAY!!! * I REALLY REALLY HATED IT ACTUALLYLLL * Moved Controls and Radio into newplayer.yml, making meta.yml and radio.yml obsolete * Separated the character creation bits that are just cosmetic from the ones that matter * also put all the related new player xml files in their own folder * expanded Radio.xml, kinda fixed survival.xml * removed the line that mighta maybe sorta possibly could encourage self antag * thought about this randomly but ICK OCK * talking is no longer a key part of this game * moves stuff around, a lot of stuff. basically moves everything but the jobs themselves around * ah probably should make sure this works first also me when i lie on the internet * don't be such a grammar nukie Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * okay nevermind that's justified Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * prepare. it is coming. the great reorganization... * yesyes that's all well and goo- THE REORG IS COMING. THE REORG IS COMING. WAKE UP. * rename that real quick * step one begins. first, consolidate existing service entries into their own yaml. this makes botany.yml obsolete. * update shiftandcrew.yml to only have departments as children also fuck it alphabetization * consolidated salvage into cargo * made a new entry for command * gave salvage a home and service an existence * made some XML files to be filled out later * quick rename... * took some stuff from Intro.txt and i think Gameplay.txt and put it in NewPlayer.xml * The Great Writing about Departments (25XX, black and white) * added a bunch of links everywhere * biochemical is no longer a thing * service formatinaaaaaaa * shiny...,,,,,,,,, colo(u)rz..,,,,,,,,,,,,, * let's get that fixed * second time i made a typo there as well * we hate fun around here * grammar?!???/ * various fixes and more linkings * oops * wewlad lol!! --------- Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: AJCM <AJCM@tutanota.com> * Automatic changelog update * Add suffixes to excap survival boxes (#28755) Update emergency.yml * Add Jani lobby background (#28724) * Add jani lobby background * Actually make new lobby screen functional * Fix license * Automatic changelog update * Strip markdown from silicon laws before saying them (#28596) * saltern update (#28773) Co-authored-by: deltanedas <@deltanedas:kde.org> * revert Tornado regex * Update HumanoidCharacterProfile.cs * Update arenas.yml * test * fix locale * Update options-menu.ftl * Update species-names.ftl * Update debug.yml * aaaaaa --------- Co-authored-by: Moony <moony@hellomouse.net> Co-authored-by: PJBot <pieterjan.briers+bot@gmail.com> Co-authored-by: icekot8 <93311212+icekot8@users.noreply.github.com> Co-authored-by: blueDev2 <89804215+blueDev2@users.noreply.github.com> Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: TsjipTsjip <19798667+TsjipTsjip@users.noreply.github.com> Co-authored-by: Plykiya <58439124+Plykiya@users.noreply.github.com> Co-authored-by: plykiya <plykiya@protonmail.com> Co-authored-by: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Co-authored-by: Boaz1111 <149967078+Boaz1111@users.noreply.github.com> Co-authored-by: Hmeister-real <118129069+Hmeister-real@users.noreply.github.com> Co-authored-by: lapatison <100279397+lapatison@users.noreply.github.com> Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Co-authored-by: Cojoke <83733158+Cojoke-dot@users.noreply.github.com> Co-authored-by: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Co-authored-by: Ps3Moira <113228053+ps3moira@users.noreply.github.com> Co-authored-by: Verm <32827189+Vermidia@users.noreply.github.com> Co-authored-by: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Co-authored-by: Repo <47093363+Titian3@users.noreply.github.com> Co-authored-by: Flareguy <78941145+Flareguy@users.noreply.github.com> Co-authored-by: Thomas <87614336+Aeshus@users.noreply.github.com> Co-authored-by: Moomoobeef <62638182+Moomoobeef@users.noreply.github.com> Co-authored-by: Mr. 27 <45323883+Dutch-VanDerLinde@users.noreply.github.com> Co-authored-by: Ubaser <134914314+UbaserB@users.noreply.github.com> Co-authored-by: AJCM-git <60196617+AJCM-git@users.noreply.github.com> Co-authored-by: lzk <124214523+lzk228@users.noreply.github.com> Co-authored-by: Lyndomen <49795619+Lyndomen@users.noreply.github.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: MerrytheManokit <167581110+MerrytheManokit@users.noreply.github.com> Co-authored-by: Vasilis <vasilis@pikachu.systems> Co-authored-by: Whisper <121047731+QuietlyWhisper@users.noreply.github.com> Co-authored-by: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Co-authored-by: UBlueberry <161545003+UBlueberry@users.noreply.github.com> Co-authored-by: AJCM <AJCM@tutanota.com> Co-authored-by: Psychpsyo <60073468+Psychpsyo@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com>
311 lines
9.3 KiB
C#
311 lines
9.3 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Linq;
|
|
using Content.Shared.Humanoid.Prototypes;
|
|
using Content.Shared.Random;
|
|
using Robust.Shared.Collections;
|
|
using Robust.Shared.Player;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Shared.Preferences.Loadouts;
|
|
|
|
/// <summary>
|
|
/// Contains all of the selected data for a role's loadout.
|
|
/// </summary>
|
|
[Serializable, NetSerializable, DataDefinition]
|
|
public sealed partial class RoleLoadout : IEquatable<RoleLoadout>
|
|
{
|
|
[DataField]
|
|
public ProtoId<RoleLoadoutPrototype> Role;
|
|
|
|
[DataField]
|
|
public Dictionary<ProtoId<LoadoutGroupPrototype>, List<Loadout>> SelectedLoadouts = new();
|
|
|
|
/*
|
|
* Loadout-specific data used for validation.
|
|
*/
|
|
|
|
public int? Points;
|
|
|
|
public RoleLoadout(ProtoId<RoleLoadoutPrototype> role)
|
|
{
|
|
Role = role;
|
|
}
|
|
|
|
public RoleLoadout Clone()
|
|
{
|
|
var weh = new RoleLoadout(Role);
|
|
|
|
foreach (var selected in SelectedLoadouts)
|
|
{
|
|
weh.SelectedLoadouts.Add(selected.Key, new List<Loadout>(selected.Value));
|
|
}
|
|
|
|
return weh;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Ensures all prototypes exist and effects can be applied.
|
|
/// </summary>
|
|
public void EnsureValid(HumanoidCharacterProfile profile, ICommonSession session, IDependencyCollection collection)
|
|
{
|
|
var groupRemove = new ValueList<string>();
|
|
var protoManager = collection.Resolve<IPrototypeManager>();
|
|
|
|
if (!protoManager.TryIndex(Role, out var roleProto))
|
|
{
|
|
SelectedLoadouts.Clear();
|
|
return;
|
|
}
|
|
|
|
// In some instances we might not have picked up a new group for existing data.
|
|
foreach (var groupProto in roleProto.Groups)
|
|
{
|
|
if (SelectedLoadouts.ContainsKey(groupProto))
|
|
continue;
|
|
|
|
// Data will get set below.
|
|
SelectedLoadouts[groupProto] = new List<Loadout>();
|
|
}
|
|
|
|
// Reset points to recalculate.
|
|
Points = roleProto.Points;
|
|
|
|
foreach (var (group, groupLoadouts) in SelectedLoadouts)
|
|
{
|
|
// Check the group is even valid for this role.
|
|
if (!roleProto.Groups.Contains(group))
|
|
{
|
|
groupRemove.Add(group);
|
|
continue;
|
|
}
|
|
|
|
// Dump if Group doesn't exist
|
|
if (!protoManager.TryIndex(group, out var groupProto))
|
|
{
|
|
groupRemove.Add(group);
|
|
continue;
|
|
}
|
|
|
|
var loadouts = groupLoadouts[..Math.Min(groupLoadouts.Count, groupProto.MaxLimit)];
|
|
|
|
// Validate first
|
|
for (var i = loadouts.Count - 1; i >= 0; i--)
|
|
{
|
|
var loadout = loadouts[i];
|
|
|
|
// Old prototype or otherwise invalid.
|
|
if (!protoManager.TryIndex(loadout.Prototype, out var loadoutProto))
|
|
{
|
|
loadouts.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
// Malicious client maybe, check the group even has it.
|
|
if (!groupProto.Loadouts.Contains(loadout.Prototype))
|
|
{
|
|
loadouts.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
// Validate the loadout can be applied (e.g. points).
|
|
if (!IsValid(profile, session, loadout.Prototype, collection, out _))
|
|
{
|
|
loadouts.RemoveAt(i);
|
|
continue;
|
|
}
|
|
|
|
Apply(loadoutProto);
|
|
}
|
|
|
|
// Apply defaults if required
|
|
// Technically it's possible for someone to game themselves into loadouts they shouldn't have
|
|
// If you put invalid ones first but that's your fault for not using sensible defaults
|
|
if (loadouts.Count < groupProto.MinLimit)
|
|
{
|
|
for (var i = 0; i < Math.Min(groupProto.MinLimit, groupProto.Loadouts.Count); i++)
|
|
{
|
|
if (!protoManager.TryIndex(groupProto.Loadouts[i], out var loadoutProto))
|
|
continue;
|
|
|
|
var defaultLoadout = new Loadout()
|
|
{
|
|
Prototype = loadoutProto.ID,
|
|
};
|
|
|
|
if (loadouts.Contains(defaultLoadout))
|
|
continue;
|
|
|
|
// Not valid so don't default to it anyway.
|
|
if (!IsValid(profile, session, defaultLoadout.Prototype, collection, out _))
|
|
continue;
|
|
|
|
loadouts.Add(defaultLoadout);
|
|
Apply(loadoutProto);
|
|
}
|
|
}
|
|
|
|
SelectedLoadouts[group] = loadouts;
|
|
}
|
|
|
|
foreach (var value in groupRemove)
|
|
{
|
|
SelectedLoadouts.Remove(value);
|
|
}
|
|
}
|
|
|
|
private void Apply(LoadoutPrototype loadoutProto)
|
|
{
|
|
foreach (var effect in loadoutProto.Effects)
|
|
{
|
|
effect.Apply(this);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets the selected loadouts to default if no data is present.
|
|
/// </summary>
|
|
/// <param name="force">Clear existing data first</param>
|
|
public void SetDefault(IPrototypeManager protoManager, bool force = false)
|
|
{
|
|
if (force)
|
|
SelectedLoadouts.Clear();
|
|
|
|
var roleProto = protoManager.Index(Role);
|
|
|
|
for (var i = roleProto.Groups.Count - 1; i >= 0; i--)
|
|
{
|
|
var group = roleProto.Groups[i];
|
|
|
|
if (!protoManager.TryIndex(group, out var groupProto))
|
|
continue;
|
|
|
|
if (SelectedLoadouts.ContainsKey(group))
|
|
continue;
|
|
|
|
SelectedLoadouts[group] = new List<Loadout>();
|
|
|
|
if (groupProto.MinLimit > 0)
|
|
{
|
|
// Apply any loadouts we can.
|
|
for (var j = 0; j < Math.Min(groupProto.MinLimit, groupProto.Loadouts.Count); j++)
|
|
{
|
|
AddLoadout(group, groupProto.Loadouts[j], protoManager);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns whether a loadout is valid or not.
|
|
/// </summary>
|
|
public bool IsValid(HumanoidCharacterProfile profile, ICommonSession session, ProtoId<LoadoutPrototype> loadout, IDependencyCollection collection, [NotNullWhen(false)] out FormattedMessage? reason)
|
|
{
|
|
reason = null;
|
|
|
|
var protoManager = collection.Resolve<IPrototypeManager>();
|
|
|
|
if (!protoManager.TryIndex(loadout, out var loadoutProto))
|
|
{
|
|
// Uhh
|
|
reason = FormattedMessage.FromMarkup("");
|
|
return false;
|
|
}
|
|
|
|
if (!protoManager.HasIndex(Role))
|
|
{
|
|
reason = FormattedMessage.FromUnformatted("loadouts-prototype-missing");
|
|
return false;
|
|
}
|
|
|
|
var valid = true;
|
|
|
|
foreach (var effect in loadoutProto.Effects)
|
|
{
|
|
valid = valid && effect.Validate(profile, this, session, collection, out reason);
|
|
}
|
|
|
|
return valid;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Applies the specified loadout to this group.
|
|
/// </summary>
|
|
public bool AddLoadout(ProtoId<LoadoutGroupPrototype> selectedGroup, ProtoId<LoadoutPrototype> selectedLoadout, IPrototypeManager protoManager)
|
|
{
|
|
var groupLoadouts = SelectedLoadouts[selectedGroup];
|
|
|
|
// Need to unselect existing ones if we're at or above limit
|
|
var limit = Math.Max(0, groupLoadouts.Count + 1 - protoManager.Index(selectedGroup).MaxLimit);
|
|
|
|
for (var i = 0; i < groupLoadouts.Count; i++)
|
|
{
|
|
var loadout = groupLoadouts[i];
|
|
|
|
if (loadout.Prototype != selectedLoadout)
|
|
{
|
|
// Remove any other loadouts that might push it above the limit.
|
|
if (limit > 0)
|
|
{
|
|
limit--;
|
|
groupLoadouts.RemoveAt(i);
|
|
i--;
|
|
}
|
|
|
|
continue;
|
|
}
|
|
|
|
DebugTools.Assert(false);
|
|
return false;
|
|
}
|
|
|
|
groupLoadouts.Add(new Loadout()
|
|
{
|
|
Prototype = selectedLoadout,
|
|
});
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Removed the specified loadout from this group.
|
|
/// </summary>
|
|
public bool RemoveLoadout(ProtoId<LoadoutGroupPrototype> selectedGroup, ProtoId<LoadoutPrototype> selectedLoadout, IPrototypeManager protoManager)
|
|
{
|
|
// Although this may bring us below minimum we'll let EnsureValid handle it.
|
|
|
|
var groupLoadouts = SelectedLoadouts[selectedGroup];
|
|
|
|
for (var i = 0; i < groupLoadouts.Count; i++)
|
|
{
|
|
var loadout = groupLoadouts[i];
|
|
|
|
if (loadout.Prototype != selectedLoadout)
|
|
continue;
|
|
|
|
groupLoadouts.RemoveAt(i);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool Equals(RoleLoadout? other)
|
|
{
|
|
if (ReferenceEquals(null, other)) return false;
|
|
if (ReferenceEquals(this, other)) return true;
|
|
return Role.Equals(other.Role) && SelectedLoadouts.SequenceEqual(other.SelectedLoadouts) && Points == other.Points;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return ReferenceEquals(this, obj) || obj is RoleLoadout other && Equals(other);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return HashCode.Combine(Role, SelectedLoadouts, Points);
|
|
}
|
|
}
|