Ремейк атмос голопроектора (#225)
* add: atmos holoprojector remake * add: clean on use * translate
This commit is contained in:
@@ -13,7 +13,10 @@ namespace Content.Server.Holosign
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// How much charge a single use expends.
|
/// How much charge a single use expends.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")]
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||||
public float ChargeUse = 50f;
|
public int Uses = 10;
|
||||||
|
|
||||||
|
[ViewVariables(VVAccess.ReadWrite), DataField]
|
||||||
|
public List<EntityUid?> Signs = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
|
using Content.Server.Popups;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using Content.Shared.Coordinates.Helpers;
|
using Content.Shared.Coordinates.Helpers;
|
||||||
using Content.Server.Power.Components;
|
|
||||||
using Content.Server.PowerCell;
|
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Storage;
|
using Content.Shared.Interaction.Events;
|
||||||
|
using Content.Shared.Popups;
|
||||||
|
|
||||||
namespace Content.Server.Holosign;
|
namespace Content.Server.Holosign;
|
||||||
|
|
||||||
public sealed class HolosignSystem : EntitySystem
|
public sealed class HolosignSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||||
|
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
@@ -18,19 +18,20 @@ public sealed class HolosignSystem : EntitySystem
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
|
SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
|
||||||
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
|
||||||
|
SubscribeLocalEvent<HolosignProjectorComponent, ComponentRemove>(OnComponentRemove);
|
||||||
|
SubscribeLocalEvent<HolosignProjectorComponent, UseInHandEvent>(OnUse);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
|
private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
|
||||||
{
|
{
|
||||||
// TODO: This should probably be using an itemstatus
|
var charges = UsesRemaining(component);
|
||||||
// TODO: I'm too lazy to do this rn but it's literally copy-paste from emag.
|
var maxCharges = component.Uses;
|
||||||
_powerCell.TryGetBatteryFromSlot(uid, out var battery);
|
var activeholo = ActiveHolo(component);
|
||||||
var charges = UsesRemaining(component, battery);
|
|
||||||
var maxCharges = MaxUses(component, battery);
|
|
||||||
|
|
||||||
using (args.PushGroup(nameof(HolosignProjectorComponent)))
|
using (args.PushGroup(nameof(HolosignProjectorComponent)))
|
||||||
{
|
{
|
||||||
args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges)));
|
args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges)));
|
||||||
|
args.PushMarkup(Loc.GetString("holoprojector-active-holo", ("activeholo", activeholo)));
|
||||||
|
|
||||||
if (charges > 0 && charges == maxCharges)
|
if (charges > 0 && charges == maxCharges)
|
||||||
{
|
{
|
||||||
@@ -39,39 +40,58 @@ public sealed class HolosignSystem : EntitySystem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnUse(EntityUid uid, HolosignProjectorComponent comp, UseInHandEvent args)
|
||||||
|
{
|
||||||
|
foreach (var sign in comp.Signs)
|
||||||
|
{
|
||||||
|
comp.Signs.Remove(sign);
|
||||||
|
QueueDel(sign);
|
||||||
|
}
|
||||||
|
_popupSystem.PopupEntity(Loc.GetString("holoprojector-delete-signs"), args.User, args.User, PopupType.Medium);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args)
|
private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args)
|
||||||
{
|
{
|
||||||
|
if (component.Signs.Contains(args.Target)) // wd edit
|
||||||
|
{
|
||||||
|
QueueDel(args.Target);
|
||||||
|
component.Signs.Remove(args.Target);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (args.Handled
|
if (args.Handled || !args.CanReach)
|
||||||
|| !args.CanReach // prevent placing out of range
|
|
||||||
|| HasComp<StorageComponent>(args.Target) // if it's a storage component like a bag, we ignore usage so it can be stored
|
|
||||||
|| !_powerCell.TryUseCharge(uid, component.ChargeUse) // if no battery or no charge, doesn't work
|
|
||||||
)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// places the holographic sign at the click location, snapped to grid.
|
if (component.Signs.Count >= component.Uses) // wd edit
|
||||||
// overlapping of the same holo on one tile remains allowed to allow holofan refreshes
|
{
|
||||||
|
_popupSystem.PopupEntity(Loc.GetString("holoprojector-uses-limit"), args.User, args.User, PopupType.Medium);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
|
var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
|
||||||
var xform = Transform(holoUid);
|
var xform = Transform(holoUid);
|
||||||
if (!xform.Anchored)
|
if (!xform.Anchored)
|
||||||
_transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)
|
_transform.AnchorEntity(holoUid, xform);
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
component.Signs.Add(holoUid); // WD EDIT
|
||||||
}
|
}
|
||||||
|
|
||||||
private int UsesRemaining(HolosignProjectorComponent component, BatteryComponent? battery = null)
|
private void OnComponentRemove(EntityUid uid, HolosignProjectorComponent comp, ComponentRemove args) // wd edit
|
||||||
{
|
{
|
||||||
if (battery == null ||
|
foreach (var sign in comp.Signs)
|
||||||
component.ChargeUse == 0f) return 0;
|
{
|
||||||
|
QueueDel(sign);
|
||||||
return (int) (battery.CurrentCharge / component.ChargeUse);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int MaxUses(HolosignProjectorComponent component, BatteryComponent? battery = null)
|
private int UsesRemaining(HolosignProjectorComponent component)
|
||||||
{
|
{
|
||||||
if (battery == null ||
|
return (component.Uses - component.Signs.Count); // wd edit
|
||||||
component.ChargeUse == 0f) return 0;
|
}
|
||||||
|
|
||||||
return (int) (battery.MaxCharge / component.ChargeUse);
|
private int ActiveHolo(HolosignProjectorComponent component) // wd edit
|
||||||
|
{
|
||||||
|
return (component.Signs.Count); // wd edit
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,7 @@ ent-ZipLock = зип пакет
|
|||||||
.desc = Предназначен для хранения улик.
|
.desc = Предназначен для хранения улик.
|
||||||
ent-BoxZipLocks = коробка зип пакетов
|
ent-BoxZipLocks = коробка зип пакетов
|
||||||
.desc = Заполнена зип пакетами. Обрадуйте детектива!
|
.desc = Заполнена зип пакетами. Обрадуйте детектива!
|
||||||
clumsy-gun-delete-log = В следствии неуклюжести во время стрельбы от { $prettyUser }, было удалено { $prettyGun }
|
clumsy-gun-delete-log = В следствии неуклюжести во время стрельбы от { $prettyUser }, было удалено { $prettyGun }
|
||||||
|
holoprojector-active-holo = Активные проекции: [color=fuchsia]{ $activeholo }[/color]
|
||||||
|
holoprojector-uses-limit = Было использовано максимальное количество проекций!
|
||||||
|
holoprojector-delete-signs = Все проекции были удалены!
|
||||||
@@ -6,16 +6,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: HolosignProjector
|
- type: HolosignProjector
|
||||||
- type: UseDelay
|
- type: UseDelay
|
||||||
- type: ContainerContainer
|
|
||||||
containers:
|
|
||||||
cell_slot: !type:ContainerSlot {}
|
|
||||||
- type: PowerCellSlot
|
|
||||||
cellSlotId: cell_slot
|
|
||||||
- type: ItemSlots
|
|
||||||
slots:
|
|
||||||
cell_slot:
|
|
||||||
name: power-cell-slot-component-slot-name-default
|
|
||||||
startingItem: PowerCellMedium
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Devices/Holoprojectors/custodial.rsi
|
sprite: Objects/Devices/Holoprojectors/custodial.rsi
|
||||||
state: icon
|
state: icon
|
||||||
@@ -29,14 +19,6 @@
|
|||||||
suffix: borg
|
suffix: borg
|
||||||
components:
|
components:
|
||||||
- type: HolosignProjector
|
- type: HolosignProjector
|
||||||
chargeUse: 240
|
|
||||||
- type: ItemSlots
|
|
||||||
slots:
|
|
||||||
cell_slot:
|
|
||||||
name: power-cell-slot-component-slot-name-default
|
|
||||||
startingItem: PowerCellMicroreactor
|
|
||||||
disableEject: true
|
|
||||||
swap: false
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
parent: Holoprojector
|
parent: Holoprojector
|
||||||
@@ -46,7 +28,6 @@
|
|||||||
components:
|
components:
|
||||||
- type: HolosignProjector
|
- type: HolosignProjector
|
||||||
signProto: HoloFan
|
signProto: HoloFan
|
||||||
chargeUse: 120
|
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Objects/Devices/Holoprojectors/atmos.rsi
|
sprite: Objects/Devices/Holoprojectors/atmos.rsi
|
||||||
state: icon
|
state: icon
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Holo/wetfloor.rsi
|
sprite: Structures/Holo/wetfloor.rsi
|
||||||
state: icon
|
state: icon
|
||||||
- type: TimedDespawn
|
|
||||||
lifetime: 90
|
|
||||||
- type: Damageable
|
- type: Damageable
|
||||||
damageContainer: StructuralInorganic
|
damageContainer: StructuralInorganic
|
||||||
- type: Destructible
|
- type: Destructible
|
||||||
@@ -41,8 +39,6 @@
|
|||||||
shape:
|
shape:
|
||||||
!type:PhysShapeAabb
|
!type:PhysShapeAabb
|
||||||
bounds: "-0.5,-0.5,0.5,0.5"
|
bounds: "-0.5,-0.5,0.5,0.5"
|
||||||
- type: TimedDespawn
|
|
||||||
lifetime: 180
|
|
||||||
- type: Airtight
|
- type: Airtight
|
||||||
noAirWhenFullyAirBlocked: false
|
noAirWhenFullyAirBlocked: false
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user