Skip to content

Commit

Permalink
cryo action
Browse files Browse the repository at this point in the history
  • Loading branch information
MiraHell committed Jul 26, 2024
1 parent 1d9bec2 commit c424b61
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 10 deletions.
8 changes: 8 additions & 0 deletions Content.Server/Bed/Cryostorage/CryostorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public override void Initialize()

SubscribeLocalEvent<CryostorageComponent, BeforeActivatableUIOpenEvent>(OnBeforeUIOpened);
SubscribeLocalEvent<CryostorageComponent, CryostorageRemoveItemBuiMessage>(OnRemoveItemBuiMessage);
SubscribeLocalEvent<CryostorageComponent, CryopodGhostActionEvent>(OnCryopodLeaveAction);

SubscribeLocalEvent<CryostorageContainedComponent, PlayerSpawnCompleteEvent>(OnPlayerSpawned);
SubscribeLocalEvent<CryostorageContainedComponent, MindRemovedMessage>(OnMindRemoved);
Expand Down Expand Up @@ -373,4 +374,11 @@ public override void Update(float frameTime)
return null;
}
// end 220 cryo department record
// start 220 cryo action
public void OnCryopodLeaveAction(Entity<CryostorageComponent> ent, ref CryopodGhostActionEvent args)
{
if (TryComp<CryostorageContainedComponent>(args.Performer, out var contained))
contained.GracePeriodEndTime = Timing.CurTime;
}
// start 220 cryo action
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private bool TryTeleportToCryo(EntityUid target, EntityUid cryopodUid, string te
if (TryComp<AmbientSoundComponent>(portal, out var ambientSoundComponent))
_audioSystem.PlayPvs(ambientSoundComponent.Sound, portal);

var doAfterArgs = new DoAfterArgs(EntityManager, target, TimeSpan.FromSeconds(4f),
var doAfterArgs = new DoAfterArgs(EntityManager, target, TimeSpan.FromSeconds(4),
new TeleportToCryoFinished(GetNetEntity(portal)), cryopodUid)
{
BreakOnDamage = false,
Expand All @@ -170,7 +170,7 @@ private void HandleTeleportFinished(Entity<CryostorageComponent> ent, ref Telepo
}

if (TryComp<CryostorageContainedComponent>(args.User, out var contained))
contained.GracePeriodEndTime = _gameTiming.CurTime + TimeSpan.FromSeconds(5f);
contained.GracePeriodEndTime = _gameTiming.CurTime + TimeSpan.FromSeconds(1);

var portalEntity = GetEntity(args.PortalId);

Expand Down
20 changes: 16 additions & 4 deletions Content.Shared/Bed/Cryostorage/CryostorageComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
using Robust.Shared.Prototypes;

namespace Content.Shared.Bed.Cryostorage;

Expand Down Expand Up @@ -41,13 +42,24 @@ public sealed partial class CryostorageComponent : Component
/// </summary>
[DataField]
public SoundSpecifier? RemoveSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg");
// start 220 teleport to cryo

// start 220 cryo

/// <summary>
/// ID of teleport portal, that will spawn on TryTeleportToCryo
/// ProtoId of teleport portal, that will spawn on TryTeleportToCryo
/// </summary>
[DataField, ViewVariables(VVAccess.ReadWrite)]
public string TeleportPortralID = "CryoStoragePortal";
// end 220 teleport to cryo
public EntProtoId TeleportPortralID = "CryoStoragePortal";

/// <summary>
/// ProtoId of ghost action
/// </summary>
[DataField]
public EntProtoId LeaveActionID = "ActionCryoGhost";

[DataField]
public EntityUid? LeaveActionUid;
// end 220 cryo
}

[Serializable, NetSerializable]
Expand Down
12 changes: 10 additions & 2 deletions Content.Shared/Bed/Cryostorage/SharedCryostorageSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Timing;
using Content.Shared.Actions;

namespace Content.Shared.Bed.Cryostorage;

Expand All @@ -24,6 +25,7 @@ public abstract class SharedCryostorageSystem : EntitySystem
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] protected readonly SharedMindSystem Mind = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;

protected EntityUid? PausedMap { get; private set; }

Expand Down Expand Up @@ -53,7 +55,7 @@ private void OnCvarChanged(bool value)

protected virtual void OnInsertedContainer(Entity<CryostorageComponent> ent, ref EntInsertedIntoContainerMessage args)
{
var (_, comp) = ent;
var (uid, comp) = ent;
if (args.Container.ID != comp.ContainerId)
return;

Expand All @@ -62,6 +64,7 @@ protected virtual void OnInsertedContainer(Entity<CryostorageComponent> ent, ref
return;

var containedComp = EnsureComp<CryostorageContainedComponent>(args.Entity);
_actionsSystem.AddAction(args.Entity, ref comp.LeaveActionUid, comp.LeaveActionID, uid); // 220 cryo action
var delay = Mind.TryGetMind(args.Entity, out _, out _) ? comp.GracePeriod : comp.NoMindGracePeriod;
containedComp.GracePeriodEndTime = Timing.CurTime + delay;
containedComp.Cryostorage = ent;
Expand All @@ -73,7 +76,10 @@ private void OnRemovedContainer(Entity<CryostorageComponent> ent, ref EntRemoved
var (_, comp) = ent;
if (args.Container.ID != comp.ContainerId)
return;

// start 220 cryo action
if (comp.LeaveActionUid != null)
_actionsSystem.RemoveAction(args.Entity, comp.LeaveActionUid.Value);
// end 220 cryo action
_appearance.SetData(ent, CryostorageVisuals.Full, args.Container.ContainedEntities.Count > 0);
}

Expand Down Expand Up @@ -178,3 +184,5 @@ public bool IsInPausedMap(Entity<TransformComponent?> entity)
return comp.MapUid != null && comp.MapUid == PausedMap;
}
}


5 changes: 5 additions & 0 deletions Content.Shared/SS220/Cryo/CryoAction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using Content.Shared.Actions;

public sealed partial class CryopodGhostActionEvent : InstantActionEvent
{
}
2 changes: 0 additions & 2 deletions Resources/Locale/ru-RU/actions/actions/cryopodSSD.ftl

This file was deleted.

2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/ss220/actions/cryopod.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
action-name-cryo-ghost = Уйти в крио хранилище
action-desc-cryo-ghost = Вы переходите в наблюдатели без возможности вернуться к своему персонажу.
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,13 @@
- type: AmbientSound
enabled: false
sound: /Audio/Effects/teleport_departure.ogg

- type: entity
id: ActionCryoGhost
name: action-name-cryo-ghost
description: action-desc-cryo-ghost
noSpawn: true
components:
- type: InstantAction
checkCanInteract: false
event: !type:CryopodGhostActionEvent

0 comments on commit c424b61

Please sign in to comment.