mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 05:27:38 +03:00
82 lines
2.9 KiB
C#
82 lines
2.9 KiB
C#
using Content.Shared.Interaction.Events;
|
|
using Content.Shared.Popups;
|
|
using Content.Shared._Goobstation.Bingle;
|
|
using Robust.Shared.Map;
|
|
using System.Numerics;
|
|
using Content.Shared.Overlays.Switchable;
|
|
using Content.Server.Flash.Components;
|
|
using Content.Server.Polymorph.Components;
|
|
using Content.Server.Polymorph.Systems;
|
|
using Content.Shared.CombatMode;
|
|
using Robust.Server.GameObjects;
|
|
|
|
namespace Content.Server._Goobstation.Bingle;
|
|
|
|
public sealed class BingleSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly PolymorphSystem _polymorph = default!;
|
|
[Dependency] private readonly AppearanceSystem _appearance = default!;
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<BingleComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<BingleComponent, AttackAttemptEvent>(OnAttackAttempt);
|
|
SubscribeLocalEvent<BingleComponent, ToggleNightVisionEvent>(OnNightvision);
|
|
SubscribeLocalEvent<BingleComponent, CombatModeToggledEvent>(OnCombatToggle); // WD EDIT
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, BingleComponent component, MapInitEvent args)
|
|
{
|
|
var cords = Transform(uid).Coordinates;
|
|
if (!cords.IsValid(EntityManager) || cords.Position == Vector2.Zero)
|
|
return;
|
|
if (MapId.Nullspace == Transform(uid).MapID)
|
|
return;
|
|
|
|
if (component.Prime)
|
|
component.MyPit = Spawn("BinglePit", cords);
|
|
else
|
|
{
|
|
var query = EntityQueryEnumerator<BinglePitComponent>();
|
|
while (query.MoveNext(out var queryUid, out var _))
|
|
if (cords == Transform(queryUid).Coordinates)
|
|
component.MyPit = queryUid;
|
|
}
|
|
}
|
|
|
|
//ran by the pit to upgrade bingle damage
|
|
public void UpgradeBingle(EntityUid uid, BingleComponent component)
|
|
{
|
|
if (component.Upgraded)
|
|
return;
|
|
|
|
var polyComp = EnsureComp<PolymorphableComponent>(uid);
|
|
_polymorph.CreatePolymorphAction("BinglePolymorph",(uid, polyComp ));
|
|
|
|
_popup.PopupEntity(Loc.GetString("bingle-upgrade-success"), uid, uid);
|
|
component.Upgraded = true;
|
|
}
|
|
|
|
private void OnAttackAttempt(EntityUid uid, BingleComponent component, AttackAttemptEvent args)
|
|
{
|
|
//Prevent Friendly Bingle fire
|
|
if (HasComp<BinglePitComponent>(args.Target) || HasComp<BingleComponent>(args.Target))
|
|
args.Cancel();
|
|
}
|
|
|
|
private void OnNightvision(EntityUid uid, BingleComponent component, ToggleNightVisionEvent args)
|
|
{
|
|
if (!TryComp<FlashImmunityComponent>(uid, out var flashComp))
|
|
return;
|
|
|
|
flashComp.Enabled = !flashComp.Enabled;
|
|
}
|
|
|
|
private void OnCombatToggle(EntityUid uid, BingleComponent component, CombatModeToggledEvent args) // WD EDIT
|
|
{
|
|
_appearance.SetData(uid, BingleVisual.Combat, args.CombatMode); // WD EDIT
|
|
}
|
|
}
|
|
|