Chameleon clothes + EMP behaviour (#30924)
* resolving conflicts?? * Controlled clothes changing + time stuff + EmpChangeIntensity * Single clothes change + EmpContinious + moved random pick logic into GetRandomValidPrototype * Changes from reviews Co-Authored-By: Nemanja <98561806+emogarbage404@users.noreply.github.com> * Update ChameleonClothingComponent.cs * repairing irreparable damage i failed, did i? * damaging repaired irreparable uh??? * 2025 FUN ALLOWED!!!! * Minor changes from reviews Co-Authored-By: beck-thompson <107373427+beck-thompson@users.noreply.github.com> * Fix merge conflicts * Fix that last bug * cleanup * Remove VV attr. * AutoPausedField on emp time change --------- Co-authored-by: Nemanja <98561806+emogarbage404@users.noreply.github.com> Co-authored-by: beck-thompson <107373427+beck-thompson@users.noreply.github.com> Co-authored-by: beck-thompson <beck314159@hotmail.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com>
This commit is contained in:
@@ -13,16 +13,6 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _proto = default!;
|
||||
|
||||
private static readonly SlotFlags[] IgnoredSlots =
|
||||
{
|
||||
SlotFlags.All,
|
||||
SlotFlags.PREVENTEQUIP,
|
||||
SlotFlags.NONE
|
||||
};
|
||||
private static readonly SlotFlags[] Slots = Enum.GetValues<SlotFlags>().Except(IgnoredSlots).ToArray();
|
||||
|
||||
private readonly Dictionary<SlotFlags, List<string>> _data = new();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -61,49 +51,4 @@ public sealed class ChameleonClothingSystem : SharedChameleonClothingSystem
|
||||
borderColor.AccentVColor = otherBorderColor.AccentVColor;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of valid chameleon targets for these slots.
|
||||
/// </summary>
|
||||
public IEnumerable<string> GetValidTargets(SlotFlags slot)
|
||||
{
|
||||
var set = new HashSet<string>();
|
||||
foreach (var availableSlot in _data.Keys)
|
||||
{
|
||||
if (slot.HasFlag(availableSlot))
|
||||
{
|
||||
set.UnionWith(_data[availableSlot]);
|
||||
}
|
||||
}
|
||||
return set;
|
||||
}
|
||||
|
||||
private void PrepareAllVariants()
|
||||
{
|
||||
_data.Clear();
|
||||
var prototypes = _proto.EnumeratePrototypes<EntityPrototype>();
|
||||
|
||||
foreach (var proto in prototypes)
|
||||
{
|
||||
// check if this is valid clothing
|
||||
if (!IsValidTarget(proto))
|
||||
continue;
|
||||
if (!proto.TryGetComponent(out ClothingComponent? item, Factory))
|
||||
continue;
|
||||
|
||||
// sort item by their slot flags
|
||||
// one item can be placed in several buckets
|
||||
foreach (var slot in Slots)
|
||||
{
|
||||
if (!item.Slots.HasFlag(slot))
|
||||
continue;
|
||||
|
||||
if (!_data.ContainsKey(slot))
|
||||
{
|
||||
_data.Add(slot, new List<string>());
|
||||
}
|
||||
_data[slot].Add(proto.ID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public sealed class ChameleonBoundUserInterface : BoundUserInterface
|
||||
var targets = _chameleon.GetValidTargets(st.Slot);
|
||||
if (st.RequiredTag != null)
|
||||
{
|
||||
var newTargets = new List<string>();
|
||||
var newTargets = new List<EntProtoId>();
|
||||
foreach (var target in targets)
|
||||
{
|
||||
if (string.IsNullOrEmpty(target) || !_proto.TryIndex(target, out EntityPrototype? proto))
|
||||
|
||||
@@ -19,8 +19,8 @@ public sealed partial class ChameleonMenu : DefaultWindow
|
||||
private readonly SpriteSystem _sprite;
|
||||
public event Action<string>? OnIdSelected;
|
||||
|
||||
private IEnumerable<string> _possibleIds = Enumerable.Empty<string>();
|
||||
private string? _selectedId;
|
||||
private IEnumerable<EntProtoId> _possibleIds = [];
|
||||
private EntProtoId? _selectedId;
|
||||
private string _searchFilter = "";
|
||||
|
||||
public ChameleonMenu()
|
||||
@@ -32,7 +32,7 @@ public sealed partial class ChameleonMenu : DefaultWindow
|
||||
Search.OnTextChanged += OnSearchEntered;
|
||||
}
|
||||
|
||||
public void UpdateState(IEnumerable<string> possibleIds, string? selectedId)
|
||||
public void UpdateState(IEnumerable<EntProtoId> possibleIds, string? selectedId)
|
||||
{
|
||||
_possibleIds = possibleIds;
|
||||
_selectedId = selectedId;
|
||||
@@ -57,7 +57,7 @@ public sealed partial class ChameleonMenu : DefaultWindow
|
||||
if (!_prototypeManager.TryIndex(id, out EntityPrototype? proto))
|
||||
continue;
|
||||
|
||||
var lowId = id.ToLowerInvariant();
|
||||
var lowId = id.Id.ToLowerInvariant();
|
||||
var lowName = proto.Name.ToLowerInvariant();
|
||||
if (!lowId.Contains(searchFilterLow) && !lowName.Contains(_searchFilter))
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user