- add: Time beacon. (#254)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
namespace Content.Server._White.TimeBeacon;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class TimeBeaconAnchorComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public EntityUid Entity = EntityUid.Invalid;
|
||||
|
||||
[DataField]
|
||||
public TimeSpan Duration = TimeSpan.FromSeconds(10);
|
||||
}
|
||||
20
Content.Server/_White/TimeBeacon/TimeBeaconComponent.cs
Normal file
20
Content.Server/_White/TimeBeacon/TimeBeaconComponent.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server._White.TimeBeacon;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class TimeBeaconComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public TimeSpan NextUse = TimeSpan.Zero;
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
public TimeSpan Cooldown = TimeSpan.FromSeconds(20);
|
||||
|
||||
[DataField]
|
||||
public EntProtoId AnchorEntity = "TimeBeaconAnchor";
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier Sound = new SoundPathSpecifier("/Audio/Machines/high_tech_confirm.ogg");
|
||||
}
|
||||
104
Content.Server/_White/TimeBeacon/TimeBeaconSystem.cs
Normal file
104
Content.Server/_White/TimeBeacon/TimeBeaconSystem.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Pulling;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Robust.Server.Audio;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server._White.TimeBeacon;
|
||||
|
||||
public sealed class TimeBeaconSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly AudioSystem _audio = default!;
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
[Dependency] private readonly PullingSystem _pulling = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<TimeBeaconComponent, UseInHandEvent>(OnUseInHand);
|
||||
SubscribeLocalEvent<TimeBeaconComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<TimeBeaconAnchorComponent, MapInitEvent>(OnMapInit);
|
||||
}
|
||||
|
||||
private void OnMapInit(Entity<TimeBeaconAnchorComponent> ent, ref MapInitEvent args)
|
||||
{
|
||||
Timer.Spawn(ent.Comp.Duration, () =>
|
||||
{
|
||||
var entity = ent.Comp.Entity;
|
||||
|
||||
if (entity == EntityUid.Invalid)
|
||||
return;
|
||||
|
||||
if (EntityManager.Deleted(ent) || EntityManager.Deleted(entity))
|
||||
return;
|
||||
|
||||
if (!TryComp(ent, out TransformComponent? xform) || !TryComp(entity, out TransformComponent? entXform))
|
||||
return;
|
||||
|
||||
if (xform.MapID != entXform.MapID)
|
||||
return;
|
||||
|
||||
// break pulls before portal enter so we dont break shit
|
||||
if (TryComp<SharedPullableComponent>(entity, out var pullable) && pullable.BeingPulled)
|
||||
{
|
||||
_pulling.TryStopPull(pullable);
|
||||
}
|
||||
|
||||
if (TryComp<SharedPullerComponent>(entity, out var pulling)
|
||||
&& pulling.Pulling != null &&
|
||||
TryComp<SharedPullableComponent>(pulling.Pulling.Value, out var subjectPulling))
|
||||
{
|
||||
_pulling.TryStopPull(subjectPulling);
|
||||
}
|
||||
|
||||
_transform.SetCoordinates(entity, entXform, xform.Coordinates);
|
||||
QueueDel(ent);
|
||||
});
|
||||
}
|
||||
|
||||
private void OnExamine(Entity<TimeBeaconComponent> ent, ref ExaminedEvent args)
|
||||
{
|
||||
if (ent.Comp.NextUse <= _timing.CurTime)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("time-beacon-component-charged"));
|
||||
return;
|
||||
}
|
||||
|
||||
var message = Loc.GetString("time-beacon-component-charging",
|
||||
("cooldown", (int) (ent.Comp.NextUse - _timing.CurTime).TotalSeconds));
|
||||
args.PushMarkup(message);
|
||||
}
|
||||
|
||||
private void OnUseInHand(Entity<TimeBeaconComponent> ent, ref UseInHandEvent args)
|
||||
{
|
||||
var coords = CompOrNull<TransformComponent>(args.User)?.Coordinates;
|
||||
|
||||
if (coords == null)
|
||||
return;
|
||||
|
||||
if (ent.Comp.NextUse > _timing.CurTime)
|
||||
{
|
||||
var message = Loc.GetString("time-beacon-component-cooldown",
|
||||
("cooldown", (int) (ent.Comp.NextUse - _timing.CurTime).TotalSeconds));
|
||||
_popup.PopupEntity(message, args.User, args.User);
|
||||
return;
|
||||
}
|
||||
|
||||
var anchor = Spawn(ent.Comp.AnchorEntity, coords.Value);
|
||||
_transform.AttachToGridOrMap(anchor);
|
||||
var anchorComp = EnsureComp<TimeBeaconAnchorComponent>(anchor);
|
||||
anchorComp.Entity = args.User;
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("time-beacon-component-anchor-set"), args.User, args.User, PopupType.Medium);
|
||||
_audio.PlayEntity(ent.Comp.Sound, args.User, ent);
|
||||
|
||||
ent.Comp.NextUse = _timing.CurTime + ent.Comp.Cooldown;
|
||||
}
|
||||
}
|
||||
10
Resources/Locale/ru-RU/_white/object/time-beacon.ftl
Normal file
10
Resources/Locale/ru-RU/_white/object/time-beacon.ftl
Normal file
@@ -0,0 +1,10 @@
|
||||
ent-TimeBeacon = временной маяк
|
||||
.desc = Перемотка!
|
||||
|
||||
time-beacon-component-charged = Временной маяк [color=darkgreen]заряжен[/color]
|
||||
time-beacon-component-charging = Временной маяк зарядится через [color=fuchsia]{ $cooldown }[/color] секунд.
|
||||
time-beacon-component-cooldown = Временной маяк можно использовать через { $cooldown } секунд.
|
||||
time-beacon-component-anchor-set = Маяк установлен!
|
||||
|
||||
uplink-time-beacon = Временной маяк
|
||||
uplink-time-beacon-desc = Устанавливает маяк при активации. Через 10 секунд телепортирует вас к точке маяка. Время перезарядки составляет 20 секунд.
|
||||
@@ -63,6 +63,17 @@
|
||||
categories:
|
||||
- UplinkAmmo
|
||||
|
||||
- type: listing
|
||||
id: UplinkTimeBeacon
|
||||
name: uplink-time-beacon
|
||||
description: uplink-time-beacon-desc
|
||||
productEntity: TimeBeacon
|
||||
icon: { sprite: Objects/Devices/door_remote.rsi, state: door_remotebase_white }
|
||||
cost:
|
||||
Telecrystal: 2
|
||||
categories:
|
||||
- UplinkUtility
|
||||
|
||||
- type: listing
|
||||
id: UplinkSmokeImplanter
|
||||
name: Имплант дыма
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
- type: entity
|
||||
parent: BaseItem
|
||||
id: TimeBeacon
|
||||
name: time beacon
|
||||
description: Rewind!
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Devices/door_remote.rsi
|
||||
layers:
|
||||
- state: door_remotebase_white
|
||||
- state: door_remotelightscolour
|
||||
color: "#00FFF7"
|
||||
- state: door_remotescreencolour
|
||||
color: "#00FFF7"
|
||||
- type: Item
|
||||
storedRotation: -90
|
||||
- type: TimeBeacon
|
||||
|
||||
- type: entity
|
||||
id: TimeBeaconAnchor
|
||||
name: time beacon anchor
|
||||
description: Fuck!
|
||||
components:
|
||||
- type: TimeBeaconAnchor
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 717 B |
@@ -10,6 +10,9 @@
|
||||
{
|
||||
"name": "door_remotebase"
|
||||
},
|
||||
{
|
||||
"name": "door_remotebase_white"
|
||||
},
|
||||
{
|
||||
"name": "door_remotelightscolour"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user