diff --git a/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs b/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs
deleted file mode 100644
index 17f7d88875..0000000000
--- a/Content.Client/Revenant/Ui/RevenantBoundUserInterface.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using Content.Shared.Revenant;
-using JetBrains.Annotations;
-using Robust.Client.GameObjects;
-
-namespace Content.Client.Revenant.Ui;
-
-[UsedImplicitly]
-public sealed class RevenantBoundUserInterface : BoundUserInterface
-{
- private RevenantMenu? _menu;
-
- public RevenantBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
- {
-
- }
-
- protected override void Open()
- {
- _menu = new();
- _menu.OpenCentered();
- _menu.OnClose += Close;
-
- _menu.OnListingButtonPressed += (_, listing) =>
- {
- SendMessage(new RevenantBuyListingMessage(listing));
- };
- }
-
- protected override void UpdateState(BoundUserInterfaceState state)
- {
- base.UpdateState(state);
-
- if (_menu == null)
- return;
-
- switch (state)
- {
- case RevenantUpdateState msg:
- _menu.UpdateEssence(msg.Essence);
- _menu.UpdateListing(msg.Listings);
- break;
- }
- }
-
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- if (!disposing)
- return;
-
- _menu?.Close();
- _menu?.Dispose();
- }
-}
diff --git a/Content.Client/Revenant/Ui/RevenantListingControl.xaml b/Content.Client/Revenant/Ui/RevenantListingControl.xaml
deleted file mode 100644
index 6adcfdc896..0000000000
--- a/Content.Client/Revenant/Ui/RevenantListingControl.xaml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Content.Client/Revenant/Ui/RevenantListingControl.xaml.cs b/Content.Client/Revenant/Ui/RevenantListingControl.xaml.cs
deleted file mode 100644
index 5f40621b93..0000000000
--- a/Content.Client/Revenant/Ui/RevenantListingControl.xaml.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using Robust.Client.AutoGenerated;
-using Robust.Client.Graphics;
-using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
-using Robust.Client.UserInterface.XAML;
-using Robust.Shared.Maths;
-
-namespace Content.Client.Revenant.Ui;
-
-[GenerateTypedNameReferences]
-public sealed partial class RevenantListingControl : Control
-{
- public RevenantListingControl(string itemName, string itemDescription,
- int itemPrice, bool canBuy, Texture? texture = null)
- {
- RobustXamlLoader.Load(this);
-
- RevenantItemName.Text = itemName;
- RevenantItemDescription.SetMessage(itemDescription);
-
- RevenantItemBuyButton.Text = Loc.GetString("revenant-user-interface-cost", ("price", itemPrice));
- RevenantItemBuyButton.Disabled = !canBuy;
-
- RevenantItemTexture.Texture = texture;
- }
-}
diff --git a/Content.Client/Revenant/Ui/RevenantMenu.xaml b/Content.Client/Revenant/Ui/RevenantMenu.xaml
deleted file mode 100644
index 6a368bfd3f..0000000000
--- a/Content.Client/Revenant/Ui/RevenantMenu.xaml
+++ /dev/null
@@ -1,41 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Content.Client/Revenant/Ui/RevenantMenu.xaml.cs b/Content.Client/Revenant/Ui/RevenantMenu.xaml.cs
deleted file mode 100644
index 62388b87fd..0000000000
--- a/Content.Client/Revenant/Ui/RevenantMenu.xaml.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using Content.Client.Message;
-using Content.Shared.FixedPoint;
-using Content.Shared.Revenant;
-using Robust.Client.AutoGenerated;
-using Robust.Client.UserInterface.Controls;
-using Robust.Client.UserInterface.CustomControls;
-using Robust.Client.UserInterface.XAML;
-using Robust.Client.Utility;
-
-namespace Content.Client.Revenant.Ui;
-
-[GenerateTypedNameReferences]
-public sealed partial class RevenantMenu : DefaultWindow
-{
- private FixedPoint2 _essence = 0f;
-
- public event Action? OnListingButtonPressed;
-
- public RevenantMenu()
- {
- RobustXamlLoader.Load(this);
- }
-
- public void UpdateEssence(float essence)
- {
- // update balance label
- _essence = essence;
- var balanceStr = Loc.GetString("revenant-user-interface-essence-amount", ("amount", Math.Round(_essence.Float())));
- BalanceInfo.SetMarkup(balanceStr);
- }
-
- public void UpdateListing(List listings)
- {
- // should probably chunk these out instead. to-do if this clogs the internet tubes.
- // maybe read clients prototypes instead?
- ClearListings();
- foreach (var item in listings)
- {
- AddListingGui(item);
- }
- }
-
- private void AddListingGui(RevenantStoreListingPrototype listing)
- {
- var listingName = listing.ListingName;
- var listingDesc = listing.Description;
- var listingPrice = listing.Price;
- var canBuy = _essence > listing.Price;
- var texture = listing.Icon?.Frame0();
-
- var newListing = new RevenantListingControl(listingName, listingDesc, listingPrice, canBuy, texture);
- newListing.RevenantItemBuyButton.OnButtonDown += args
- => OnListingButtonPressed?.Invoke(args, listing);
-
- RevenantListingsContainer.AddChild(newListing);
- }
-
- private void ClearListings()
- {
- RevenantListingsContainer.Children.Clear();
- }
-}
diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
index 3e856e644c..84b7697494 100644
--- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
+++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
@@ -23,7 +23,9 @@ using Content.Shared.MobState;
using Content.Server.Explosion.EntitySystems;
using System.Linq;
using Content.Server.Emag;
+using Content.Server.Store.Components;
using Content.Shared.CharacterAppearance.Components;
+using Content.Shared.FixedPoint;
using Robust.Shared.Utility;
namespace Content.Server.Revenant.EntitySystems;
@@ -177,7 +179,9 @@ public sealed partial class RevenantSystem : EntitySystem
essence.Harvested = true;
ChangeEssenceAmount(uid, essence.EssenceAmount, component);
- component.StolenEssence += essence.EssenceAmount;
+ if (TryComp(uid, out var store))
+ _store.TryAddCurrency(new Dictionary()
+ { {component.StolenEssenceCurrencyPrototype, essence.EssenceAmount} }, store);
if (!TryComp(args.Target, out var mobstate))
return;
diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Shop.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Shop.cs
deleted file mode 100644
index 7512ac40e2..0000000000
--- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Shop.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System.Linq;
-using Content.Shared.Revenant;
-using Content.Server.UserInterface;
-using Robust.Server.GameObjects;
-using Robust.Server.Player;
-using Content.Shared.Actions.ActionTypes;
-
-namespace Content.Server.Revenant.EntitySystems;
-
-// TODO: Delete and replace all of this with StoreSystem once that's merged
-// i'm sorry, but i'm not ultra-optimizing something that's getting deleted in a week.
-// 8/7/22 -emo (bully me if this exists in the future)
-public sealed partial class RevenantSystem : EntitySystem
-{
- private void InitializeShop()
- {
- SubscribeLocalEvent(OnShop);
- SubscribeLocalEvent(OnBuy);
- }
-
- private void OnShop(EntityUid uid, RevenantComponent component, RevenantShopActionEvent args)
- {
- if (!TryComp(uid, out var actor))
- return;
- ToggleUi(component, actor.PlayerSession);
- }
-
- private void OnBuy(EntityUid uid, RevenantComponent component, RevenantBuyListingMessage ev)
- {
- RevenantStoreListingPrototype? targetListing = null;
- foreach (var listing in component.Listings)
- {
- if (listing.Key.ID == ev.Listing.ID)
- targetListing = listing.Key;
- }
-
- if (targetListing == null)
- return;
- component.Listings[targetListing] = false;
-
- if (component.StolenEssence < ev.Listing.Price)
- return;
- component.StolenEssence -= ev.Listing.Price;
-
- if (_proto.TryIndex(ev.Listing.ActionId, out var action))
- _action.AddAction(uid, new InstantAction(action), null);
-
- UpdateUserInterface(component);
- }
-
- public void ToggleUi(RevenantComponent component, IPlayerSession session)
- {
- var ui = component.Owner.GetUIOrNull(RevenantUiKey.Key);
- ui?.Toggle(session);
-
- UpdateUserInterface(component);
- }
-
- private void UpdateUserInterface(RevenantComponent component)
- {
- var ui = component.Owner.GetUIOrNull(RevenantUiKey.Key);
- if (ui == null)
- return;
-
- var filterlistings = (from e in component.Listings where e.Value select e.Key).ToList();
-
- ui.SetState(new RevenantUpdateState(component.StolenEssence.Float(), filterlistings));
- }
-}
diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.cs
index 8cf57b20d2..ef7d1269b4 100644
--- a/Content.Server/Revenant/EntitySystems/RevenantSystem.cs
+++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.cs
@@ -16,6 +16,8 @@ using Robust.Shared.Prototypes;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Tag;
using Content.Server.Polymorph.Systems;
+using Content.Server.Store.Components;
+using Content.Server.Store.Systems;
using Content.Shared.FixedPoint;
using Robust.Shared.Player;
using Content.Shared.Movement.Systems;
@@ -42,6 +44,7 @@ public sealed partial class RevenantSystem : EntitySystem
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
+ [Dependency] private readonly StoreSystem _store = default!;
public override void Initialize()
{
@@ -49,13 +52,13 @@ public sealed partial class RevenantSystem : EntitySystem
SubscribeLocalEvent(OnStartup);
+ SubscribeLocalEvent(OnShop);
SubscribeLocalEvent(OnDamage);
SubscribeLocalEvent(OnExamine);
SubscribeLocalEvent(OnStatusAdded);
SubscribeLocalEvent(OnStatusEnded);
InitializeAbilities();
- InitializeShop();
}
private void OnStartup(EntityUid uid, RevenantComponent component, ComponentStartup args)
@@ -72,10 +75,6 @@ public sealed partial class RevenantSystem : EntitySystem
if (TryComp(component.Owner, out EyeComponent? eye))
eye.VisibilityMask |= (uint) (VisibilityFlags.Ghost);
- //get all the abilities
- foreach (var listing in _proto.EnumeratePrototypes())
- component.Listings.Add(listing, true);
-
var shopaction = new InstantAction(_proto.Index("RevenantShop"));
_action.AddAction(uid, shopaction, null);
}
@@ -133,7 +132,8 @@ public sealed partial class RevenantSystem : EntitySystem
_polymorphable.PolymorphEntity(uid, "Ectoplasm");
}
- UpdateUserInterface(component);
+ if (TryComp(uid, out var store))
+ _store.UpdateUserInterface(uid, store);
return true;
}
@@ -163,6 +163,13 @@ public sealed partial class RevenantSystem : EntitySystem
return true;
}
+ private void OnShop(EntityUid uid, RevenantComponent component, RevenantShopActionEvent args)
+ {
+ if (!TryComp(uid, out var store))
+ return;
+ _store.ToggleUi(uid, store);
+ }
+
public override void Update(float frameTime)
{
base.Update(frameTime);
diff --git a/Content.Server/Revenant/RevenantComponent.cs b/Content.Server/Revenant/RevenantComponent.cs
index f8fa3c7f9b..6484821862 100644
--- a/Content.Server/Revenant/RevenantComponent.cs
+++ b/Content.Server/Revenant/RevenantComponent.cs
@@ -4,6 +4,7 @@ using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using System.Threading;
using Content.Shared.FixedPoint;
+using Content.Shared.Store;
namespace Content.Server.Revenant;
@@ -17,11 +18,8 @@ public sealed class RevenantComponent : SharedRevenantComponent
[ViewVariables(VVAccess.ReadWrite)]
public FixedPoint2 Essence = 75;
- ///
- /// Used for purchasing shop items.
- ///
- [ViewVariables(VVAccess.ReadWrite)]
- public FixedPoint2 StolenEssence = 0;
+ [DataField("stolenEssenceCurrencyPrototype", customTypeSerializer: typeof(PrototypeIdSerializer))]
+ public string StolenEssenceCurrencyPrototype = "StolenEssence";
///
/// The entity's current max amount of essence. Can be increased
@@ -189,12 +187,6 @@ public sealed class RevenantComponent : SharedRevenantComponent
[ViewVariables(VVAccess.ReadWrite), DataField("malfunctionRadius")]
public float MalfunctionRadius = 3.5f;
#endregion
-
- ///
- /// Stores all of the currently unlockable abilities in the shop.
- ///
- [ViewVariables]
- public Dictionary Listings = new ();
}
public sealed class SoulSearchDoAfterComplete : EntityEventArgs
diff --git a/Content.Server/Store/Systems/StoreSystem.Ui.cs b/Content.Server/Store/Systems/StoreSystem.Ui.cs
index b8514deda2..b2a755e63e 100644
--- a/Content.Server/Store/Systems/StoreSystem.Ui.cs
+++ b/Content.Server/Store/Systems/StoreSystem.Ui.cs
@@ -60,15 +60,13 @@ public sealed partial class StoreSystem : EntitySystem
{
ui = component.Owner.GetUIOrNull(StoreUiKey.Key);
if (ui == null)
- {
- Logger.Error("No Ui key.");
return;
- }
}
//if we haven't opened it before, initialize the shit
if (!component.Opened)
{
+ RefreshAllListings(component);
InitializeFromPreset(component.Preset, component);
component.Opened = true;
}
diff --git a/Content.Server/Store/Systems/StoreSystem.cs b/Content.Server/Store/Systems/StoreSystem.cs
index dfa2c16dfc..e55a5d228e 100644
--- a/Content.Server/Store/Systems/StoreSystem.cs
+++ b/Content.Server/Store/Systems/StoreSystem.cs
@@ -141,7 +141,6 @@ public sealed partial class StoreSystem : EntitySystem
/// The store being initialized
public void InitializeFromPreset(StorePresetPrototype preset, StoreComponent component)
{
- RefreshAllListings(component);
component.Preset = preset.ID;
component.CurrencyWhitelist.UnionWith(preset.CurrencyWhitelist);
component.Categories.UnionWith(preset.Categories);
diff --git a/Content.Shared/Revenant/RevenantStoreListingPrototype.cs b/Content.Shared/Revenant/RevenantStoreListingPrototype.cs
deleted file mode 100644
index 4bb3d376c7..0000000000
--- a/Content.Shared/Revenant/RevenantStoreListingPrototype.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Content.Shared.Actions.ActionTypes;
-using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
-using Robust.Shared.Utility;
-
-namespace Content.Shared.Revenant;
-
-[Serializable]
-[Prototype("revenantListing")]
-public sealed class RevenantStoreListingPrototype : IPrototype
-{
- [ViewVariables]
- [IdDataField]
- public string ID { get; } = default!;
-
- [DataField("actionId", customTypeSerializer:typeof(PrototypeIdSerializer))]
- public string ActionId { get; } = string.Empty;
-
- [DataField("price")]
- public int Price { get; } = 5;
-
- [DataField("description")]
- public string Description { get; } = string.Empty;
-
- [DataField("listingName")]
- public string ListingName { get; } = string.Empty;
-
- [DataField("icon")]
- public SpriteSpecifier? Icon { get; } = null;
-}
diff --git a/Content.Shared/Revenant/SharedRevenant.cs b/Content.Shared/Revenant/SharedRevenant.cs
index e2f18fb842..25be1d0310 100644
--- a/Content.Shared/Revenant/SharedRevenant.cs
+++ b/Content.Shared/Revenant/SharedRevenant.cs
@@ -16,34 +16,3 @@ public enum RevenantVisuals : byte
Stunned,
Harvesting,
}
-
-[NetSerializable, Serializable]
-public enum RevenantUiKey : byte
-{
- Key
-}
-
-[Serializable, NetSerializable]
-public sealed class RevenantUpdateState : BoundUserInterfaceState
-{
- public float Essence;
-
- public readonly List Listings;
-
- public RevenantUpdateState(float essence, List listings)
- {
- Essence = essence;
- Listings = listings;
- }
-}
-
-[Serializable, NetSerializable]
-public sealed class RevenantBuyListingMessage : BoundUserInterfaceMessage
-{
- public RevenantStoreListingPrototype Listing;
-
- public RevenantBuyListingMessage (RevenantStoreListingPrototype listing)
- {
- Listing = listing;
- }
-}
diff --git a/Resources/Locale/en-US/store/currency.ftl b/Resources/Locale/en-US/store/currency.ftl
index 83853d4e5c..0bfe32bf8a 100644
--- a/Resources/Locale/en-US/store/currency.ftl
+++ b/Resources/Locale/en-US/store/currency.ftl
@@ -8,4 +8,7 @@ store-currency-price-display-debugdollar = {$amount ->
}
store-currency-balance-display-telecrystal = TC: {$amount}
-store-currency-price-display-telecrystal = {$amount} TC
\ No newline at end of file
+store-currency-price-display-telecrystal = {$amount} TC
+
+store-currency-balance-display-stolen-essence = Stolen Essence: {$amount}
+store-currency-price-display-stolen-essence = {$amount} Stolen Essence
\ No newline at end of file
diff --git a/Resources/Prototypes/Catalog/revenant_catalog.yml b/Resources/Prototypes/Catalog/revenant_catalog.yml
index 347b610728..977282b370 100644
--- a/Resources/Prototypes/Catalog/revenant_catalog.yml
+++ b/Resources/Prototypes/Catalog/revenant_catalog.yml
@@ -1,32 +1,51 @@
-#TODO: generic shop system
-- type: revenantListing
- id: Defile
- actionId: RevenantDefile
- listingName: Defile
- description: Costs 30 Essence per use. Defiles the surrounding area, ripping up floors, damaging windows, opening containers, and throwing items. Using it leaves you vulnerable to attacks for a short period of time.
- icon: Interface/Actions/defile.png
- price: 10
+- type: listing
+ id: RevenantDefile
+ name: Defile
+ description: Defiles the surrounding area, ripping up floors, damaging windows, opening containers, and throwing items. Using it leaves you vulnerable to attacks for a short period of time.
+ productAction: RevenantDefile
+ cost:
+ StolenEssence: 10
+ categories:
+ - RevenantAbilities
+ conditions:
+ - !type:ListingLimitedStockCondition
+ stock: 1
-- type: revenantListing
- id: OverloadLights
- actionId: RevenantOverloadLights
- listingName: Overload Lights
- description: Costs 40 Essence per use. Overloads all nearby lights, causing the bulbs to shatter and sending out damaging sparks. Using it leaves you vulnerable to attacks for a long period of time.
- icon: Interface/Actions/overloadlight.png
- price: 25
+- type: listing
+ id: RevenantOverloadLights
+ name: Overload Lights
+ description: Overloads all nearby lights, causing the bulbs to shatter and sending out damaging sparks. Using it leaves you vulnerable to attacks for a long period of time.
+ productAction: RevenantOverloadLights
+ cost:
+ StolenEssence: 25
+ categories:
+ - RevenantAbilities
+ conditions:
+ - !type:ListingLimitedStockCondition
+ stock: 1
-- type: revenantListing
- id: Blight
- actionId: RevenantBlight
- listingName: Blight
- description: Costs 50 Essence per use. Infects all nearby organisms with an infectious disease that causes poison and tiredness. Using it leaves you vulnerable to attacks for a medium period of time.
- icon: Interface/Actions/blight.png
- price: 75
+- type: listing
+ id: RevenantBlight
+ name: Blight
+ description: Infects all nearby organisms with an infectious disease that causes toxic buildup and tiredness. Using it leaves you vulnerable to attacks for a medium period of time.
+ productAction: RevenantBlight
+ cost:
+ StolenEssence: 75
+ categories:
+ - RevenantAbilities
+ conditions:
+ - !type:ListingLimitedStockCondition
+ stock: 1
-- type: revenantListing
- id: Malfunction
- actionId: RevenantMalfunction
- listingName: Malfunction
- description: Costs 60 Essence per use. Makes most nearby electronics stop working properly. Using it leaves you vulnerable to attacks for a long period of time.
- icon: Interface/Actions/malfunction.png
- price: 125
\ No newline at end of file
+- type: listing
+ id: RevenantMalfunction
+ name: Malfunction
+ description: Makes nearby electronics stop working properly. Using it leaves you vulnerable to attacks for a long period of time.
+ productAction: RevenantMalfunction
+ cost:
+ StolenEssence: 125
+ categories:
+ - RevenantAbilities
+ conditions:
+ - !type:ListingLimitedStockCondition
+ stock: 1
diff --git a/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml b/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml
index e44cc9aa2e..ed3df2e40d 100644
--- a/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml
+++ b/Resources/Prototypes/Entities/Mobs/NPCs/revenant.yml
@@ -60,11 +60,16 @@
softness: 0.75
- type: UserInterface
interfaces:
- - key: enum.RevenantUiKey.Key
- type: RevenantBoundUserInterface
+ - key: enum.StoreUiKey.Key
+ type: StoreBoundUserInterface
- type: MobState
- type: Visibility
layer: 2 #ghost vis layer
+ - type: Store
+ categories:
+ - RevenantAbilities
+ currencyWhitelist:
+ - StolenEssence
- type: entity
parent: BaseItem
diff --git a/Resources/Prototypes/Store/categories.yml b/Resources/Prototypes/Store/categories.yml
index 135500ccce..071d4c5d1b 100644
--- a/Resources/Prototypes/Store/categories.yml
+++ b/Resources/Prototypes/Store/categories.yml
@@ -58,3 +58,8 @@
name: Pointless
priority: 9
+#revenant
+- type: storeCategory
+ id: RevenantAbilities
+ name: Abilities
+
diff --git a/Resources/Prototypes/Store/currency.yml b/Resources/Prototypes/Store/currency.yml
index 1ff3b94f99..8911b46475 100644
--- a/Resources/Prototypes/Store/currency.yml
+++ b/Resources/Prototypes/Store/currency.yml
@@ -5,6 +5,12 @@
entityId: Telecrystal1
canWithdraw: true
+- type: currency
+ id: StolenEssence
+ balanceDisplay: store-currency-balance-display-stolen-essence
+ priceDisplay: store-currency-price-display-stolen-essence
+ canWithdraw: false
+
#debug
- type: currency
id: DebugDollar