diff --git a/Content.Server/_Crescent/Shipyard/ShipyardPatch.cs b/Content.Server/_Crescent/Shipyard/ShipyardPatch.cs index 1b2cb63e9c9..14002bbbec9 100644 --- a/Content.Server/_Crescent/Shipyard/ShipyardPatch.cs +++ b/Content.Server/_Crescent/Shipyard/ShipyardPatch.cs @@ -264,7 +264,15 @@ public bool TrySellShuttle(EntityUid stationUid, EntityUid shuttleUid, out int b _station.DeleteStation(shuttleStationUid); } - bill = (int) _pricing.AppraiseGrid(shuttleUid); + var value = _pricing.AppraiseGrid(shuttleUid); + + if (TryComp(shuttleUid, out var mult)) + { + value *= mult.priceMultiplier; + } + + bill = (int) value; + _mapManager.DeleteGrid(shuttleUid); _sawmill.Info($"Sold shuttle {shuttleUid} for {bill}"); return true; @@ -291,6 +299,27 @@ private void SetupShipyard() _mapManager.SetMapPaused(ShipyardMap.Value, false); } + + private int GetShuttleSellValue(EntityUid shuttleUid, ShipyardConsoleUiKey? uiKey = null) + { + var value = _pricing.AppraiseGrid(shuttleUid); + + if (TryComp(shuttleUid, out var mult)) + { + value *= mult.priceMultiplier; + } + + // Existing tax logic + if (uiKey is ShipyardConsoleUiKey.BlackMarket + or ShipyardConsoleUiKey.Syndicate) + { + value -= (int)(value * 0.30f); + } + + return (int) value; + } + + // // Tries to rename a shuttle deed and update the respective components. // Returns true if successful. @@ -406,6 +435,25 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component PlayDenySound(uid, component); return; } + + // Apply resale depreciation to purchased ships + var priceMult = EnsureComp(shuttle.Owner); + priceMult.priceMultiplier = 0.80f; + + var sellValue = (int)(_pricing.AppraiseGrid(shuttle.Owner) * 0.8f); + + RefreshState( + uid, + bank.Balance, + true, + name, + sellValue, + true, + (ShipyardConsoleUiKey) args.UiKey + ); + + + EntityUid? shuttleStation = null; // setting up any stations if we have a matching game map prototype to allow late joins directly onto the vessel if (_prototypeManager.TryIndex(vessel.ID, out var stationProto)) @@ -455,10 +503,6 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component - int sellValue = 0; - if (TryComp(product, out var deed)) - sellValue = (int) _pricing.AppraiseGrid((EntityUid) (deed?.ShuttleUid!)); - EnsureComp(shuttle.Owner); if (TryComp(shuttle.Owner, out var shuttleCodes)) { @@ -670,6 +714,37 @@ private void SendSellMessage(EntityUid uid, EntityUid? player, string name, stri } } + private void ForceRefreshUi( + EntityUid console, + EntityUid shuttle, + string shipName, + ShipyardConsoleUiKey uiKey) + { + if (!TryComp(console, out var uiComp)) + return; + + var actors = _ui.GetActors(console, uiKey); + + foreach (var actor in actors) + { + if (!TryComp(actor, out var bank)) + continue; + + var sellValue = GetShuttleSellValue(shuttle, uiKey); + + RefreshState( + console, + bank.Balance, + true, + shipName, + sellValue, + true, + uiKey + ); + } + } + + private void PlayDenySound(EntityUid uid, ShipyardConsoleComponent component) { _audio.PlayPvs(_audio.GetSound(component.DenySound), uid, AudioParams.Default.WithMaxDistance(0.01f)); @@ -708,15 +783,9 @@ private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component } var sellValue = deed?.ShuttleUid != null - ? (int)_pricing.AppraiseGrid((EntityUid)deed.ShuttleUid) + ? GetShuttleSellValue((EntityUid) deed.ShuttleUid, (ShipyardConsoleUiKey) uiComp.Key) : 0; - if (uiComp.Key is ShipyardConsoleUiKey.BlackMarket - or ShipyardConsoleUiKey.Syndicate) - { - var tax = (int)(sellValue * 0.30f); - sellValue -= tax; - } var fullName = deed != null ? GetFullName(deed) : null; RefreshState(uid, bank.Balance, true, fullName, sellValue, targetId.HasValue, (ShipyardConsoleUiKey)uiComp.Key); @@ -932,7 +1001,7 @@ private bool TryRedeemShip(EntityUid uid, ShipyardConsoleComponent component, En }); _shuttle.AddIFFFlag(shuttle.Owner, IFFFlags.IsPlayerShuttle); var comp = EnsureComp(shuttle.Owner); - comp.priceMultiplier = 0.25f; + comp.priceMultiplier = 0.80f; // match our IFF faction with our spawner's if (TryComp(Transform(uid).GridUid, out var stationIFF))