Flipped caps real (#24961)

* Flipped caps real

* oops

* whoops

* flip not fold

* fix formatting

* cargosoft formatting
This commit is contained in:
themias
2024-02-10 03:44:19 -05:00
committed by GitHub
parent b07e8abedb
commit f7a3ea6dcf
100 changed files with 389 additions and 529 deletions

View File

@@ -17,4 +17,17 @@ public sealed partial class FoldableClothingComponent : Component
/// </summary>
[DataField]
public SlotFlags? UnfoldedSlots;
/// <summary>
/// What equipped prefix does this have while in folded form?
/// </summary>
[DataField]
public string? FoldedEquippedPrefix;
/// <summary>
/// What held prefix does this have while in folded form?
/// </summary>
[DataField]
public string? FoldedHeldPrefix;
}

View File

@@ -1,6 +1,7 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Foldable;
using Content.Shared.Inventory;
using Content.Shared.Item;
namespace Content.Shared.Clothing.EntitySystems;
@@ -8,6 +9,7 @@ public sealed class FoldableClothingSystem : EntitySystem
{
[Dependency] private readonly ClothingSystem _clothingSystem = default!;
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
public override void Initialize()
{
@@ -31,12 +33,32 @@ public sealed class FoldableClothingSystem : EntitySystem
private void OnFolded(Entity<FoldableClothingComponent> ent, ref FoldedEvent args)
{
if (TryComp<ClothingComponent>(ent.Owner, out var clothingComp))
if (TryComp<ClothingComponent>(ent.Owner, out var clothingComp) &&
TryComp<ItemComponent>(ent.Owner, out var itemComp))
{
if (args.IsFolded && ent.Comp.FoldedSlots.HasValue)
_clothingSystem.SetSlots(ent.Owner, ent.Comp.FoldedSlots.Value, clothingComp);
else if (!args.IsFolded && ent.Comp.UnfoldedSlots.HasValue)
_clothingSystem.SetSlots(ent.Owner, ent.Comp.UnfoldedSlots.Value, clothingComp);
if (args.IsFolded)
{
if (ent.Comp.FoldedSlots.HasValue)
_clothingSystem.SetSlots(ent.Owner, ent.Comp.FoldedSlots.Value, clothingComp);
if (ent.Comp.FoldedEquippedPrefix != null)
_clothingSystem.SetEquippedPrefix(ent.Owner, ent.Comp.FoldedEquippedPrefix, clothingComp);
if (ent.Comp.FoldedHeldPrefix != null)
_itemSystem.SetHeldPrefix(ent.Owner, ent.Comp.FoldedHeldPrefix, false, itemComp);
}
else
{
if (ent.Comp.UnfoldedSlots.HasValue)
_clothingSystem.SetSlots(ent.Owner, ent.Comp.UnfoldedSlots.Value, clothingComp);
if (ent.Comp.FoldedEquippedPrefix != null)
_clothingSystem.SetEquippedPrefix(ent.Owner, null, clothingComp);
if (ent.Comp.FoldedHeldPrefix != null)
_itemSystem.SetHeldPrefix(ent.Owner, null, false, itemComp);
}
}
}
}

View File

@@ -17,4 +17,10 @@ public sealed partial class FoldableComponent : Component
[DataField]
public bool CanFoldInsideContainer = false;
[DataField]
public LocId UnfoldVerbText = "unfold-verb";
[DataField]
public LocId FoldVerbText = "fold-verb";
}

View File

@@ -134,7 +134,7 @@ public sealed class FoldableSystem : EntitySystem
AlternativeVerb verb = new()
{
Act = () => TryToggleFold(uid, component),
Text = component.IsFolded ? Loc.GetString("unfold-verb") : Loc.GetString("fold-verb"),
Text = component.IsFolded ? Loc.GetString(component.UnfoldVerbText) : Loc.GetString(component.FoldVerbText),
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/fold.svg.192dpi.png")),
// If the object is unfolded and they click it, they want to fold it, if it's folded, they want to pick it up