* 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>
125 lines
4.3 KiB
C#
125 lines
4.3 KiB
C#
using Content.Shared.Actions;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.MouseRotator;
|
|
using Content.Shared.Mech.Components;
|
|
using Content.Shared.Movement.Components;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.CombatMode;
|
|
|
|
public abstract class SharedCombatModeSystem : EntitySystem
|
|
{
|
|
[Dependency] protected readonly IGameTiming Timing = default!;
|
|
[Dependency] private readonly INetManager _netMan = default!;
|
|
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
|
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<CombatModeComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<CombatModeComponent, ComponentShutdown>(OnShutdown);
|
|
SubscribeLocalEvent<CombatModeComponent, ToggleCombatActionEvent>(OnActionPerform);
|
|
}
|
|
|
|
private void OnMapInit(EntityUid uid, CombatModeComponent component, MapInitEvent args)
|
|
{
|
|
_actionsSystem.AddAction(uid, ref component.CombatToggleActionEntity, component.CombatToggleAction);
|
|
Dirty(uid, component);
|
|
}
|
|
|
|
private void OnShutdown(EntityUid uid, CombatModeComponent component, ComponentShutdown args)
|
|
{
|
|
_actionsSystem.RemoveAction(uid, component.CombatToggleActionEntity);
|
|
|
|
SetMouseRotatorComponents(uid, false);
|
|
}
|
|
|
|
private void OnActionPerform(EntityUid uid, CombatModeComponent component, ToggleCombatActionEvent args)
|
|
{
|
|
if (args.Handled)
|
|
return;
|
|
|
|
args.Handled = true;
|
|
SetInCombatMode(uid, !component.IsInCombatMode, component);
|
|
|
|
// TODO better handling of predicted pop-ups.
|
|
// This probably breaks if the client has prediction disabled.
|
|
|
|
if (!_netMan.IsClient || !Timing.IsFirstTimePredicted)
|
|
return;
|
|
|
|
var msg = component.IsInCombatMode ? "action-popup-combat-enabled" : "action-popup-combat-disabled";
|
|
_popup.PopupEntity(Loc.GetString(msg), args.Performer, args.Performer);
|
|
}
|
|
|
|
public void SetCanDisarm(EntityUid entity, bool canDisarm, CombatModeComponent? component = null)
|
|
{
|
|
if (!Resolve(entity, ref component))
|
|
return;
|
|
|
|
component.CanDisarm = canDisarm;
|
|
}
|
|
|
|
public bool IsInCombatMode(EntityUid? entity, CombatModeComponent? component = null)
|
|
{
|
|
return entity != null && Resolve(entity.Value, ref component, false) && component.IsInCombatMode;
|
|
}
|
|
|
|
public virtual void SetInCombatMode(EntityUid entity, bool value, CombatModeComponent? component = null)
|
|
{
|
|
if (!Resolve(entity, ref component))
|
|
return;
|
|
|
|
if (component.IsInCombatMode == value)
|
|
return;
|
|
|
|
component.IsInCombatMode = value;
|
|
Dirty(entity, component);
|
|
|
|
if (component.CombatToggleActionEntity != null)
|
|
_actionsSystem.SetToggled(component.CombatToggleActionEntity, component.IsInCombatMode);
|
|
|
|
// Change mouse rotator comps if flag is set
|
|
if (!component.ToggleMouseRotator || IsNpc(entity) && !_mind.TryGetMind(entity, out _, out _))
|
|
return;
|
|
|
|
SetMouseRotatorComponents(entity, value);
|
|
}
|
|
|
|
private void SetMouseRotatorComponents(EntityUid uid, bool value)
|
|
{
|
|
if (value)
|
|
{
|
|
if (TryComp<MechPilotComponent>(uid, out var mechPilot) && !HasComp<NoRotateOnMoveComponent>(mechPilot.Mech))
|
|
{
|
|
EnsureComp<NoRotateOnMoveComponent>(mechPilot.Mech);
|
|
}
|
|
|
|
EnsureComp<MouseRotatorComponent>(uid);
|
|
EnsureComp<NoRotateOnMoveComponent>(uid);
|
|
}
|
|
else
|
|
{
|
|
if (TryComp<MechPilotComponent>(uid, out var mechPilot) && HasComp<NoRotateOnMoveComponent>(mechPilot.Mech))
|
|
{
|
|
RemComp<NoRotateOnMoveComponent>(mechPilot.Mech);
|
|
}
|
|
|
|
RemComp<MouseRotatorComponent>(uid);
|
|
RemComp<NoRotateOnMoveComponent>(uid);
|
|
}
|
|
}
|
|
|
|
// todo: When we stop making fucking garbage abstract shared components, remove this shit too.
|
|
protected abstract bool IsNpc(EntityUid uid);
|
|
}
|
|
|
|
public sealed partial class ToggleCombatActionEvent : InstantActionEvent
|
|
{
|
|
|
|
}
|