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

[Tweak] Holoprojector / Голопроектрор #112

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
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;

Spatison marked this conversation as resolved.
Show resolved Hide resolved
[ViewVariables(VVAccess.ReadOnly)]
public List<EntityUid?> Signs = new();
Spatison marked this conversation as resolved.
Show resolved Hide resolved
// WD EDIT END
}
}
74 changes: 47 additions & 27 deletions Content.Server/Holosign/HolosignSystem.cs
Original file line number Diff line number Diff line change
@@ -1,77 +1,97 @@
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
Spatison marked this conversation as resolved.
Show resolved Hide resolved

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;
}
Spatison marked this conversation as resolved.
Show resolved Hide resolved
Spatison marked this conversation as resolved.
Show resolved Hide resolved
// 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
var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager));
var xform = Transform(holoUid);
if (!xform.Anchored)
_transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it)

args.Handled = true;
}

private int UsesRemaining(HolosignProjectorComponent component, BatteryComponent? battery = null)
{
if (battery == null ||
component.ChargeUse == 0f) return 0;
// WD EDIT START
EnsureComp<HolosignComponent>(holoUid, out var holosign);
--component.Uses;
component.Signs.Add(holoUid);
holosign.Sign = uid;
// WD EDIT END

return (int) (battery.CurrentCharge / component.ChargeUse);
args.Handled = true;
Spatison marked this conversation as resolved.
Show resolved Hide resolved
}

private int MaxUses(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;
foreach (var sign in component.Signs.ToList())
{
component.Signs.Remove(sign);
QueueDel(sign);
}

return (int) (battery.MaxCharge / component.ChargeUse);
component.Uses = component.MaxUses;
_popup.PopupEntity(Loc.GetString("holoprojector-delete-signs"), args.User, args.User, PopupType.Medium);
}
// WD EDIT START
Spatison marked this conversation as resolved.
Show resolved Hide resolved
}
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? Sign;
Spatison marked this conversation as resolved.
Show resolved Hide resolved
}
Spatison marked this conversation as resolved.
Show resolved Hide resolved
Spatison marked this conversation as resolved.
Show resolved Hide resolved
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
{
Spatison marked this conversation as resolved.
Show resolved Hide resolved
public override void Initialize()
{
SubscribeLocalEvent<HolosignComponent, DestructionEventArgs>(OnDestruction);
}

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

holosignProjector.Signs.Remove(uid);
++holosignProjector.Uses;
}
Spatison marked this conversation as resolved.
Show resolved Hide resolved
Spatison marked this conversation as resolved.
Show resolved Hide resolved
}
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
Spatison marked this conversation as resolved.
Show resolved Hide resolved

- 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
Loading