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

Shipyard RCD #1130

Merged
merged 8 commits into from
Mar 24, 2024
Merged
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
5 changes: 3 additions & 2 deletions Content.Server/Shipyard/Systems/ShipyardSystem.Consoles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
using Content.Server.Shuttles.Components;
using Content.Server.Station.Components;
using System.Text.RegularExpressions;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;

namespace Content.Server.Shipyard.Systems;
Expand Down Expand Up @@ -438,12 +439,12 @@ private void SendSellMessage(EntityUid uid, EntityUid? player, string name, stri

private void PlayDenySound(EntityUid uid, ShipyardConsoleComponent component)
{
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid);
_audio.PlayPvs(_audio.GetSound(component.ErrorSound), uid, AudioParams.Default.WithMaxDistance(0.01f));
}

private void PlayConfirmSound(EntityUid uid, ShipyardConsoleComponent component)
{
_audio.PlayPvs(_audio.GetSound(component.ConfirmSound), uid);
_audio.PlayPvs(_audio.GetSound(component.ConfirmSound), uid, AudioParams.Default.WithMaxDistance(0.01f));
}

private void OnItemSlotChanged(EntityUid uid, ShipyardConsoleComponent component, ContainerModifiedMessage args)
Expand Down
18 changes: 18 additions & 0 deletions Content.Shared/Access/Components/IdCardComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Content.Shared.Access.Systems;
using Content.Shared.PDA;
using Content.Shared.StatusIcon;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

Expand Down Expand Up @@ -40,4 +41,21 @@ public sealed partial class IdCardComponent : Component
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public bool BypassLogging;


// Frontier
[DataField("soundError")]
public SoundSpecifier ErrorSound =
new SoundPathSpecifier("/Audio/Effects/Cargo/buzz_sigh.ogg");

// Frontier
[DataField("soundSwipe")]
public SoundSpecifier SwipeSound =
new SoundPathSpecifier("/Audio/Machines/id_swipe.ogg");

// Frontier
[DataField("soundInsert")]
public SoundSpecifier InsertSound =
new SoundPathSpecifier("/Audio/Machines/id_insert.ogg");

}
7 changes: 7 additions & 0 deletions Content.Shared/RCD/Components/RCDAmmoComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ public sealed partial class RCDAmmoComponent : Component
/// </summary>
[DataField("charges"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public int Charges = 5;

/// <summary>
/// ~~~ Frontier ~~~
/// A flag that limits RCD to the authorized ships.
/// </summary>
[DataField("isShipyardRCDAmmo"), AutoNetworkedField]
public bool IsShipyardRCDAmmo;
}

// TODO: state??? check if it desyncs
14 changes: 14 additions & 0 deletions Content.Shared/RCD/Components/RCDComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,18 @@ public sealed partial class RCDComponent : Component
[DataField("floor", customTypeSerializer: typeof(PrototypeIdSerializer<ContentTileDefinition>))]
[ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
public string Floor = "FloorSteel";

/// <summary>
/// ~~~ Frontier ~~~
/// A flag that limits RCD to the authorized ships.
/// </summary>
[DataField("isShipyardRCD"), AutoNetworkedField]
public bool IsShipyardRCD;

/// <summary>
/// ~~~ Frontier ~~~
/// The uid to which this RCD is limited to be used on.
/// </summary>
[DataField("linkedShuttleUid"), AutoNetworkedField]
public EntityUid? LinkedShuttleUid = null;
}
10 changes: 10 additions & 0 deletions Content.Shared/RCD/Systems/RCDAmmoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ private void OnAfterInteract(EntityUid uid, RCDAmmoComponent comp, AfterInteract
return;

var user = args.User;

// ## Frontier - Shipyard RCD ammo only fits in shipyard RCD.
// At this point RCDComponent is guaranteed
EnsureComp<RCDComponent>(target, out var rcdComponent);
GreaseMonk marked this conversation as resolved.
Show resolved Hide resolved
if (rcdComponent.IsShipyardRCD && !comp.IsShipyardRCDAmmo || !rcdComponent.IsShipyardRCD && comp.IsShipyardRCDAmmo)
{
_popup.PopupClient(Loc.GetString("rcd-component-wrong-ammo-type"), target, user);
return;
}

args.Handled = true;
var count = Math.Min(charges.MaxCharges - charges.Charges, comp.Charges);
if (count <= 0)
Expand Down
101 changes: 92 additions & 9 deletions Content.Shared/RCD/Systems/RCDSystem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Content.Shared.Access.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Charges.Components;
using Content.Shared.Charges.Systems;
Expand All @@ -10,6 +11,7 @@
using Content.Shared.Physics;
using Content.Shared.Popups;
using Content.Shared.RCD.Components;
using Content.Shared.Shipyard.Components;
using Content.Shared.Tag;
using Content.Shared.Tiles;
using Robust.Shared.Audio;
Expand Down Expand Up @@ -50,6 +52,7 @@ public override void Initialize()
SubscribeLocalEvent<RCDComponent, AfterInteractEvent>(OnAfterInteract);
SubscribeLocalEvent<RCDComponent, RCDDoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<RCDComponent, DoAfterAttemptEvent<RCDDoAfterEvent>>(OnDoAfterAttempt);
SubscribeLocalEvent<IdCardComponent, AfterInteractEvent>(OnIdCardSwipeHappened); // Frontier
}

private void OnExamine(EntityUid uid, RCDComponent comp, ExaminedEvent args)
Expand All @@ -70,6 +73,56 @@ private void OnUseInHand(EntityUid uid, RCDComponent comp, UseInHandEvent args)
args.Handled = true;
}

/**
* Frontier - ability to swipe rcd for authorizations to build on specific grids
*/
private void OnIdCardSwipeHappened(EntityUid uid, IdCardComponent comp, ref AfterInteractEvent args)
{
if (args.Handled)
return;

if (args.Target is not { Valid: true } target || !args.CanReach)
return;

var rcdEntityUid = target;

// Is this id card interacting with a shipyard RCD ? if not, ignore it.
if (!TryComp<RCDComponent>(rcdEntityUid, out var rcdComponent) || !rcdComponent.IsShipyardRCD)
{
args.Handled = true;
return;
}

// If the id card has no registered ship we cant continue.
if (!TryComp<ShuttleDeedComponent>(comp.Owner, out var shuttleDeedComponent))
{
_popup.PopupClient(Loc.GetString("rcd-component-missing-id-deed"),
uid, args.User, PopupType.Medium);
_audio.PlayPredicted(comp.ErrorSound, rcdEntityUid, args.User, AudioParams.Default.WithMaxDistance(0.01f));
args.Handled = true;
return;
}

// Swiping it again removes the authorization on it.
if (rcdComponent.LinkedShuttleUid != null)
{
_popup.PopupClient(Loc.GetString("rcd-component-id-card-removed"),
uid, args.User, PopupType.Medium);
_audio.PlayPredicted(comp.SwipeSound, rcdEntityUid, args.User, AudioParams.Default.WithMaxDistance(0.01f));
rcdComponent.LinkedShuttleUid = null;
}
else
{
_popup.PopupClient(Loc.GetString("rcd-component-id-card-accepted"),
uid, args.User, PopupType.Medium);
_audio.PlayPredicted(comp.InsertSound, rcdEntityUid, args.User, AudioParams.Default.WithMaxDistance(0.01f));
rcdComponent.LinkedShuttleUid = shuttleDeedComponent.ShuttleUid;
}

Dirty(rcdComponent.Owner, rcdComponent);
args.Handled = true;
}

private void OnAfterInteract(EntityUid uid, RCDComponent comp, AfterInteractEvent args)
{
if (args.Handled || !args.CanReach)
Expand Down Expand Up @@ -111,10 +164,48 @@ private void OnAfterInteract(EntityUid uid, RCDComponent comp, AfterInteractEven

args.Handled = true;

if (_doAfter.TryStartDoAfter(doAfterArgs) && _gameTiming.IsFirstTimePredicted)
// IsAuthorized is part of frontier
if (IsAuthorized(gridId, uid, comp, args) && _doAfter.TryStartDoAfter(doAfterArgs) && _gameTiming.IsFirstTimePredicted)
Spawn("EffectRCDConstruction", location);
}

/**
* Frontier - Stops RCD functions if there is a protected grid component on it, and adds shipyard rcd limitations.
*/
private bool IsAuthorized(EntityUid? gridId, EntityUid uid, RCDComponent comp, AfterInteractEvent args)
{
if (gridId == null)
{
return true;
}
var mapGrid = _mapMan.GetGrid(gridId.Value);
var gridUid = mapGrid.Owner;

// Frontier - Remove all RCD use on outpost.
if (HasComp<ProtectedGridComponent>(gridUid))
{
_popup.PopupClient(Loc.GetString("rcd-component-use-blocked"), uid, args.User);
return false;
}

// Frontier - LinkedShuttleUid requirements to use Shipyard RCD.
if (comp.IsShipyardRCD)
{
if (comp.LinkedShuttleUid == null)
{
_popup.PopupClient(Loc.GetString("rcd-component-no-id-swiped"), uid, args.User);
return false;
}
if (comp.LinkedShuttleUid != gridUid)
{
_popup.PopupClient(Loc.GetString("rcd-component-can-only-build-authorized-ship"), uid, args.User);
return false;
}
}

return true;
}

private void OnDoAfterAttempt(EntityUid uid, RCDComponent comp, DoAfterAttemptEvent<RCDDoAfterEvent> args)
{
// sus client crash why
Expand Down Expand Up @@ -162,14 +253,6 @@ private void OnDoAfter(EntityUid uid, RCDComponent comp, RCDDoAfterEvent args)
var tile = mapGrid.GetTileRef(location);
var snapPos = mapGrid.TileIndicesFor(location);

// I love that this uses entirely separate code to construction and tile placement!!!

var gridUid = mapGrid.Owner;
var ev = new FloorTileAttemptEvent();

if (HasComp<ProtectedGridComponent>(gridUid) || ev.Cancelled) // Frontier - Remove all RCD use on outpost.
return;

GreaseMonk marked this conversation as resolved.
Show resolved Hide resolved
switch (comp.Mode)
{
//Floor mode just needs the tile to be a space tile (subFloor)
Expand Down
4 changes: 3 additions & 1 deletion Content.Shared/Shipyard/Components/ShuttleDeedComponent.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Robust.Shared.GameStates;

namespace Content.Shared.Shipyard.Components;

/// <summary>
/// Tied to an ID card when a ship is purchased. 1 ship per captain.
/// </summary>
[RegisterComponent, Access(typeof(SharedShipyardSystem))]
[RegisterComponent, NetworkedComponent, Access(typeof(SharedShipyardSystem))]
public sealed partial class ShuttleDeedComponent : Component
{
public const int MaxNameLength = 30;
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_NF/research/technologies.ftl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
research-techology-advanced-personal-propulsion = Advanced Personal Propulsion
research-technology-rapid-construction = Rapid Construction
research-technology-hardsuits-basic = Basic Hardsuits
research-technology-hardsuits-specialized = Specialized Hardsuits
research-technology-hardsuits-advanced = Advanced Hardsuits
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## UI
rcd-component-missing-id-deed = No ship registered to this ID
rcd-component-can-only-build-authorized-ship = Can only build on authorized ships!
rcd-component-no-id-swiped = Swipe id card on RCD to authorize.
rcd-component-use-blocked = The RCD whirrs, but nothing happens.
rcd-component-id-card-accepted = You swipe the id card and the RCD makes a accepting noise.
rcd-component-id-card-removed = The RCD powers down, unauthorizing it.
rcd-component-wrong-ammo-type = Wrong type of RCD ammo.
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@
GeigerCounter: 10 # Frontier
PowerCellMedium: 15
# NetworkConfigurator: 15
ShipyardRCD: 10
ShipyardRCDAmmo: 20
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Structures/Machines/lathe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@
- AnomalyLocatorWide
- RCD
- RCDAmmo
- ShipyardRCD # Frontier
- ShipyardRCDAmmo # Frontier
- Scalpel
- Retractor
- Cautery
Expand Down
13 changes: 13 additions & 0 deletions Resources/Prototypes/Research/industrial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,16 @@
- PowerCellMicroreactor
technologyPrerequisites:
- AdvancedPowercells

- type: technology
id: RapidConstruction
name: research-technology-rapid-construction
icon:
sprite: Objects/Tools/rcd.rsi
state: icon
discipline: Industrial
tier: 2
cost: 10000
recipeUnlocks:
- ShipyardRCD
- ShipyardRCDAmmo
37 changes: 37 additions & 0 deletions Resources/Prototypes/_NF/Entities/Objects/Tools/shipyard_rcd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- type: entity
name: Shipyard RCD
parent: BaseItem
id: ShipyardRCD
description: An advanced construction device which can place/remove walls, floors, and airlocks quickly. It has a slot to swipe ID cards.
components:
- type: RCD
isShipyardRCD: true
- type: LimitedCharges
maxCharges: 5
charges: 5
- type: UseDelay
- type: Sprite
sprite: Objects/Tools/rcd.rsi
state: icon-shipyard
- type: Item
size: Normal
- type: Clothing
sprite: Objects/Tools/rcd.rsi
quickEquip: false
slots:
- Belt
- type: PhysicalComposition
materialComposition:
Steel: 5000
Plastic: 1000
- type: StaticPrice
price: 500

- type: entity
id: ShipyardRCDEmpty
parent: ShipyardRCD
suffix: Empty
components:
- type: LimitedCharges
maxCharges: 5
charges: 0
18 changes: 18 additions & 0 deletions Resources/Prototypes/_NF/Recipes/Lathes/devices.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,21 @@
Glass: 500
Plastic: 50
Gold: 100

- type: latheRecipe
id: ShipyardRCD
result: ShipyardRCDEmpty
category: Tools
completetime: 4
materials:
Steel: 1000
Plastic: 300

- type: latheRecipe
id: ShipyardRCDAmmo
result: ShipyardRCDAmmo
category: Tools
completetime: 2.4
materials:
Steel: 500
Plastic: 250
20 changes: 20 additions & 0 deletions Resources/Prototypes/_NF/Recipes/Lathes/tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- type: entity
name: Shipyard RCD Ammo
parent: BaseItem
id: ShipyardRCDAmmo
description: Ammo cartridge for a Shipyard RCD.
components:
- type: RCDAmmo
isShipyardRCDAmmo: true
- type: Sprite
sprite: Objects/Tools/rcd.rsi
state: ammo-shipyard
- type: Item
sprite: Objects/Tools/rcd.rsi
heldPrefix: ammo-shipyard
- type: PhysicalComposition
materialComposition:
Steel: 1000
Plastic: 1000
- type: StaticPrice
price: 100
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading