# Conflicts: # Content.Client/Entry/EntryPoint.cs # Content.Client/Stylesheets/StyleNano.cs # Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs # Content.Server/Nutrition/EntitySystems/FoodSystem.cs # Content.Shared/Follower/FollowerSystem.cs # Content.Shared/Humanoid/SharedHumanoidAppearanceSystem.cs # Content.Shared/Inventory/InventorySystem.Relay.cs # Content.Shared/PAI/SharedPAISystem.cs # Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs # Resources/Locale/en-US/_strings/access/components/genpop.ftl # Resources/Locale/en-US/_strings/doors/components/turnstile.ftl # Resources/Locale/en-US/_strings/power/battery.ftl # Resources/Locale/en-US/_strings/store/pai-catalog.ftl # Resources/Locale/en-US/_strings/tools/simple-tool-usage.ftl # Resources/Locale/en-US/_strings/ui/controls.ftl # Resources/Locale/en-US/_strings/weapons/ranged/upgrades.ftl # Resources/Prototypes/Access/misc.yml # Resources/Prototypes/Catalog/Cargo/cargo_vending.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/coats.yml # Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml # Resources/Prototypes/Entities/Markers/Spawners/Random/crates.yml # Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml # Resources/Prototypes/Entities/Mobs/Player/dragon.yml # Resources/Prototypes/Entities/Mobs/Player/humanoid.yml # Resources/Prototypes/Entities/Objects/Fun/toys.yml # Resources/Prototypes/Entities/Objects/Misc/paper.yml # Resources/Prototypes/Entities/Objects/Specific/Robotics/borg_modules.yml # Resources/Prototypes/Entities/Objects/Tools/access_configurator.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Magazines/shotgun.yml # Resources/Prototypes/Entities/Objects/Weapons/Guns/Battery/battery_guns.yml # Resources/Prototypes/Entities/Stations/base.yml # Resources/Prototypes/Entities/Structures/Walls/asteroid.yml # Resources/Prototypes/Loadouts/role_loadouts.yml # Resources/Prototypes/Recipes/Lathes/Packs/science.yml # Resources/Prototypes/Research/industrial.yml # Resources/Prototypes/Species/vox.yml # Resources/Prototypes/Store/currency.yml # Resources/Prototypes/Voice/speech_emotes.yml # Resources/Prototypes/ai_factions.yml # Resources/Prototypes/borg_types.yml # Resources/Textures/Clothing/Head/Hats/captain.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/capformaldress.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/captain.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpskirt/paramedic.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpskirt/paramedic.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/capformal.rsi/equipped-INNERCLOTHING-monkey.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/capformal.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpsuit/captain.rsi/equipped-INNERCLOTHING-monkey.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/captain.rsi/meta.json # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/equipped-INNERCLOTHING-monkey.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/equipped-INNERCLOTHING.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/icon.png # Resources/Textures/Clothing/Uniforms/Jumpsuit/paramedic.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/captain_sabre.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/energykatana.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/katana.rsi/meta.json # Resources/Textures/Objects/Weapons/Melee/machete.rsi/meta.json # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/deny.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/locked.png # Resources/Textures/Structures/Doors/Airlocks/Glass/firelock.rsi/opening.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/assembly.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/meta.json # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/open.png # Resources/Textures/Structures/Doors/Airlocks/Standard/atmospherics.rsi/opening.png # Resources/Textures/Structures/Doors/Airlocks/Standard/firelock.rsi/closed.png # Resources/Textures/Structures/Doors/Airlocks/Standard/firelock.rsi/closing.png # Resources/Textures/Structures/Doors/Airlocks/Standard/firelock.rsi/opening.png # Resources/Textures/Structures/Wallmounts/posters.rsi/poster4_contraband.png # Resources/migration.yml
131 lines
4.4 KiB
C#
131 lines
4.4 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.Movement.Systems;
|
|
using Content.Shared.Popups;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Physics.Events;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Shared.CombatMode;
|
|
|
|
public abstract class SharedCombatModeSystem : EntitySystem
|
|
{
|
|
[Dependency] protected readonly IGameTiming Timing = 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);
|
|
SubscribeLocalEvent<CombatModeComponent, AttemptMobCollideEvent>(OnCollide); // Sunrise-Edit
|
|
}
|
|
|
|
// Sunrise-Start
|
|
private void OnCollide(EntityUid uid, CombatModeComponent component, ref AttemptMobCollideEvent args)
|
|
{
|
|
if (!component.IsInCombatMode)
|
|
{
|
|
args.Cancelled = true;
|
|
}
|
|
}
|
|
// Sunrise-End
|
|
|
|
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);
|
|
|
|
var msg = component.IsInCombatMode ? "action-popup-combat-enabled" : "action-popup-combat-disabled";
|
|
_popup.PopupClient(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
|
|
{
|
|
|
|
}
|