Skip to content

Commit

Permalink
Добавил автоматический телепорт в криокапсулу профессий.
Browse files Browse the repository at this point in the history
Signed-off-by: JDtrimble <[email protected]>
  • Loading branch information
pxc1984 committed Jul 4, 2024
1 parent f20858e commit 6463b18
Show file tree
Hide file tree
Showing 45 changed files with 261 additions and 0 deletions.
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 Content.Server/_Sunrise/AutoCryostorage/AutoCryostorageSystem.cs
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}");
}
}
}
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/_sunrise/auto_cryostorage/portal.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-PortalCryo = { ent-BasePortal }
.desc = { ent-BasePortal.desc }
2 changes: 2 additions & 0 deletions Resources/Locale/ru-RU/_sunrise/auto_cryostorage/portal.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ent-PortalCryo = { ent-BasePortal }
.desc = { ent-BasePortal.desc }
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/assistant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
supervisors: job-supervisors-everyone
access:
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: PassengerGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/bartender.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
extendedAccess:
- Kitchen
- Hydroponics
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: BartenderGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/botanist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
extendedAccess:
- Kitchen
- Bar
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: BotanistGear
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/chaplain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo
- type: BibleUser #Lets them heal with bibles

- type: startingGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/chef.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
extendedAccess:
- Hydroponics
- Bar
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: ChefGear
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/clown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
- type: SleepEmitSound
snore: /Audio/Voice/Misc/silly_snore.ogg
interval: 10
- type: AutoCryostorage # Sunrise-Cryo
- !type:AddImplantSpecial
implants: [ SadTromboneImplant ]

Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/janitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
- !type:GiveItemOnHolidaySpecial
holiday: GarbageDay
prototype: WeaponRevolverInspector
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: JanitorGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/lawyer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- Lawyer
- Brig
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: LawyerGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/librarian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
access:
- Service
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: LibrarianGear
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/mime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
components:
- type: MimePowers
- type: FrenchAccent
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: MimeGear
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/musician.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
- !type:GiveItemOnHolidaySpecial
holiday: MikuDay
prototype: BoxPerformer
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: MusicianGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Civilian/service_worker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- Kitchen
extendedAccess:
- Hydroponics
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: ServiceWorkerGear
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Roles/Jobs/Command/captain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- Engineering
- External
- Atmospherics
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: AtmosphericTechnicianGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
- External
extendedAccess:
- Atmospherics
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: StationEngineerGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
- Maintenance
- Engineering
- External
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: TechnicalAssistantGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Medical/chemist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
- Medical
- Chemistry
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: ChemistGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Medical/medical_doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
- Maintenance
extendedAccess:
- Chemistry
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: DoctorGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Medical/medical_intern.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
access:
- Medical
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: MedicalInternGear
Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Medical/paramedic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
- Maintenance
extendedAccess:
- Chemistry
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: ParamedicGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
access:
- Research
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: ResearchAssistantGear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
4 changes: 4 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Science/scientist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
access:
- Research
- Maintenance
special:
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo

- type: startingGear
id: ScientistGear
Expand Down
3 changes: 3 additions & 0 deletions Resources/Prototypes/Roles/Jobs/Security/detective.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
special:
- !type:AddImplantSpecial
implants: [ MindShieldImplant ]
- !type:AddComponentSpecial
components:
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
- !type:AddComponentSpecial
components:
- type: CommandStaff
- type: AutoCryostorage # Sunrise-Cryo
speciesBlacklist:
- Vox

Expand Down
Loading

0 comments on commit 6463b18

Please sign in to comment.