fish-station/Content.Shared/_Sunrise/Paint/SharedMechPaintSystem.cs
Rinary b6920aec99
Рефактор мехов, правки в системе медицины (#507)
* mech system, fix hands, fix fraction

* fix

* fix fake hypo

* fix triple airlocks big sizing

* fix

* upd clown hulk

* xd fix 2

* bigger exit delay

* mechs reflect changes

* guns changes

* draike up

* mechs in another category

* add equipment

* Revert "upd clown hulk"

This reverts commit b8084967040be5d442b2d4770cf7fdece1daa2a8.

* SPIN MY MECH ASS

* mech no rot

* some resprite

* no injections in hardsuits

* some species can not be injectable

* medipans can ignore armor, admeme hypospray ignore armor

* fix

* fix admeme hypo

* mob fraction fix

* rover + nt gygax add

* fix description

* fix id

* some better dome effects

* если пустая гильза в стволе -> Кнопки "казнь" не будет

* phazon added

* fix server crashes

* full rework mechs on mobstates, coils fix mechs, diagnostic hud show health bar for mechs, mechs fastest repair, add mech analyzer

* some fixes

* configure health of all mechs

* upd

* add rover to uplink

* translate bundle

* change price

* phazon construction

* fix

* fix

* Finish phazon construction

* add phazon research and recipes

* phazon construction translate

* fix

* Mech lights

* fix

* translate light action

* Mech sounds, fix damage

* fix

* fix hello sound

* upd

* fix linter

* change damagePercentage

* fix

* fix hello sound

* temp disable damage sounds

* fix battery needed on construct

* some changes

* add mech painting system as DEBUG(in dev)

* Fix yaml, durand paintings

* mech spray cans textures

* change sprite

* fix

* ripley, clarke new textures

* ripley,clarke paints

* fix

* sec pod texture

---------

Co-authored-by: Vigers Ray <60344369+VigersRay@users.noreply.github.com>
2024-10-30 10:53:00 +03:00

92 lines
3.3 KiB
C#

using Content.Shared.DoAfter;
using Content.Shared.Humanoid;
using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Mech.Components;
using Content.Shared.Mech.EntitySystems;
using Content.Shared.Popups;
using Content.Shared.SubFloor;
using Robust.Shared.Audio.Systems;
using Content.Shared.Nutrition.EntitySystems;
using Content.Shared.Whitelist;
namespace Content.Shared._Sunrise.Paint;
/// <summary>
/// Colors target and consumes reagent on each color success.
/// </summary>
public abstract class SharedMechPaintSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly OpenableSystem _openable = default!;
[Dependency] private readonly SharedMechSystem _mechSystem = default!;
[Dependency] private readonly EntityWhitelistSystem _whitelist = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<MechPaintComponent, PaintDoAfterEvent>(OnPaint);
}
private void OnPaint(Entity<MechPaintComponent> entity, ref PaintDoAfterEvent args)
{
if (args.Target == null || args.Used == null || !HasComp<MechComponent>(args.Target))
return;
if (args.Handled || args.Cancelled)
return;
if (args.Target is not { Valid: true } target)
return;
if (!_openable.IsOpen(entity))
{
_popup.PopupEntity(Loc.GetString("paint-closed", ("used", args.Used)), args.User, args.User, PopupType.Medium);
return;
}
if (entity.Comp.Whitelist != null && !_whitelist.IsValid(entity.Comp.Whitelist, target) || HasComp<HumanoidAppearanceComponent>(target) || HasComp<SubFloorHideComponent>(target))
{
_popup.PopupEntity(Loc.GetString("paint-failure", ("target", args.Target)), args.User, args.User, PopupType.Medium);
return;
}
if (TryPaint(entity, target))
{
EnsureComp<MechComponent>(target, out MechComponent? mech);
EnsureComp<AppearanceComponent>(target, out AppearanceComponent? appearance);
_audio.PlayPvs(entity.Comp.Spray, entity);
_popup.PopupEntity(Loc.GetString("paint-success", ("target", args.Target)), args.User, args.User, PopupType.Medium);
mech.BaseState = entity.Comp.BaseState;
mech.OpenState = entity.Comp.OpenState;
mech.BrokenState = entity.Comp.BrokenState;
entity.Comp.Used = true;
Dirty(target, mech);
args.Handled = true;
_mechSystem.UpdateAppearance(target, mech, appearance);
return;
}
if (!TryPaint(entity, target))
{
_popup.PopupEntity(Loc.GetString("paint-empty", ("used", args.Used)), args.User, args.User, PopupType.Medium);
return;
}
}
private bool TryPaint(Entity<MechPaintComponent> entity, EntityUid target)
{
if (HasComp<HumanoidAppearanceComponent>(target) || HasComp<SubFloorHideComponent>(target) || entity.Comp.Used)
return false;
if (HasComp<MechComponent>(target))
return true;
return false;
}
}