mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
Various Bugfixes (Mostly Traits System) (#2154)
# Description  Mfw a downstream fixes things only for themselves, leaving me to hear hundreds of complaints constantly about bugs that I don't have the time or manpower to fix upstream. # Changelog 🆑 - fix: Fixed an issue that prevented players from saving item customizations if they didn't have enough loadout points to buy the item a second time. - add: Traits can now define the order in which they are applied. - fix: Fixed RGBee pushie not working. (cherry picked from commit bf3a0ec705acb9781ca5f5c2d200857b6a964a07)
This commit is contained in:
@@ -207,8 +207,11 @@ namespace Content.Client.Light
|
||||
|
||||
public static Color GetCurrentRgbColor(TimeSpan curTime, TimeSpan offset, Entity<RgbLightControllerComponent> rgb)
|
||||
{
|
||||
var delta = (float)(curTime - offset).TotalSeconds;
|
||||
var entOffset = Math.Abs(rgb.Owner.Id * 0.09817f);
|
||||
var hue = (delta * rgb.Comp.CycleRate + entOffset) % 1;
|
||||
return Color.FromHsv(new Vector4(
|
||||
(float) (((curTime.TotalSeconds - offset.TotalSeconds) * rgb.Comp.CycleRate + Math.Abs(rgb.Owner.Id * 0.1)) % 1),
|
||||
MathF.Abs(hue),
|
||||
1.0f,
|
||||
1.0f,
|
||||
1.0f
|
||||
|
||||
@@ -2760,9 +2760,10 @@ namespace Content.Client.Lobby.UI
|
||||
selector.PreferenceChanged += preference =>
|
||||
{
|
||||
// Make sure they have enough loadout points
|
||||
var selected = preference.Selected
|
||||
? CheckPoints(-selector.Loadout.Cost, preference.Selected)
|
||||
: CheckPoints(selector.Loadout.Cost, preference.Selected);
|
||||
var wasSelected = Profile?.LoadoutPreferences
|
||||
.FirstOrDefault(it => it.LoadoutName == selector.Loadout.ID)
|
||||
?.Selected ?? false;
|
||||
var selected = preference.Selected && (wasSelected || CheckPoints(-selector.Loadout.Cost, true));
|
||||
|
||||
// Update Preferences
|
||||
Profile = Profile?.WithLoadoutPreference(
|
||||
@@ -2781,7 +2782,7 @@ namespace Content.Client.Lobby.UI
|
||||
bool CheckPoints(int points, bool preference)
|
||||
{
|
||||
var temp = LoadoutPointsBar.Value + points;
|
||||
return preference ? !(temp < 0) : temp < 0;
|
||||
return preference ? temp >= 0 : temp < 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,11 +207,17 @@ public sealed partial class LoadoutPreferenceSelector : Control
|
||||
});
|
||||
PreferenceButton.OnToggled += args =>
|
||||
{
|
||||
if (args.Pressed == _preference.Selected)
|
||||
return;
|
||||
|
||||
_preference.Selected = args.Pressed;
|
||||
PreferenceChanged?.Invoke(Preference);
|
||||
};
|
||||
HeirloomButton.OnToggled += args =>
|
||||
{
|
||||
if (args.Pressed == _preference.Selected)
|
||||
return;
|
||||
|
||||
_preference.CustomHeirloom = args.Pressed ? true : null;
|
||||
PreferenceChanged?.Invoke(Preference);
|
||||
};
|
||||
|
||||
@@ -63,15 +63,25 @@ public sealed class TraitSystem : EntitySystem
|
||||
return;
|
||||
|
||||
var jobPrototypeToUse = _prototype.Index(jobId ?? _prototype.EnumeratePrototypes<JobPrototype>().First().ID);
|
||||
var sortedTraits = new List<TraitPrototype>();
|
||||
|
||||
foreach (var traitId in profile.TraitPreferences)
|
||||
{
|
||||
if (!_prototype.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
|
||||
if (_prototype.TryIndex<TraitPrototype>(traitId, out var traitPrototype))
|
||||
{
|
||||
sortedTraits.Add(traitPrototype);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugTools.Assert($"No trait found with ID {traitId}!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
sortedTraits.Sort();
|
||||
|
||||
foreach (var traitPrototype in sortedTraits)
|
||||
{
|
||||
if (!traitPrototype.Enable || // WD EDIT
|
||||
!_characterRequirements.CheckRequirementsValid(
|
||||
traitPrototype.Requirements,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using Content.Shared.Customization.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Traits;
|
||||
|
||||
@@ -10,7 +9,7 @@ namespace Content.Shared.Traits;
|
||||
/// Describes a trait.
|
||||
/// </summary>
|
||||
[Prototype("trait")]
|
||||
public sealed partial class TraitPrototype : IPrototype
|
||||
public sealed partial class TraitPrototype : IPrototype, IComparable
|
||||
{
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
@@ -35,6 +34,19 @@ public sealed partial class TraitPrototype : IPrototype
|
||||
[DataField(serverOnly: true)]
|
||||
public TraitFunction[] Functions { get; private set; } = Array.Empty<TraitFunction>();
|
||||
|
||||
/// <summary>
|
||||
/// Should this trait be loaded earlier/later than other traits?
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int Priority = 0;
|
||||
public int CompareTo(object? obj) // Compare function to allow for some traits to specify they need to load earlier than others
|
||||
{
|
||||
if (obj is not TraitPrototype other)
|
||||
return -1;
|
||||
|
||||
return Priority.CompareTo(other.Priority); // No need for total ordering, only care about things that want to be loaded earlier or later.
|
||||
}
|
||||
|
||||
// WD EDIT START
|
||||
[DataField]
|
||||
public bool Enable = true;
|
||||
|
||||
Reference in New Issue
Block a user