Skip to content

Commit

Permalink
Merge pull request #1399 from AftrLite/porter-vfx
Browse files Browse the repository at this point in the history
Fixes/Updates the VFX for Mailporter, Cargoporter
  • Loading branch information
kipdotnet authored Jan 17, 2025
2 parents 128dc71 + aee139e commit 22bb96b
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 115 deletions.
162 changes: 81 additions & 81 deletions Content.Client/Cargo/Systems/CargoSystem.Telepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,98 +7,98 @@

namespace Content.Client.Cargo.Systems;

public sealed partial class CargoSystem
public sealed partial class CargoSystem //imp edit to remove default visuals
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
// [Dependency] private readonly SharedAppearanceSystem _appearance = default!;

private static readonly Animation CargoTelepadBeamAnimation = new()
{
Length = TimeSpan.FromSeconds(0.5),
AnimationTracks =
{
new AnimationTrackSpriteFlick
{
LayerKey = CargoTelepadLayers.Beam,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(new RSI.StateId("beam"), 0f)
}
}
}
};
// private static readonly Animation CargoTelepadBeamAnimation = new()
// {
// Length = TimeSpan.FromSeconds(0.5),
// AnimationTracks =
// {
// new AnimationTrackSpriteFlick
// {
// LayerKey = CargoTelepadLayers.Beam,
// KeyFrames =
// {
// new AnimationTrackSpriteFlick.KeyFrame(new RSI.StateId("beam"), 0f)
// }
// }
// }
// };

private static readonly Animation CargoTelepadIdleAnimation = new()
{
Length = TimeSpan.FromSeconds(2.8), //imp edit for fancy sprite, old is 0.8
AnimationTracks =
{
new AnimationTrackSpriteFlick
{
LayerKey = CargoTelepadLayers.Beam,
KeyFrames =
{
new AnimationTrackSpriteFlick.KeyFrame(new RSI.StateId("idle"), 0f)
}
}
}
};
// private static readonly Animation CargoTelepadIdleAnimation = new()
// {
// Length = TimeSpan.FromSeconds(2.8), //imp edit for fancy sprite, old is 0.8
// AnimationTracks =
// {
// new AnimationTrackSpriteFlick
// {
// LayerKey = CargoTelepadLayers.Beam,
// KeyFrames =
// {
// new AnimationTrackSpriteFlick.KeyFrame(new RSI.StateId("idle"), 0f)
// }
// }
// }
// };

private const string TelepadBeamKey = "cargo-telepad-beam";
private const string TelepadIdleKey = "cargo-telepad-idle";
// private const string TelepadBeamKey = "cargo-telepad-beam";
// private const string TelepadIdleKey = "cargo-telepad-idle";

private void InitializeCargoTelepad()
{
SubscribeLocalEvent<CargoTelepadComponent, AppearanceChangeEvent>(OnCargoAppChange);
SubscribeLocalEvent<CargoTelepadComponent, AnimationCompletedEvent>(OnCargoAnimComplete);
}
// private void InitializeCargoTelepad()
// {
// SubscribeLocalEvent<CargoTelepadComponent, AppearanceChangeEvent>(OnCargoAppChange);
// SubscribeLocalEvent<CargoTelepadComponent, AnimationCompletedEvent>(OnCargoAnimComplete);
// }

private void OnCargoAppChange(EntityUid uid, CargoTelepadComponent component, ref AppearanceChangeEvent args)
{
OnChangeData(uid, args.Sprite);
}
// private void OnCargoAppChange(EntityUid uid, CargoTelepadComponent component, ref AppearanceChangeEvent args)
// {
// OnChangeData(uid, args.Sprite);
// }

private void OnCargoAnimComplete(EntityUid uid, CargoTelepadComponent component, AnimationCompletedEvent args)
{
OnChangeData(uid);
}
// private void OnCargoAnimComplete(EntityUid uid, CargoTelepadComponent component, AnimationCompletedEvent args)
// {
// OnChangeData(uid);
// }

private void OnChangeData(EntityUid uid, SpriteComponent? sprite = null)
{
if (!Resolve(uid, ref sprite))
return;
// private void OnChangeData(EntityUid uid, SpriteComponent? sprite = null)
// {
// if (!Resolve(uid, ref sprite))
// return;

_appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state);
AnimationPlayerComponent? player = null;
// _appearance.TryGetData<CargoTelepadState?>(uid, CargoTelepadVisuals.State, out var state);
// AnimationPlayerComponent? player = null;

switch (state)
{
case CargoTelepadState.Teleporting:
if (_player.HasRunningAnimation(uid, TelepadBeamKey))
return;
_player.Stop(uid, player, TelepadIdleKey);
_player.Play(uid, player, CargoTelepadBeamAnimation, TelepadBeamKey);
break;
case CargoTelepadState.Unpowered:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, false);
_player.Stop(uid, player, TelepadBeamKey);
_player.Stop(uid, player, TelepadIdleKey);
break;
default:
sprite.LayerSetVisible(CargoTelepadLayers.Beam, true);
// switch (state)
// {
// case CargoTelepadState.Teleporting:
// if (_player.HasRunningAnimation(uid, TelepadBeamKey))
// return;
// _player.Stop(uid, player, TelepadIdleKey);
// _player.Play(uid, player, CargoTelepadBeamAnimation, TelepadBeamKey);
// break;
// case CargoTelepadState.Unpowered:
// sprite.LayerSetVisible(CargoTelepadLayers.Beam, false);
// _player.Stop(uid, player, TelepadBeamKey);
// _player.Stop(uid, player, TelepadIdleKey);
// break;
// default:
// sprite.LayerSetVisible(CargoTelepadLayers.Beam, true);

if (_player.HasRunningAnimation(uid, player, TelepadIdleKey) ||
_player.HasRunningAnimation(uid, player, TelepadBeamKey))
return;
// if (_player.HasRunningAnimation(uid, player, TelepadIdleKey) ||
// _player.HasRunningAnimation(uid, player, TelepadBeamKey))
// return;

_player.Play(uid, player, CargoTelepadIdleAnimation, TelepadIdleKey);
break;
}
}
// _player.Play(uid, player, CargoTelepadIdleAnimation, TelepadIdleKey);
// break;
// }
// }

[UsedImplicitly]
private enum CargoTelepadLayers : byte
{
Base = 0,
Beam = 1,
}
// [UsedImplicitly]
// private enum CargoTelepadLayers : byte
// {
// Base = 0,
// Beam = 1,
// }
}
2 changes: 1 addition & 1 deletion Content.Client/Cargo/Systems/CargoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public sealed partial class CargoSystem : SharedCargoSystem
public override void Initialize()
{
base.Initialize();
InitializeCargoTelepad();
// InitializeCargoTelepad(); #imp edit to remove default visuals
}
}
11 changes: 6 additions & 5 deletions Content.Server/Cargo/Systems/CargoSystem.Telepad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private void UpdateTelepad(float frameTime)
if (comp.CurrentState == CargoTelepadState.Unpowered)
{
comp.CurrentState = CargoTelepadState.Idle;
_appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance);
// _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance); #imp edit to remove default visuals
comp.Accumulator = comp.Delay;
continue;
}
Expand All @@ -78,7 +78,7 @@ private void UpdateTelepad(float frameTime)
if (comp.Accumulator > 0f)
{
comp.CurrentState = CargoTelepadState.Idle;
_appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance);
// _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Idle, appearance); #imp edit to remove default visuals
continue;
}

Expand All @@ -99,7 +99,8 @@ private void UpdateTelepad(float frameTime)

comp.CurrentOrders.Remove(currentOrder);
comp.CurrentState = CargoTelepadState.Teleporting;
_appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance);
Spawn(comp.BeamInFx, Transform(uid).Coordinates);
// _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Teleporting, appearance); #imp edit to remove default visuals
}

comp.Accumulator += comp.Delay;
Expand Down Expand Up @@ -147,9 +148,9 @@ private void SetEnabled(EntityUid uid, CargoTelepadComponent component, ApcPower
if (disabled)
return;

TryComp<AppearanceComponent>(uid, out var appearance);
// TryComp<AppearanceComponent>(uid, out var appearance);
component.CurrentState = CargoTelepadState.Unpowered;
_appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Unpowered, appearance);
// _appearance.SetData(uid, CargoTelepadVisuals.State, CargoTelepadState.Unpowered, appearance); #imp edit to remove default visuals
}

private void OnTelepadPowerChange(EntityUid uid, CargoTelepadComponent component, ref PowerChangedEvent args)
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/_DV/Mail/Components/MailTeleporterComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ public sealed partial class MailTeleporterComponent : Component
[DataField]
public SoundSpecifier TeleportSound = new SoundPathSpecifier("/Audio/Effects/teleport_arrival.ogg");
/// <summary>
/// Imp : The SFX spawned when mail teleports in.
/// Imp : The VFX spawned when mail teleports in.
/// </summary>
[DataField]
public EntProtoId BeamInFx = "TelepadBeamInFX";
public EntProtoId BeamInFx = "MailTelepadVFX";
/// <summary>
/// The MailDeliveryPoolPrototype that's used to select what mail this
/// teleporter can deliver.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public sealed partial class CargoTelepadComponent : Component

[DataField("receiverPort", customTypeSerializer: typeof(PrototypeIdSerializer<SinkPortPrototype>)), ViewVariables(VVAccess.ReadWrite)]
public string ReceiverPort = "OrderReceiver";

/// <summary>
/// Imp : The VFX spawned when cargo teleports in.
/// </summary>
[DataField]
public EntProtoId BeamInFx = "CargoTelepadVFX";
}
10 changes: 5 additions & 5 deletions Content.Shared/Cargo/SharedCargoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public enum CargoTelepadState : byte
Teleporting,
};

[Serializable, NetSerializable]
public enum CargoTelepadVisuals : byte
{
State,
};
// [Serializable, NetSerializable] #imp edit to remove default visuals
// public enum CargoTelepadVisuals : byte
// {
// State,
// };
17 changes: 11 additions & 6 deletions Resources/Prototypes/Entities/Structures/cargo_telepad.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@
mask:
- MachineMask
- type: Sprite
sprite: _Impstation/Structures/cargo_telepad.rsi #imp edit
sprite: _Impstation/Structures/cargo_telepad.rsi #imp edits begin
drawdepth: FloorObjects
layers:
- state: offline
map: [ "enum.CargoTelepadLayers.Base" ]
- state: idle
map: [ "enum.CargoTelepadLayers.Beam" ]
shader: unshaded
- state: offline
- state: idle
shader: unshaded
map: ["enum.PowerDeviceVisualLayers.Powered"]
- type: GenericVisualizer
visuals:
enum.PowerDeviceVisuals.Powered:
enum.PowerDeviceVisualLayers.Powered:
True: { visible: true }
False: { visible: false } #imp edits end
- type: Damageable
damageContainer: StructuralInorganic
damageModifierSet: StructuralMetallicStrong
Expand Down
5 changes: 0 additions & 5 deletions Resources/Prototypes/_Impstation/Entities/Effects/base.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
- type: entity
categories: [ HideSpawnMenu ]
id: BaseFXEntity
placement:
mode: SnapgridCenter
components:
- type: Transform
noRot: true
anchored: true
- type: Tag
tags:
- HideContextMenu
54 changes: 44 additions & 10 deletions Resources/Prototypes/_Impstation/Entities/Effects/teleportfx.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,64 @@
- type: entity
parent: BaseFXEntity
categories: [ HideSpawnMenu ]
id: TelepadBeamInFX
id: CargoTelepadVFX
components:
- type: TimedDespawn
lifetime: 0.5
lifetime: 1.2
- type: Sprite
layers:
- sprite: _Impstation/Structures/cargo_telepad.rsi
state: beam
- sprite: _Impstation/Effects/teleportvfx.rsi
offset: "0,0.25"
state: cargovfx
shader: unshaded
netsync: false
drawdepth: Effects
drawdepth: Mobs
- type: PointLight
color: "#FF9719"
radius: 1.5
energy: 2.5
radius: 1.2
energy: 3.5
castShadows: false
- type: LightBehaviour
behaviours:
- !type:FadeBehaviour
interpolate: Linear
minDuration: 0.5
maxDuration: 0.5
minDuration: 1.2
maxDuration: 1.2
startValue: 0.1
endValue: 2
endValue: 3.5
property: Energy
enabled: true
isLooped: true
reverseWhenFinished: true

- type: entity
parent: BaseFXEntity
categories: [ HideSpawnMenu ]
id: MailTelepadVFX
components:
- type: TimedDespawn
lifetime: 1.2
- type: Sprite
layers:
- sprite: _Impstation/Effects/teleportvfx.rsi
offset: "0,0.25"
state: mailvfx
shader: unshaded
netsync: false
drawdepth: Mobs
- type: PointLight
color: "#33c7ff"
radius: 1.2
energy: 3.5
castShadows: false
- type: LightBehaviour
behaviours:
- !type:FadeBehaviour
interpolate: Linear
minDuration: 1.2
maxDuration: 1.2
startValue: 0.1
endValue: 3.5
property: Energy
enabled: true
isLooped: true
Expand Down
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

0 comments on commit 22bb96b

Please sign in to comment.