Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

STC2 #569

Merged
merged 7 commits into from
Nov 13, 2023
Merged

STC2 #569

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 48 additions & 6 deletions Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,16 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component
}

var newDeed = EnsureComp<ShuttleDeedComponent>(targetId);
var channel = _prototypeManager.Index<RadioChannelPrototype>(component.ShipyardChannel);
newDeed.ShuttleUid = shuttle.Owner;
newDeed.ShuttleName = name;
newDeed.ShuttleOwner = player;

var channel = component.ShipyardChannel;

if (ShipyardConsoleUiKey.Security != (ShipyardConsoleUiKey) args.UiKey)
_idSystem.TryChangeJobTitle(targetId, $"Captain", idCard, player);
else
channel = component.SecurityShipyardChannel;

// The following block of code is entirely to do with trying to sanely handle moving records from station to station.
// it is ass.
Expand Down Expand Up @@ -225,10 +228,12 @@ private void OnPurchaseMessage(EntityUid uid, ShipyardConsoleComponent component
{
var tax = (int) (sellValue * 0.30f);
sellValue -= tax;
channel = component.BlackMarketShipyardChannel;

SendPurchaseMessage(uid, player, name, component.SecurityShipyardChannel, true);
}

_radio.SendRadioMessage(uid, Loc.GetString("shipyard-console-docking", ("owner", player), ("vessel", name)), channel, uid);
_chat.TrySendInGameICMessage(uid, Loc.GetString("shipyard-console-docking", ("owner", player), ("vessel", name)), InGameICChatType.Speak, true);
SendPurchaseMessage(uid, player, name, channel, false);

PlayConfirmSound(uid, component);
_adminLogger.Add(LogType.ShipYardUsage, LogImpact.Low, $"{ToPrettyString(player):actor} purchased shuttle {ToPrettyString(shuttle.Owner)} for {vessel.Price} credits via {ToPrettyString(component.Owner)}");
Expand Down Expand Up @@ -291,7 +296,7 @@ public void OnSellMessage(EntityUid uid, ShipyardConsoleComponent component, Shi

var shuttleName = ToPrettyString(shuttleUid); // Grab the name before it gets 1984'd

var channel = _prototypeManager.Index<RadioChannelPrototype>(component.ShipyardChannel);
var channel = component.ShipyardChannel;

if (!TrySellShuttle(stationUid, shuttleUid, out var bill))
{
Expand All @@ -302,6 +307,9 @@ public void OnSellMessage(EntityUid uid, ShipyardConsoleComponent component, Shi

RemComp<ShuttleDeedComponent>(targetId);

if (ShipyardConsoleUiKey.Security == (ShipyardConsoleUiKey) args.UiKey)
channel = component.SecurityShipyardChannel;

if (ShipyardConsoleUiKey.BlackMarket == (ShipyardConsoleUiKey) args.UiKey)
{
var tax = (int) (bill * 0.30f);
Expand All @@ -313,13 +321,15 @@ public void OnSellMessage(EntityUid uid, ShipyardConsoleComponent component, Shi
}

bill -= tax;
channel = component.BlackMarketShipyardChannel;

SendSellMessage(uid, deed.ShuttleOwner!, deed.ShuttleName!, component.SecurityShipyardChannel, player, true);
}

_bank.TryBankDeposit(player, bill);
PlayConfirmSound(uid, component);

_radio.SendRadioMessage(uid, Loc.GetString("shipyard-console-leaving", ("owner", deed.ShuttleOwner!), ("vessel", deed.ShuttleName!), ("player", player)), channel, uid);
_chat.TrySendInGameICMessage(uid, Loc.GetString("shipyard-console-leaving", ("owner", deed.ShuttleOwner!), ("vessel", deed.ShuttleName!), ("player", player)), InGameICChatType.Speak, true);
SendSellMessage(uid, deed.ShuttleOwner!, deed.ShuttleName!, channel, player, false);

_adminLogger.Add(LogType.ShipYardUsage, LogImpact.Low, $"{ToPrettyString(player):actor} sold {shuttleName} for {bill} credits via {ToPrettyString(component.Owner)}");
RefreshState(uid, bank.Balance, true, null, 0, true, (ShipyardConsoleUiKey) args.UiKey);
Expand Down Expand Up @@ -360,6 +370,38 @@ private void ConsolePopup(ICommonSession session, string text)
_popup.PopupEntity(text, player);
}

private void SendPurchaseMessage(EntityUid uid, EntityUid player, string name, string shipyardChannel, bool secret)
{
var channel = _prototypeManager.Index<RadioChannelPrototype>(shipyardChannel);

if (secret)
{
_radio.SendRadioMessage(uid, Loc.GetString("shipyard-console-docking-secret", ("vessel", name)), channel, uid);
_chat.TrySendInGameICMessage(uid, Loc.GetString("shipyard-console-docking-secret", ("vessel", name)), InGameICChatType.Speak, true);
}
else
{
_radio.SendRadioMessage(uid, Loc.GetString("shipyard-console-docking", ("owner", player), ("vessel", name)), channel, uid);
_chat.TrySendInGameICMessage(uid, Loc.GetString("shipyard-console-docking", ("owner", player!), ("vessel", name)), InGameICChatType.Speak, true);
}
}

private void SendSellMessage(EntityUid uid, EntityUid? player, string name, string shipyardChannel, EntityUid seller, bool secret)
{
var channel = _prototypeManager.Index<RadioChannelPrototype>(shipyardChannel);

if (secret)
{
_radio.SendRadioMessage(uid, Loc.GetString("shipyard-console-leaving-secret", ("vessel", name!)), channel, uid);
_chat.TrySendInGameICMessage(uid, Loc.GetString("shipyard-console-leaving-secret", ("vessel", name!)), InGameICChatType.Speak, true);
}
else
{
_radio.SendRadioMessage(uid, Loc.GetString("shipyard-console-leaving", ("owner", player!), ("vessel", name!), ("player", seller)), channel, uid);
_chat.TrySendInGameICMessage(uid, Loc.GetString("shipyard-console-leaving", ("owner", player!), ("vessel", name!), ("player", seller)), InGameICChatType.Speak, true);
}
}

private void PlayDenySound(EntityUid uid, ShipyardConsoleComponent component)
{
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ public sealed partial class ShipyardConsoleComponent : Component

[DataField("shipyardChannel")]
public string ShipyardChannel = "Traffic";

[DataField("securityShipyardChannel")]
public string SecurityShipyardChannel = "Security";

[DataField("blackMarketShipyardChannel")]
public string BlackMarketShipyardChannel = "Syndicate";
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ shipyard-console-invalid-vessel = Cannot purchase vessel:
shipyard-console-menu-title = Shipyard Menu
shipyard-console-docking = Captain {$owner} shuttle {$vessel} en route, eta 10 seconds.
shipyard-console-leaving = Captain {$owner} shuttle {$vessel} sold by {$player}.
shipyard-console-docking-secret = shuttle {$vessel} en route, eta 10 seconds.
shipyard-console-leaving-secret = shuttle {$vessel} sold.
shipyard-commands-purchase-desc = Spawns and FTL docks a specified shuttle from a grid file.
shipyard-console-no-idcard = No ID card present
shipyard-console-already-deeded = ID card already has a Deed
Expand Down
Loading