Skip to content

Commit

Permalink
[Tweak] Holoprojector / Голопроектрор (#112)
Browse files Browse the repository at this point in the history
* tweak

* local

* tweak

* tweak
  • Loading branch information
Spatison authored Nov 6, 2024
1 parent 475c6ab commit 5c5d109
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 121 deletions.
15 changes: 10 additions & 5 deletions Content.Server/Holosign/HolosignProjectorComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ public sealed partial class HolosignProjectorComponent : Component
[DataField("signProto", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
public string SignProto = "HolosignWetFloor";

/// <summary>
/// How much charge a single use expends.
/// </summary>
[ViewVariables(VVAccess.ReadWrite), DataField("chargeUse")]
public float ChargeUse = 50f;
// WD EDIT START
[DataField]
public int MaxUses = 6;

[DataField]
public int Uses = 6;

[ViewVariables(VVAccess.ReadOnly)]
public List<EntityUid?> Signs = new();
// WD EDIT END
}
}
76 changes: 50 additions & 26 deletions Content.Server/Holosign/HolosignSystem.cs
Original file line number Diff line number Diff line change
@@ -1,53 +1,68 @@
using System.Linq;
using Content.Server._White.Holosign;
using Content.Server.Popups;
using Content.Shared.Examine;
using Content.Shared.Coordinates.Helpers;
using Content.Server.Power.Components;
using Content.Server.PowerCell;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Popups;
using Content.Shared.Storage;

namespace Content.Server.Holosign;

public sealed class HolosignSystem : EntitySystem
{
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;

[Dependency] private readonly PopupSystem _popup = default!; // WD EDIT

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<HolosignProjectorComponent, UseInHandEvent>(OnUse); // WD EDIT
}

private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
{
// TODO: This should probably be using an itemstatus
// TODO: I'm too lazy to do this rn but it's literally copy-paste from emag.
_powerCell.TryGetBatteryFromSlot(uid, out var battery);
var charges = UsesRemaining(component, battery);
var maxCharges = MaxUses(component, battery);
// WD EDIT START
var charges = component.Uses;
var maxCharges = component.MaxUses;
var activeholo = component.Signs.Count;
// WD EDIT END

using (args.PushGroup(nameof(HolosignProjectorComponent)))
{
args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges)));
args.PushMarkup(Loc.GetString("holoprojector-active-holo", ("activeholo", activeholo))); // WD EDIT

if (charges > 0 && charges == maxCharges)
{
args.PushMarkup(Loc.GetString("limited-charges-max-charges"));
}
}
}

private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent component, BeforeRangedInteractEvent args)
{

if (args.Handled
|| !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
)
|| HasComp<StorageComponent>(args.Target)) // if it's a storage component like a bag, we ignore usage so it can be stored
return;

// WD EDIT START
if (component.Signs.Contains(args.Target))
{
++component.Uses;
component.Signs.Remove(args.Target);
QueueDel(args.Target);
return;
}

if (component.Uses == 0)
{
_popup.PopupEntity(Loc.GetString("holoprojector-uses-limit"), args.User, args.User, PopupType.Medium);
return;
}
// WD EDIT END

// places the holographic sign at the click location, snapped to grid.
// overlapping of the same holo on one tile remains allowed to allow holofan refreshes
Expand All @@ -56,22 +71,31 @@ private void OnBeforeInteract(EntityUid uid, HolosignProjectorComponent componen
if (!xform.Anchored)
_transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)

// WD EDIT START
EnsureComp<HolosignComponent>(holoUid, out var holosign);
--component.Uses;
component.Signs.Add(holoUid);
holosign.Projector = uid;
// WD EDIT END

args.Handled = true;
}

private int UsesRemaining(HolosignProjectorComponent component, BatteryComponent? battery = null)
// WD EDIT START
private void OnUse(EntityUid uid, HolosignProjectorComponent component, UseInHandEvent args)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;

return (int) (battery.CurrentCharge / component.ChargeUse);
}
if (args.Handled)
return;

private int MaxUses(HolosignProjectorComponent component, BatteryComponent? battery = null)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;
foreach (var sign in component.Signs.ToList())
{
component.Signs.Remove(sign);
QueueDel(sign);
}

return (int) (battery.MaxCharge / component.ChargeUse);
args.Handled = true;
component.Uses = component.MaxUses;
_popup.PopupEntity(Loc.GetString("holoprojector-delete-signs"), args.User, args.User, PopupType.Medium);
}
// WD EDIT START
}
8 changes: 8 additions & 0 deletions Content.Server/_White/Holosign/HolosignComponent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Content.Server._White.Holosign;

[RegisterComponent]
public sealed partial class HolosignComponent : Component
{
[ViewVariables(VVAccess.ReadOnly)]
public EntityUid? Projector;
}
21 changes: 21 additions & 0 deletions Content.Server/_White/Holosign/HolosignSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Content.Server.Holosign;
using Content.Shared.Destructible;

namespace Content.Server._White.Holosign;

public sealed class HolosignSystem : EntitySystem
{
public override void Initialize()
{
SubscribeLocalEvent<HolosignComponent, DestructionEventArgs>(OnDestruction);
}

private void OnDestruction(EntityUid uid, HolosignComponent component, DestructionEventArgs args)
{
if (!TryComp<HolosignProjectorComponent>(component.Projector, out var holosignProjector))
return;

holosignProjector.Signs.Remove(uid);
++holosignProjector.Uses;
}
}
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/_white/holoprojector/holoprojector.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
holoprojector-active-holo = Active projections: [color=fuchsia]{ $activeholo }[/color]
holoprojector-uses-limit = The maximum number of projections was used!
holoprojector-delete-signs = All projections have been deleted!
3 changes: 3 additions & 0 deletions Resources/Locale/ru-RU/_white/holoprojector/holoprojector.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
holoprojector-active-holo = Активные проекции: [color=fuchsia]{ $activeholo }[/color]
holoprojector-uses-limit = Было использовано максимальное количество проекций!
holoprojector-delete-signs = Все проекции были удалены!
9 changes: 8 additions & 1 deletion Resources/Migrations/migration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,11 @@ ReinforcementRadioSyndicateMonkeyNukeops: ReinforcementRadioSyndicateAncestorNuk
DrinkBottleGoldschlager: DrinkBottleGildlager

# 2024-11-10 WD EDIT
VendingMachinePride: RandomVending
VendingMachinePride: RandomVending

# 2024-30-10 WD EDIT
HoloprojectorEmpty: Holoprojector
HoloprojectorBorg: Holoprojector
HolofanProjectorEmpty: HolofanProjector
HoloprojectorFieldEmpty: HoloprojectorField
HoloprojectorSecurityEmpty: HoloprojectorSecurity
69 changes: 1 addition & 68 deletions Resources/Prototypes/Entities/Objects/Devices/holoprojectors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,14 @@
storedRotation: -90
- type: HolosignProjector
- 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
delay: 0.5 # WD EDIT
- type: Sprite
sprite: Objects/Devices/Holoprojectors/custodial.rsi
state: icon
- type: Tag
tags:
- HolosignProjector

- type: entity
parent: Holoprojector
id: HoloprojectorEmpty
suffix: Empty
components:
- type: ItemSlots
slots:
cell_slot:
name: power-cell-slot-component-slot-name-default

- type: entity
parent: Holoprojector
id: HoloprojectorBorg
suffix: borg
components:
- 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
parent: Holoprojector
id: HolofanProjector
Expand All @@ -58,7 +24,6 @@
components:
- type: HolosignProjector
signProto: HoloFan
chargeUse: 120
- type: Sprite
sprite: Objects/Devices/Holoprojectors/atmos.rsi
state: icon
Expand All @@ -72,16 +37,6 @@
recipes:
- HolofanProjector

- type: entity
parent: HolofanProjector
id: HolofanProjectorEmpty
suffix: Empty
components:
- type: ItemSlots
slots:
cell_slot:
name: power-cell-slot-component-slot-name-default

- type: entity
parent: Holoprojector
id: HoloprojectorField
Expand All @@ -90,7 +45,6 @@
components:
- type: HolosignProjector
signProto: HolosignForcefield
chargeUse: 120
- type: Sprite
sprite: Objects/Devices/Holoprojectors/field.rsi
state: icon
Expand All @@ -104,16 +58,6 @@
recipes:
- HoloprojectorField

- type: entity
parent: HoloprojectorField
id: HoloprojectorFieldEmpty
suffix: Empty
components:
- type: ItemSlots
slots:
cell_slot:
name: power-cell-slot-component-slot-name-default

- type: entity
parent: Holoprojector
id: HoloprojectorSecurity
Expand All @@ -122,7 +66,6 @@
components:
- type: HolosignProjector
signProto: HolosignSecurity
chargeUse: 120
- type: Sprite
sprite: Objects/Devices/Holoprojectors/security.rsi
state: icon
Expand All @@ -131,13 +74,3 @@
- HolofanProjector
- type: StaticPrice
price: 50

- type: entity
parent: HoloprojectorSecurity
id: HoloprojectorSecurityEmpty
suffix: Empty
components:
- type: ItemSlots
slots:
cell_slot:
name: power-cell-slot-component-slot-name-default
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@
- type: ItemBorgModule
items:
- AdvMopItem
- HoloprojectorBorg
- Holoprojector # WD EDIT
- SprayBottleSpaceCleaner
- Dropper
- TrashBag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
- type: Sprite
sprite: Structures/Holo/wetfloor.rsi
state: icon
- type: TimedDespawn
lifetime: 90
- type: Damageable
damageContainer: Inorganic
- type: Destructible
Expand All @@ -25,6 +23,14 @@
behaviors:
- !type:DoActsBehavior
acts: [ "Destruction" ]
# WD EDIT START
- type: Clickable
- type: MeleeSound
soundGroups:
Brute:
path:
"/Audio/Weapons/egloves.ogg"
# WD EDIT END

- type: entity
id: HoloFan
Expand All @@ -41,8 +47,6 @@
shape:
!type:PhysShapeAabb
bounds: "-0.5,-0.5,0.5,0.5"
- type: TimedDespawn
lifetime: 180
- type: Airtight
noAirWhenFullyAirBlocked: false

Expand All @@ -68,14 +72,11 @@
- TableMask
layer:
- TableLayer
- type: TimedDespawn
lifetime: 180
- type: PointLight
enabled: true
radius: 3
color: red
- type: Climbable
- type: Clickable

- type: entity
id: HolosignForcefield
Expand All @@ -99,13 +100,10 @@
- FullTileMask
layer:
- GlassLayer
- type: TimedDespawn
lifetime: 180
- type: PointLight
enabled: true
radius: 3
color: blue
- type: Clickable
- type: ContainmentField
throwForce: 0
- type: Destructible
Expand Down
Loading

0 comments on commit 5c5d109

Please sign in to comment.