Files
OldThink/Content.Server/Holosign/HolosignSystem.cs
Remuchi e2b6002076 Merge remote-tracking branch 'origin/master' into upstream
# Conflicts:
#	Content.Server/Antag/AntagSelectionSystem.cs
#	Content.Server/Changeling/ChangelingRuleSystem.cs
#	Content.Server/Changeling/ChangelingSystem.Abilities.cs
#	Content.Server/Doors/Systems/DoorSystem.cs
#	Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs
#	Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs
#	Content.Server/GameTicking/Rules/TraitorRuleSystem.cs
#	Content.Server/GameTicking/Rules/ZombieRuleSystem.cs
#	Content.Server/Holosign/HolosignSystem.cs
#	Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs
#	Content.Server/_White/Cult/GameRule/CultRuleComponent.cs
#	Content.Server/_White/Cult/GameRule/CultRuleSystem.cs
#	Content.Server/_White/Cult/Runes/Systems/CultSystem.Rune.cs
#	Content.Server/_White/Keyhole/KeyholeSystem.cs
#	Content.Server/_White/MeatyOre/MeatyOreStoreSystem.cs
#	Content.Shared/Projectiles/SharedProjectileSystem.cs
#	Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
#	Content.Shared/_White/Keyhole/Components/KeyBaseComponent.cs
#	Resources/Locale/ru-RU/White/stuff.ftl/runes-entities.ftl
#	Resources/Locale/ru-RU/_white/cult/blood-spear.ftl
#	Resources/Locale/ru-RU/_white/cult/bolt-barrage.ftl
#	Resources/Locale/ru-RU/_white/cult/cult.ftl
#	Resources/Locale/ru-RU/_white/cult/gui.ftl
#	Resources/Locale/ru-RU/cult/cult-structure.ftl
#	Resources/Locale/ru-RU/cult/pylon.ftl
#	Resources/Maps/White/Scoupidia.yml
#	Resources/Maps/White/Void.yml
#	Resources/Maps/White/WonderBox.yml
#	Resources/Prototypes/Actions/types.yml
#	Resources/Prototypes/Atmospherics/gases.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_atmospherics.yml
#	Resources/Prototypes/Catalog/Cargo/cargo_vending.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/dressers.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/heads.yml
#	Resources/Prototypes/Catalog/Fills/Lockers/misc.yml
#	Resources/Prototypes/Catalog/uplink_catalog.yml
#	Resources/Prototypes/Entities/Clothing/OuterClothing/armor.yml
#	Resources/Prototypes/Entities/Objects/Misc/subdermal_implants.yml
#	Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Melee/sledgehammer.yml
#	Resources/Prototypes/Entities/Objects/Weapons/Melee/sword.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_assembly.yml
#	Resources/Prototypes/Entities/Structures/Doors/Airlocks/base_structureairlocks.yml
#	Resources/Prototypes/Entities/Structures/Doors/Firelocks/firelock.yml
#	Resources/Prototypes/Entities/Structures/Doors/Firelocks/frame.yml
#	Resources/Prototypes/Entities/Structures/Doors/SecretDoor/secret_door.yml
#	Resources/Prototypes/Entities/Structures/Doors/Windoors/assembly.yml
#	Resources/Prototypes/Entities/Structures/Doors/Windoors/base_structurewindoors.yml
#	Resources/Prototypes/Entities/Structures/Furniture/dresser.yml
#	Resources/Prototypes/Entities/Structures/Lighting/base_lighting.yml
#	Resources/Prototypes/Entities/Structures/Power/cable_terminal.yml
#	Resources/Prototypes/Entities/Structures/Walls/grille.yml
#	Resources/Prototypes/Entities/Structures/Walls/walls.yml
#	Resources/Prototypes/Entities/Structures/stairs.yml
#	Resources/Prototypes/_White/Entities/Objects/Misc/books.yml
2024-04-13 13:59:00 +07:00

100 lines
3.5 KiB
C#

using Content.Shared.Examine;
using Content.Server.Popups;
using Content.Shared.Coordinates.Helpers;
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 SharedTransformSystem _transform = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<HolosignProjectorComponent, BeforeRangedInteractEvent>(OnBeforeInteract);
SubscribeLocalEvent<HolosignProjectorComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<HolosignProjectorComponent, ComponentRemove>(OnComponentRemove);
SubscribeLocalEvent<HolosignProjectorComponent, UseInHandEvent>(OnUse);
}
private void OnExamine(EntityUid uid, HolosignProjectorComponent component, ExaminedEvent args)
{
var charges = UsesRemaining(component);
var maxCharges = component.Uses;
var activeholo = ActiveHolo(component);
using (args.PushGroup(nameof(HolosignProjectorComponent)))
{
args.PushMarkup(Loc.GetString("limited-charges-charges-remaining", ("charges", charges)));
args.PushMarkup(Loc.GetString("holoprojector-active-holo", ("activeholo", activeholo)));
if (charges > 0 && charges == maxCharges)
{
args.PushMarkup(Loc.GetString("limited-charges-max-charges"));
}
}
}
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)
{
if (component.Signs.Contains(args.Target)) // wd edit
{
QueueDel(args.Target);
component.Signs.Remove(args.Target);
return;
}
if (args.Handled || !args.CanReach || HasComp<StorageComponent>(args.Target))
return;
if (component.Signs.Count >= component.Uses) // wd edit
{
_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 xform = Transform(holoUid);
if (!xform.Anchored)
{
_transform.AnchorEntity(holoUid, xform);
}
args.Handled = true;
component.Signs.Add(holoUid); // WD EDIT
}
private void OnComponentRemove(EntityUid uid, HolosignProjectorComponent comp, ComponentRemove args) // wd edit
{
foreach (var sign in comp.Signs)
{
QueueDel(sign);
}
}
private static int UsesRemaining(HolosignProjectorComponent component)
{
return component.Uses - component.Signs.Count; // wd edit
}
private static int ActiveHolo(HolosignProjectorComponent component) // wd edit
{
return component.Signs.Count; // wd edit
}
}