Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

фикс крио #199

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 21 additions & 77 deletions Content.Server/_Sunrise/CryoTeleport/CryoTeleportSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
using Content.Server.Bed.Cryostorage;
using System.Linq;
using Content.Server.Bed.Cryostorage;
using Content.Server.GameTicking;
using Content.Server.Mind;
using Content.Server.Station.Components;
using Content.Server.Station.Systems;
using Content.Shared.Bed.Cryostorage;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Enums;
using Robust.Shared.Player;
using Robust.Shared.Timing;

Expand All @@ -21,17 +25,14 @@ public sealed class CryoTeleportSystem : EntitySystem
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly IPlayerManager _playerMan = default!;

public TimeSpan NextTick = TimeSpan.Zero;
public TimeSpan RefreshCooldown = TimeSpan.FromSeconds(5);

/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<PlayerSpawnCompleteEvent>(OnCompleteSpawn);
// SubscribeLocalEvent<CryoTeleportTargetComponent, BeingGibbedEvent>(OnGibbed);
SubscribeLocalEvent<CryoTeleportTargetComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<CryoTeleportTargetComponent, PlayerAttachedEvent>(OnPlayerAttached);
_playerMan.PlayerStatusChanged += OnSessionStatus;
}

public override void Update(float delay)
Expand Down Expand Up @@ -96,82 +97,25 @@ private void OnCompleteSpawn(PlayerSpawnCompleteEvent ev)

var cryoTeleportTargetComponent = EnsureComp<CryoTeleportTargetComponent>(ev.Player.AttachedEntity.Value);
cryoTeleportTargetComponent.Station = ev.Station;
cryoTeleportTargetComponent.UserId = ev.Player.UserId;
}

private void OnPlayerDetached(EntityUid uid, CryoTeleportTargetComponent comp, PlayerDetachedEvent ev)
private void OnSessionStatus(object? sender, SessionStatusEventArgs args)
{
comp.ExitTime = _timing.CurTime;
}
if (!TryComp<CryoTeleportTargetComponent>(args.Session.AttachedEntity, out var comp))
return;

private void OnPlayerAttached(EntityUid uid, CryoTeleportTargetComponent comp, PlayerAttachedEvent ev)
{
comp.ExitTime = null;
comp.UserId = ev.Player.UserId;
}
if (args.Session.Status == SessionStatus.Disconnected && comp.ExitTime == null)
{
comp.ExitTime = _timing.CurTime;
}
else if (args.Session.Status == SessionStatus.Connected)
{
comp.ExitTime = null;
}

// private void OnGibbed(EntityUid uid, CryoTeleportTargetComponent comp, BeingGibbedEvent ev)
// {
// if (comp.Station == null)
// return;
//
// if (!TryComp<TransformComponent>(uid, out var entityXform))
// return;
//
// if (!TryComp<StationCryoTeleportComponent>(comp.Station, out var stationCryoTeleportComponent))
// return;
//
// // var stationJobsComponent = Comp<StationJobsComponent>(comp.Station.Value);
// _mind.TryGetMind(uid, out var mindId, out var mindComp);
//
// if (mindComp == null)
// {
// Log.Error($"mindComp null");
// return;
// }
//
// if (mindComp.UserId == null)
// return;
//
// foreach (var uniqueStation in _station.GetStationsSet())
// {
// if (!TryComp<StationJobsComponent>(uniqueStation, out var stationJobs))
// continue;
//
// if (!_stationJobs.TryGetPlayerJobs(uniqueStation, mindComp.UserId.Value, out var jobs, stationJobs))
// continue;
//
// foreach (var job in jobs)
// {
// _stationJobs.TryAdjustJobSlot(uniqueStation, job, 1, clamp: true);
// }
//
// _stationJobs.TryRemovePlayerJobs(uniqueStation, mindComp.UserId.Value, stationJobs);
// }
//
// if (!TryComp<StationRecordsComponent>(comp.Station, out var stationRecords))
// return;
//
// var jobName = Loc.GetString("earlyleave-cryo-job-unknown");
// var recordId = _stationRecords.GetRecordByName(comp.Station.Value, Name(uid));
// if (recordId != null)
// {
// var key = new StationRecordKey(recordId.Value, comp.Station.Value);
// if (_stationRecords.TryGetRecord<GeneralStationRecord>(key, out var entry, stationRecords))
// jobName = entry.JobTitle;
//
// _stationRecords.RemoveRecord(key, stationRecords);
// }
//
// _chat.DispatchStationAnnouncement(comp.Station.Value,
// Loc.GetString(
// "earlyleave-cryo-announcement",
// ("character", Name(uid)),
// ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(jobName))
// ),
// Loc.GetString("earlyleave-cryo-sender"),
// playDefault: false
// );
// }
comp.UserId = args.Session.UserId;
}

private EntityUid? FindCryoStorage(TransformComponent stationGridTransform)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Robust.Shared.Audio;
using Robust.Shared.Network;
using Robust.Shared.Player;

namespace Content.Server._Sunrise.CryoTeleport;

Expand All @@ -9,7 +11,7 @@ namespace Content.Server._Sunrise.CryoTeleport;
public sealed partial class StationCryoTeleportComponent : Component
{
[DataField]
public TimeSpan TransferDelay = TimeSpan.FromSeconds(300); // 5 минут
public TimeSpan TransferDelay = TimeSpan.FromMinutes(5); // 5 минут

[DataField]
public string PortalPrototype = "PortalCryo";
Expand Down
2 changes: 1 addition & 1 deletion Resources/Prototypes/_Sunrise/CryoTeleport/portal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: PortalCryo
components:
- type: Transform
anchored: False
anchored: True
- type: InteractionOutline
- type: Clickable
- type: Physics
Expand Down
Loading