-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Добавил автоматический телепорт в криокапсулу профессий.
Signed-off-by: JDtrimble <[email protected]>
- Loading branch information
Showing
45 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
Content.Server/_Sunrise/AutoCryostorage/AutoCryostorageComponent.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Threading; | ||
using Robust.Shared.Audio; | ||
|
||
namespace Content.Server._Sunrise.AutoCryostorage; | ||
|
||
/// <summary> | ||
/// This is used for... | ||
/// </summary> | ||
[RegisterComponent] | ||
public sealed partial class AutoCryostorageComponent : Component | ||
{ | ||
[DataField] | ||
public TimeSpan TransferDelay = TimeSpan.FromSeconds(600); // 600 секунд перед перемещением в крио | ||
|
||
[DataField] | ||
public bool IsCounting = false; | ||
|
||
[DataField] | ||
public string? PortalPrototype = "PortalCryo"; | ||
|
||
[DataField] | ||
public SoundSpecifier? EnterSound = new SoundPathSpecifier("/Audio/Effects/teleport_departure.ogg"); | ||
} |
83 changes: 83 additions & 0 deletions
83
Content.Server/_Sunrise/AutoCryostorage/AutoCryostorageSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using Robust.Shared.Player; | ||
using Robust.Shared.Timing; | ||
using Content.Server.Bed.Cryostorage; | ||
using Content.Shared.Bed.Cryostorage; | ||
using Content.Shared.Mind; | ||
using Content.Shared.Objectives.Systems; | ||
using Robust.Shared.Audio.Systems; | ||
using Timer = Robust.Shared.Timing.Timer; | ||
|
||
namespace Content.Server._Sunrise.AutoCryostorage; | ||
|
||
public sealed class AutoCryostorageSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly CryostorageSystem _cryostorageSystem = default!; | ||
[Dependency] private readonly SharedMindSystem Mind = default!; | ||
[Dependency] private readonly IGameTiming Timing = default!; | ||
[Dependency] private readonly IEntityManager _entMan = default!; | ||
[Dependency] private readonly SharedAudioSystem _audio = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
SubscribeLocalEvent<AutoCryostorageComponent, PlayerAttachedEvent>(OnPlayerAttached); | ||
SubscribeLocalEvent<AutoCryostorageComponent, PlayerDetachedEvent>(OnPlayerDetached); | ||
} | ||
|
||
private void OnPlayerAttached(EntityUid uid, AutoCryostorageComponent comp, PlayerAttachedEvent ev) | ||
{ | ||
if (!comp.IsCounting) | ||
return; | ||
|
||
comp.IsCounting = false; | ||
} | ||
|
||
private void OnPlayerDetached(EntityUid uid, AutoCryostorageComponent comp, PlayerDetachedEvent ev) | ||
{ | ||
if (comp.IsCounting) | ||
return; | ||
|
||
comp.IsCounting = true; | ||
Timer.Spawn(comp.TransferDelay, () => TransferToCryo(uid, comp)); | ||
} | ||
|
||
private void TransferToCryo(EntityUid uid, AutoCryostorageComponent comp) | ||
{ | ||
if (!comp.IsCounting) | ||
return; | ||
|
||
if (!HasComp<TransformComponent>(uid)) | ||
return; | ||
|
||
if (!TryComp<TransformComponent>(uid, out var entityXform)) | ||
return; | ||
|
||
var cryos = AllEntityQuery<CryostorageComponent>(); | ||
var found = false; | ||
while (cryos.MoveNext(out var cryoUid, out var cryoComp)) | ||
{ | ||
if (entityXform.MapUid != Transform(cryoUid).MapUid) | ||
continue; | ||
|
||
_entMan.SpawnEntity(comp.PortalPrototype, entityXform.Coordinates); | ||
_audio.PlayPredicted(comp.EnterSound, entityXform.Coordinates, uid); | ||
|
||
var containedComp = EnsureComp<CryostorageContainedComponent>(uid); | ||
var delay = Mind.TryGetMind(uid, out var mindId, out var mindComp) | ||
? cryoComp.GracePeriod | ||
: cryoComp.NoMindGracePeriod; | ||
containedComp.GracePeriodEndTime = Timing.CurTime + delay; | ||
containedComp.Cryostorage = cryoUid; | ||
var id = mindComp?.UserId ?? containedComp.UserId; | ||
|
||
_cryostorageSystem.HandleEnterCryostorage((uid, containedComp), id); | ||
|
||
cryos.Dispose(); | ||
found = true; | ||
} | ||
|
||
if (!found) | ||
{ | ||
Console.WriteLine($"Haven't found any cryos to insert entity {uid}"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ent-PortalCryo = { ent-BasePortal } | ||
.desc = { ent-BasePortal.desc } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ent-PortalCryo = { ent-BasePortal } | ||
.desc = { ent-BasePortal.desc } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.