Telepad revival (#16664)

This commit is contained in:
Nemanja
2023-05-21 06:09:31 -04:00
committed by GitHub
parent 8edfedfba5
commit 252f0be372
15 changed files with 196 additions and 128 deletions

View File

@@ -1,10 +0,0 @@
using Content.Shared.Cargo.Components;
using Robust.Shared.GameObjects;
namespace Content.Client.Cargo;
[RegisterComponent]
public sealed class CargoTelepadComponent : SharedCargoTelepadComponent
{
}

View File

@@ -1,4 +1,6 @@
using Content.Shared.Cargo; using Content.Shared.Cargo;
using Content.Shared.Cargo.Components;
using JetBrains.Annotations;
using Robust.Client.Animations; using Robust.Client.Animations;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
@@ -52,47 +54,48 @@ public sealed partial class CargoSystem
private void OnCargoAppChange(EntityUid uid, CargoTelepadComponent component, ref AppearanceChangeEvent args) private void OnCargoAppChange(EntityUid uid, CargoTelepadComponent component, ref AppearanceChangeEvent args)
{ {
OnChangeData(args.Component, args.Sprite); OnChangeData(uid, args.Sprite);
} }
private void OnCargoAnimComplete(EntityUid uid, CargoTelepadComponent component, AnimationCompletedEvent args) private void OnCargoAnimComplete(EntityUid uid, CargoTelepadComponent component, AnimationCompletedEvent args)
{ {
if (!TryComp<AppearanceComponent>(uid, out var appearance)) return; OnChangeData(uid);
OnChangeData(appearance);
} }
private void OnChangeData(AppearanceComponent component, SpriteComponent? sprite = null) private void OnChangeData(EntityUid uid, SpriteComponent? sprite = null)
{ {
if (!Resolve(component.Owner, ref sprite)) if (!Resolve(uid, ref sprite))
return; return;
_appearance.TryGetData<CargoTelepadState?>(component.Owner, CargoTelepadVisuals.State, out var state); _appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state);
AnimationPlayerComponent? player = null; AnimationPlayerComponent? player = null;
switch (state) switch (state)
{ {
case CargoTelepadState.Teleporting: case CargoTelepadState.Teleporting:
if (_player.HasRunningAnimation(component.Owner, TelepadBeamKey)) return; if (_player.HasRunningAnimation(uid, TelepadBeamKey))
_player.Stop(component.Owner, player, TelepadIdleKey); return;
_player.Play(component.Owner, player, CargoTelepadBeamAnimation, TelepadBeamKey); _player.Stop(uid, player, TelepadIdleKey);
_player.Play(uid, player, CargoTelepadBeamAnimation, TelepadBeamKey);
break; break;
case CargoTelepadState.Unpowered: case CargoTelepadState.Unpowered:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, false); sprite.LayerSetVisible(CargoTelepadLayers.Beam, false);
_player.Stop(component.Owner, player, TelepadBeamKey); _player.Stop(uid, player, TelepadBeamKey);
_player.Stop(component.Owner, player, TelepadIdleKey); _player.Stop(uid, player, TelepadIdleKey);
break; break;
default: default:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, true); sprite.LayerSetVisible(CargoTelepadLayers.Beam, true);
if (_player.HasRunningAnimation(component.Owner, player, TelepadIdleKey) || if (_player.HasRunningAnimation(uid, player, TelepadIdleKey) ||
_player.HasRunningAnimation(component.Owner, player, TelepadBeamKey)) return; _player.HasRunningAnimation(uid, player, TelepadBeamKey))
return;
_player.Play(component.Owner, player, CargoTelepadIdleAnimation, TelepadIdleKey); _player.Play(uid, player, CargoTelepadIdleAnimation, TelepadIdleKey);
break; break;
} }
} }
[UsedImplicitly]
private enum CargoTelepadLayers : byte private enum CargoTelepadLayers : byte
{ {
Base = 0, Base = 0,

View File

@@ -1,40 +0,0 @@
using Content.Server.Cargo.Systems;
using Content.Shared.Cargo;
using Content.Shared.Cargo.Components;
using Content.Shared.MachineLinking;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Cargo.Components
{
/// <summary>
/// Handles teleporting in requested cargo after the specified delay.
/// </summary>
[RegisterComponent, Access(typeof(CargoSystem))]
public sealed class CargoTelepadComponent : SharedCargoTelepadComponent
{
[DataField("delay")]
public float Delay = 45f;
/// <summary>
/// How much time we've accumulated until next teleport.
/// </summary>
[DataField("accumulator")]
public float Accumulator = 0f;
[ViewVariables]
public CargoTelepadState CurrentState = CargoTelepadState.Unpowered;
[DataField("teleportSound")] public SoundSpecifier TeleportSound = new SoundPathSpecifier("/Audio/Machines/phasein.ogg");
/// <summary>
/// The paper-type prototype to spawn with the order information.
/// </summary>
[DataField("printerOutput", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string PrinterOutput = "PaperCargoInvoice";
[DataField("receiverPort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>))]
public string ReceiverPort = "OrderReceiver";
}
}

View File

@@ -1,13 +1,12 @@
using Content.Server.Cargo.Systems;
using Content.Server.Cargo.Components; using Content.Server.Cargo.Components;
using Content.Server.Labels.Components; using Content.Server.Construction;
using Content.Server.Paper; using Content.Server.Paper;
using Content.Server.Power.Components; using Content.Server.Power.Components;
using Content.Shared.Cargo; using Content.Shared.Cargo;
using Content.Shared.Cargo.Prototypes; using Content.Shared.Cargo.Components;
using Content.Shared.DeviceLinking;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Collections; using Robust.Shared.Utility;
using Robust.Shared.Player;
namespace Content.Server.Cargo.Systems; namespace Content.Server.Cargo.Systems;
@@ -19,22 +18,32 @@ public sealed partial class CargoSystem
private void InitializeTelepad() private void InitializeTelepad()
{ {
SubscribeLocalEvent<CargoTelepadComponent, ComponentInit>(OnInit); SubscribeLocalEvent<CargoTelepadComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<CargoTelepadComponent, RefreshPartsEvent>(OnRefreshParts);
SubscribeLocalEvent<CargoTelepadComponent, UpgradeExamineEvent>(OnUpgradeExamine);
SubscribeLocalEvent<CargoTelepadComponent, PowerChangedEvent>(OnTelepadPowerChange); SubscribeLocalEvent<CargoTelepadComponent, PowerChangedEvent>(OnTelepadPowerChange);
// Shouldn't need re-anchored event // Shouldn't need re-anchored event
SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange); SubscribeLocalEvent<CargoTelepadComponent, AnchorStateChangedEvent>(OnTelepadAnchorChange);
} }
private void UpdateTelepad(float frameTime) private void UpdateTelepad(float frameTime)
{ {
foreach (var comp in EntityManager.EntityQuery<CargoTelepadComponent>()) var query = EntityQueryEnumerator<CargoTelepadComponent>();
while (query.MoveNext(out var uid, out var comp))
{ {
// Don't EntityQuery for it as it's not required. // Don't EntityQuery for it as it's not required.
TryComp<AppearanceComponent>(comp.Owner, out var appearance); TryComp<AppearanceComponent>(uid, out var appearance);
if (comp.CurrentState == CargoTelepadState.Unpowered) if (comp.CurrentState == CargoTelepadState.Unpowered)
{ {
comp.CurrentState = CargoTelepadState.Idle; comp.CurrentState = CargoTelepadState.Idle;
_appearance.SetData(comp.Owner, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance); _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance);
comp.Accumulator = comp.Delay;
continue;
}
if (!TryComp<DeviceLinkSinkComponent>(uid, out var sinkComponent) ||
sinkComponent.LinkedSources.FirstOrNull() is not { } console ||
!HasComp<CargoOrderConsoleComponent>(console))
{
comp.Accumulator = comp.Delay; comp.Accumulator = comp.Delay;
continue; continue;
} }
@@ -45,11 +54,11 @@ public sealed partial class CargoSystem
if (comp.Accumulator > 0f) if (comp.Accumulator > 0f)
{ {
comp.CurrentState = CargoTelepadState.Idle; comp.CurrentState = CargoTelepadState.Idle;
_appearance.SetData(comp.Owner, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance); _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance);
continue; continue;
} }
var station = _station.GetOwningStation(comp.Owner); var station = _station.GetOwningStation(console);
if (!TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) || if (!TryComp<StationCargoOrderDatabaseComponent>(station, out var orderDatabase) ||
orderDatabase.Orders.Count == 0) orderDatabase.Orders.Count == 0)
@@ -58,14 +67,14 @@ public sealed partial class CargoSystem
continue; continue;
} }
var xform = Transform(comp.Owner); var xform = Transform(uid);
if(FulfillOrder(orderDatabase, xform.Coordinates,comp.PrinterOutput)) if (FulfillOrder(orderDatabase, xform.Coordinates,comp.PrinterOutput))
{ {
_audio.PlayPvs(_audio.GetSound(comp.TeleportSound), comp.Owner, AudioParams.Default.WithVolume(-8f)); _audio.PlayPvs(_audio.GetSound(comp.TeleportSound), uid, AudioParams.Default.WithVolume(-8f));
UpdateOrders(orderDatabase); UpdateOrders(orderDatabase);
comp.CurrentState = CargoTelepadState.Teleporting; comp.CurrentState = CargoTelepadState.Teleporting;
_appearance.SetData(comp.Owner, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance); _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance);
} }
comp.Accumulator += comp.Delay; comp.Accumulator += comp.Delay;
@@ -77,29 +86,42 @@ public sealed partial class CargoSystem
_linker.EnsureSinkPorts(uid, telepad.ReceiverPort); _linker.EnsureSinkPorts(uid, telepad.ReceiverPort);
} }
private void SetEnabled(CargoTelepadComponent component, ApcPowerReceiverComponent? receiver = null, private void OnRefreshParts(EntityUid uid, CargoTelepadComponent component, RefreshPartsEvent args)
{
var rating = args.PartRatings[component.MachinePartTeleportDelay] - 1;
component.Delay = component.BaseDelay * MathF.Pow(component.PartRatingTeleportDelay, rating);
}
private void OnUpgradeExamine(EntityUid uid, CargoTelepadComponent component, UpgradeExamineEvent args)
{
args.AddPercentageUpgrade("cargo-telepad-delay-upgrade", component.Delay / component.BaseDelay);
}
private void SetEnabled(EntityUid uid, CargoTelepadComponent component, ApcPowerReceiverComponent? receiver = null,
TransformComponent? xform = null) TransformComponent? xform = null)
{ {
// False due to AllCompsOneEntity test where they may not have the powerreceiver. // False due to AllCompsOneEntity test where they may not have the powerreceiver.
if (!Resolve(component.Owner, ref receiver, ref xform, false)) return; if (!Resolve(uid, ref receiver, ref xform, false))
return;
var disabled = !receiver.Powered || !xform.Anchored; var disabled = !receiver.Powered || !xform.Anchored;
// Setting idle state should be handled by Update(); // Setting idle state should be handled by Update();
if (disabled) return; if (disabled)
return;
TryComp<AppearanceComponent>(component.Owner, out var appearance); TryComp<AppearanceComponent>(uid, out var appearance);
component.CurrentState = CargoTelepadState.Unpowered; component.CurrentState = CargoTelepadState.Unpowered;
_appearance.SetData(component.Owner, CargoTelepadVisuals.State, CargoTelepadState.Unpowered, appearance); _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Unpowered, appearance);
} }
private void OnTelepadPowerChange(EntityUid uid, CargoTelepadComponent component, ref PowerChangedEvent args) private void OnTelepadPowerChange(EntityUid uid, CargoTelepadComponent component, ref PowerChangedEvent args)
{ {
SetEnabled(component); SetEnabled(uid, component);
} }
private void OnTelepadAnchorChange(EntityUid uid, CargoTelepadComponent component, ref AnchorStateChangedEvent args) private void OnTelepadAnchorChange(EntityUid uid, CargoTelepadComponent component, ref AnchorStateChangedEvent args)
{ {
SetEnabled(component); SetEnabled(uid, component);
} }
} }

View File

@@ -1,6 +1,60 @@
using Content.Shared.Construction.Prototypes;
using Content.Shared.MachineLinking;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Cargo.Components; namespace Content.Shared.Cargo.Components;
public abstract class SharedCargoTelepadComponent : Component /// <summary>
/// Handles teleporting in requested cargo after the specified delay.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(SharedCargoSystem))]
public sealed class CargoTelepadComponent : Component
{ {
/// <summary>
/// The base amount of time it takes to teleport from the telepad
/// </summary>
[DataField("baseDelay"), ViewVariables(VVAccess.ReadWrite)]
public float BaseDelay = 45f;
/// <summary>
/// The actual amount of time it takes to teleport from the telepad
/// </summary>
[DataField("delay"), ViewVariables(VVAccess.ReadWrite)]
public float Delay = 45f;
/// <summary>
/// The machine part that affects <see cref="Delay"/>
/// </summary>
[DataField("machinePartTeleportDelay", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>)), ViewVariables(VVAccess.ReadWrite)]
public string MachinePartTeleportDelay = "Capacitor";
/// <summary>
/// A multiplier applied to <see cref="Delay"/> for each level of <see cref="MachinePartTeleportDelay"/>
/// </summary>
[DataField("partRatingTeleportDelay"), ViewVariables(VVAccess.ReadWrite)]
public float PartRatingTeleportDelay = 0.8f;
/// <summary>
/// How much time we've accumulated until next teleport.
/// </summary>
[DataField("accumulator"), ViewVariables(VVAccess.ReadWrite)]
public float Accumulator;
[DataField("currentState")]
public CargoTelepadState CurrentState = CargoTelepadState.Unpowered;
[DataField("teleportSound")]
public SoundSpecifier TeleportSound = new SoundPathSpecifier("/Audio/Machines/phasein.ogg");
/// <summary>
/// The paper-type prototype to spawn with the order information.
/// </summary>
[DataField("printerOutput", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>)), ViewVariables(VVAccess.ReadWrite)]
public string PrinterOutput = "PaperCargoInvoice";
[DataField("receiverPort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>)), ViewVariables(VVAccess.ReadWrite)]
public string ReceiverPort = "OrderReceiver";
} }

View File

@@ -43,3 +43,5 @@ cargo-shuttle-console-station-unknown = Unknown
cargo-shuttle-console-shuttle-not-found = Not found cargo-shuttle-console-shuttle-not-found = Not found
cargo-shuttle-console-organics = Detected organic lifeforms on the shuttle cargo-shuttle-console-organics = Detected organic lifeforms on the shuttle
cargo-no-shuttle = No cargo shuttle found! cargo-no-shuttle = No cargo shuttle found!
cargo-telepad-delay-upgrade = Teleport delay

View File

@@ -50,4 +50,4 @@ research-technology-advanced-cleaning = Advanced Cleaning
research-technology-meat-manipulation = Meat Manipulation research-technology-meat-manipulation = Meat Manipulation
research-technology-honk-mech = H.O.N.K. Mech research-technology-honk-mech = H.O.N.K. Mech
research-technology-advanced-spray = Advanced Spray research-technology-advanced-spray = Advanced Spray
research-technology-bluespace-cargo-transport = Bluespace Cargo Transport

View File

@@ -775,6 +775,21 @@
DefaultPrototype: Beaker DefaultPrototype: Beaker
ExamineName: Glass Beaker ExamineName: Glass Beaker
- type: entity
id: CargoTelepadMachineCircuitboard
parent: BaseMachineCircuitboard
name: cargo telepad machine board
description: A machine printed circuit board for a cargo telepad.
components:
- type: Sprite
state: supply
- type: MachineBoard
prototype: CargoTelepad
requirements:
Capacitor: 2
materialRequirements:
Steel: 5
- type: entity - type: entity
id: SodaDispenserMachineCircuitboard id: SodaDispenserMachineCircuitboard
parent: BaseMachineCircuitboard parent: BaseMachineCircuitboard

View File

@@ -673,6 +673,15 @@
color: "#b89f25" color: "#b89f25"
- type: AccessReader - type: AccessReader
access: [["Cargo"]] access: [["Cargo"]]
- type: DeviceNetwork
deviceNetId: Wireless
receiveFrequencyId: BasicDevice
- type: WirelessNetworkConnection
range: 200
- type: DeviceLinkSource
range: 200
ports:
- OrderSender
- type: entity - type: entity
parent: BaseComputer parent: BaseComputer

View File

@@ -308,6 +308,7 @@
- StasisBedMachineCircuitboard - StasisBedMachineCircuitboard
- MaterialReclaimerMachineCircuitboard - MaterialReclaimerMachineCircuitboard
- OreProcessorMachineCircuitboard - OreProcessorMachineCircuitboard
- CargoTelepadMachineCircuitboard
- RipleyCentralElectronics - RipleyCentralElectronics
- RipleyPeripheralsElectronics - RipleyPeripheralsElectronics
- HonkerCentralElectronics - HonkerCentralElectronics

View File

@@ -1,7 +1,8 @@
- type: entity - type: entity
id: CargoTelepad id: CargoTelepad
parent: BaseStructureDynamic parent: [ BaseMachinePowered, ConstructibleMachine ]
name: cargo telepad name: cargo telepad
description: Beam in the pizzas and dig in.
components: components:
- type: InteractionOutline - type: InteractionOutline
- type: Physics - type: Physics
@@ -20,7 +21,6 @@
mask: mask:
- MachineMask - MachineMask
- type: Sprite - type: Sprite
netsync: false
sprite: Structures/cargo_telepad.rsi sprite: Structures/cargo_telepad.rsi
drawdepth: FloorObjects drawdepth: FloorObjects
layers: layers:
@@ -40,22 +40,10 @@
- type: DeviceLinkSink - type: DeviceLinkSink
ports: ports:
- OrderReceiver - OrderReceiver
- type: Destructible
thresholds:
- trigger:
!type:DamageTrigger
damage: 75
behaviors:
- !type:SpawnEntitiesBehavior
spawn:
SheetSteel1:
min: 1
max: 1
- !type:DoActsBehavior
acts: [ "Destruction" ]
- type: ApcPowerReceiver - type: ApcPowerReceiver
powerLoad: 1000 # TODO if we keep this make it spike power draw when teleporting powerLoad: 1000 # TODO if we keep this make it spike power draw when teleporting
- type: ExtensionCableReceiver
- type: CargoTelepad - type: CargoTelepad
- type: Machine
board: CargoTelepadMachineCircuitboard
- type: Appearance - type: Appearance
- type: CollideOnAnchor - type: CollideOnAnchor

View File

@@ -563,6 +563,15 @@
Steel: 100 Steel: 100
Glass: 900 Glass: 900
- type: latheRecipe
id: CargoTelepadMachineCircuitboard
result: CargoTelepadMachineCircuitboard
completetime: 4
materials:
Steel: 100
Glass: 900
Gold: 100
- type: latheRecipe - type: latheRecipe
id: SodaDispenserMachineCircuitboard id: SodaDispenserMachineCircuitboard
result: SodaDispenserMachineCircuitboard result: SodaDispenserMachineCircuitboard

View File

@@ -74,6 +74,20 @@
- SurveillanceWirelessCameraMonitorCircuitboard - SurveillanceWirelessCameraMonitorCircuitboard
- TelecomServerCircuitboard - TelecomServerCircuitboard
- type: technology
id: AdvancedEntertainment
name: research-technology-advanced-entertainment
icon:
sprite: Structures/Machines/computers.rsi
state: television
discipline: CivilianServices
tier: 1
cost: 7500
recipeUnlocks:
- ComputerTelevisionCircuitboard
- SynthesizerInstrument
- DawInstrumentMachineCircuitboard
# Tier 2 # Tier 2
- type: technology - type: technology
@@ -123,22 +137,6 @@
- HonkerTargetingElectronics - HonkerTargetingElectronics
- MechEquipmentHorn - MechEquipmentHorn
- type: technology
id: AdvancedEntertainment
name: research-technology-advanced-entertainment
icon:
sprite: Structures/Machines/computers.rsi
state: television
discipline: CivilianServices
tier: 2
cost: 7500
recipeUnlocks:
- ComputerTelevisionCircuitboard
- SynthesizerInstrument
- DawInstrumentMachineCircuitboard
# Tier 3
- type: technology - type: technology
id: AdvancedSpray id: AdvancedSpray
name: research-technology-advanced-spray name: research-technology-advanced-spray
@@ -146,8 +144,22 @@
sprite: Objects/Weapons/Guns/Basic/spraynozzle.rsi sprite: Objects/Weapons/Guns/Basic/spraynozzle.rsi
state: icon state: icon
discipline: CivilianServices discipline: CivilianServices
tier: 3 tier: 2
cost: 15000 cost: 10000
recipeUnlocks: recipeUnlocks:
- WeaponSprayNozzle - WeaponSprayNozzle
- ClothingBackpackWaterTank - ClothingBackpackWaterTank
# Tier 3
- type: technology
id: BluespaceCargoTransport
name: research-technology-bluespace-cargo-transport
icon:
sprite: Structures/cargo_telepad.rsi
state: display
discipline: CivilianServices
tier: 3
cost: 15000
recipeUnlocks:
- CargoTelepadMachineCircuitboard

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

View File

@@ -32,6 +32,9 @@
}, },
{ {
"name": "offline" "name": "offline"
},
{
"name": "display"
} }
] ]
} }