Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Content.Client/_Goobstation/MartialArts/MartialArtsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Content.Shared._Goobstation.MartialArts;

namespace Content.Client._Goobstation.MartialArts;

/// <summary>
/// This handles...
/// </summary>
public sealed class MartialArtsSystem : SharedMartialArtsSystem
{
}
19 changes: 18 additions & 1 deletion Content.Server/Body/Systems/RespiratorSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Content.Server.Chat.Systems;
using Content.Server.EntityEffects.EffectConditions;
using Content.Server.EntityEffects.Effects;
using Content.Shared._Goobstation.MartialArts.Components; // Goobstation - Martial Arts
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Alert;
using Content.Shared.Atmos;
Expand All @@ -21,6 +22,8 @@
using JetBrains.Annotations;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.Movement.Pulling.Components; // Goobstation
using Content.Shared.Movement.Pulling.Systems; // Goobstation

namespace Content.Server.Body.Systems;

Expand Down Expand Up @@ -52,6 +55,20 @@ public override void Initialize()
SubscribeLocalEvent<RespiratorComponent, ApplyMetabolicMultiplierEvent>(OnApplyMetabolicMultiplier);
}

// Goobstation start
// Can breathe check for grab
public bool CanBreathe(EntityUid uid, RespiratorComponent respirator)
{
if(respirator.Saturation < respirator.SuffocationThreshold)
return false;
if (TryComp<PullableComponent>(uid, out var pullable)
&& pullable.GrabStage == GrabStage.Suffocate)
return false;

return !HasComp<KravMagaBlockedBreathingComponent>(uid);
}
// Goobstation end

private void OnMapInit(Entity<RespiratorComponent> ent, ref MapInitEvent args)
{
ent.Comp.NextUpdate = _gameTiming.CurTime + ent.Comp.UpdateInterval;
Expand Down Expand Up @@ -111,7 +128,7 @@ public override void Update(float frameTime)
}
}

if (respirator.Saturation < respirator.SuffocationThreshold)
if (!CanBreathe(uid, respirator)) // Goobstation
{
if (_gameTiming.CurTime >= respirator.LastGaspEmoteTime + respirator.GaspEmoteCooldown)
{
Expand Down
31 changes: 29 additions & 2 deletions Content.Server/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.CombatMode;
using Content.Shared.Damage.Systems;
using Content.Shared.Explosion;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Input;
Expand Down Expand Up @@ -94,7 +95,7 @@ private void OnDisarmed(EntityUid uid, HandsComponent component, DisarmedEvent a

// Break any pulls
if (TryComp(uid, out PullerComponent? puller) && TryComp(puller.Pulling, out PullableComponent? pullable))
_pullingSystem.TryStopPull(puller.Pulling.Value, pullable);
_pullingSystem.TryStopPull(puller.Pulling.Value, pullable, ignoreGrab: true); // Goobstation: Added check for grab

var offsetRandomCoordinates = _transformSystem.GetMoverCoordinates(args.Target).Offset(_random.NextVector2(1f, 1.5f));
if (!ThrowHeldItem(args.Target, offsetRandomCoordinates))
Expand Down Expand Up @@ -201,6 +202,20 @@ private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates co
if (playerSession?.AttachedEntity is not { Valid: true } player || !Exists(player))
return false;

// Goobstation start
if (TryGetActiveItem(player, out var item) && TryComp<VirtualItemComponent>(item, out var virtComp))
{
var userEv = new VirtualItemDropAttemptEvent(virtComp.BlockingEntity, player, item.Value, true);
RaiseLocalEvent(player, userEv);

var targEv = new VirtualItemDropAttemptEvent(virtComp.BlockingEntity, player, item.Value, true);
RaiseLocalEvent(virtComp.BlockingEntity, targEv);

if (userEv.Cancelled || targEv.Cancelled)
return false;
}
// Goobstation end

return ThrowHeldItem(player, coordinates);
}

Expand All @@ -215,6 +230,19 @@ hands.ActiveHandEntity is not { } throwEnt ||
!_actionBlockerSystem.CanThrow(player, throwEnt))
return false;

// Goobstation start: Added throwing for grabbed mobs, mnoved direction.
var direction = _transformSystem.ToMapCoordinates(coordinates).Position - _transformSystem.GetWorldPosition(player);

if (TryComp<VirtualItemComponent>(throwEnt, out var virt))
{
var userEv = new VirtualItemThrownEvent(virt.BlockingEntity, player, throwEnt, direction);
RaiseLocalEvent(player, userEv);

var targEv = new VirtualItemThrownEvent(virt.BlockingEntity, player, throwEnt, direction);
RaiseLocalEvent(virt.BlockingEntity, targEv);
}
// Goobstation end

if (_timing.CurTime < hands.NextThrowTime)
return false;
hands.NextThrowTime = _timing.CurTime + hands.ThrowCooldown;
Expand All @@ -229,7 +257,6 @@ hands.ActiveHandEntity is not { } throwEnt ||
throwEnt = splitStack.Value;
}

var direction = coordinates.ToMapPos(EntityManager, _transformSystem) - Transform(player).WorldPosition;
if (direction == Vector2.Zero)
return true;

Expand Down
11 changes: 9 additions & 2 deletions Content.Server/Stunnable/Systems/StunbatonSystem.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Server.Power.Events;
using Content.Server.Stunnable.Components;
using Content.Shared._Goobstation.MartialArts;
using Content.Shared.Chemistry.EntitySystems;
using Content.Shared.Damage.Events;
using Content.Shared.Examine;
Expand Down Expand Up @@ -31,11 +33,16 @@ public override void Initialize()

private void OnStaminaHitAttempt(Entity<StunbatonComponent> entity, ref StaminaDamageOnHitAttemptEvent args)
{
if (!_itemToggle.IsActivated(entity.Owner) ||
!TryComp<BatteryComponent>(entity.Owner, out var battery) || !_battery.TryUseCharge(entity.Owner, entity.Comp.EnergyPerUse, battery))
// Goobstation start
var energy = entity.Comp.EnergyPerUse;

if (!_itemToggle.IsActivated(entity.Owner)
|| !TryComp<BatteryComponent>(entity.Owner, out var battery)
|| !_battery.TryUseCharge(entity.Owner, energy, battery))
{
args.Cancelled = true;
}
// Goobstation end
}

private void OnExamined(Entity<StunbatonComponent> entity, ref ExaminedEvent args)
Expand Down
7 changes: 4 additions & 3 deletions Content.Server/Weapons/Melee/MeleeWeaponSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Robust.Shared.Player;
using System.Linq;
using System.Numerics;
using Content.Shared._Goobstation.MartialArts.Events;

namespace Content.Server.Weapons.Melee;

Expand Down Expand Up @@ -88,10 +89,10 @@ protected override void DoDamageEffect(List<EntityUid> targets, EntityUid? user,
{
// Filter out any deleted entities that may have been destroyed by the damage
var validTargets = targets.Where(t => !Deleted(t)).ToList();

if (validTargets.Count == 0)
return;

// Use coordinates from the targetXform if valid, otherwise fall back to user coordinates
var coordinates = targetXform.Coordinates;
if (!coordinates.IsValid(EntityManager))
Expand All @@ -101,7 +102,7 @@ protected override void DoDamageEffect(List<EntityUid> targets, EntityUid? user,
else
return; // No valid coordinates available
}

var filter = Filter.Pvs(coordinates, entityMan: EntityManager).RemoveWhereAttachedEntity(o => o == user);
_color.RaiseEffect(Color.Red, validTargets, filter);
}
Expand Down
26 changes: 26 additions & 0 deletions Content.Server/_Goobstation/MartialArts/MartialArtsSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using Content.Server.Chat.Systems;
using Content.Shared.Chat; // HardLight
using Content.Shared._Goobstation.MartialArts;
using Content.Shared._Goobstation.MartialArts.Components;
using Content.Shared._Goobstation.MartialArts.Events;

namespace Content.Server._Goobstation.MartialArts;

/// <summary>
/// Just handles carp sayings for now.
/// </summary>
public sealed class MartialArtsSystem : SharedMartialArtsSystem
{
[Dependency] private readonly ChatSystem _chat = default!;

public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CanPerformComboComponent, SleepingCarpSaying>(OnSleepingCarpSaying);
}

private void OnSleepingCarpSaying(Entity<CanPerformComboComponent> ent, ref SleepingCarpSaying args)
{
_chat.TrySendInGameICMessage(ent, Loc.GetString(args.Saying), InGameICChatType.Speak, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void RandomTeleport(EntityUid uid, float radius, SoundSpecifier sound, in
// We need stop the user from being pulled so they don't just get "attached" with whoever is pulling them.
// This can for example happen when the user is cuffed and being pulled.
if (TryComp<PullableComponent>(uid, out var pull) && _pullingSystem.IsPulled(uid, pull))
_pullingSystem.TryStopPull(uid, pull);
_pullingSystem.TryStopPull(uid, pull, ignoreGrab: true); // HardLight: pullable<pull

var xform = Transform(uid);
var entityCoords = xform.Coordinates.ToMap(EntityManager, _xform);
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Administration/SharedAdminFrozenSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private void OnStartup(EntityUid uid, AdminFrozenComponent component, ComponentS
{
if (TryComp<PullableComponent>(uid, out var pullable))
{
_pulling.TryStopPull(uid, pullable);
_pulling.TryStopPull(uid, pullable, ignoreGrab: true); // Goobstation
}

UpdateCanMove(uid, component, args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void OnAnchorComplete(EntityUid uid, AnchorableComponent component, TryA

if (TryComp<PullableComponent>(uid, out var pullable) && pullable.Puller != null)
{
_pulling.TryStopPull(uid, pullable);
_pulling.TryStopPull(uid, pullable, ignoreGrab: true); // Goobstation
}

// TODO: Anchoring snaps rn anyway!
Expand Down
12 changes: 7 additions & 5 deletions Content.Shared/Cuffs/SharedCuffableSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Item;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Popups;
using Content.Shared.Pulling.Events;
using Content.Shared.Rejuvenate;
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Stunnable;
using Content.Shared.Timing;
using Content.Shared.Verbs;
Expand Down Expand Up @@ -813,10 +815,10 @@ public IReadOnlyList<EntityUid> GetAllCuffs(CuffableComponent component)
private sealed partial class UnCuffDoAfterEvent : SimpleDoAfterEvent
{
}

[Serializable, NetSerializable]
private sealed partial class AddCuffDoAfterEvent : SimpleDoAfterEvent
{
}
}
}

[Serializable, NetSerializable]
public sealed partial class AddCuffDoAfterEvent : SimpleDoAfterEvent // Goobstation: Moved out of class made public
{
}
8 changes: 8 additions & 0 deletions Content.Shared/Damage/Systems/StaminaSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Content.Shared._Goobstation.MartialArts.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Alert;
using Content.Shared.CCVar;
Expand Down Expand Up @@ -145,6 +146,13 @@ private void OnMeleeHit(EntityUid uid, StaminaDamageOnHitComponent component, Me
return;
}

// Goobstation - Martial Arts
if (TryComp<MartialArtsKnowledgeComponent>(args.User, out var knowledgeComp)
&& TryComp<MartialArtBlockedComponent>(args.Weapon, out var blockedComp)
&& knowledgeComp.MartialArtsForm == blockedComp.Form)
return;
// Goobstation

var ev = new StaminaDamageOnHitAttemptEvent();
RaiseLocalEvent(uid, ref ev);
if (ev.Cancelled)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,27 @@ private void SwapHandsPreviousPressed(ICommonSession? session)
private bool DropPressed(ICommonSession? session, EntityCoordinates coords, EntityUid netEntity)
{
if (TryComp(session?.AttachedEntity, out HandsComponent? hands) && hands.ActiveHand != null)
TryDrop(session.AttachedEntity.Value, hands.ActiveHand, coords, handsComp: hands);
{
// Goobstation start
if (session != null)
{
var ent = session.AttachedEntity.Value;

if (TryGetActiveItem(ent, out var item) && TryComp<VirtualItemComponent>(item, out var virtComp))
{
var userEv = new VirtualItemDropAttemptEvent(virtComp.BlockingEntity, ent, item.Value, false);
RaiseLocalEvent(ent, userEv);

var targEv = new VirtualItemDropAttemptEvent(virtComp.BlockingEntity, ent, item.Value, false);
RaiseLocalEvent(virtComp.BlockingEntity, targEv);

if (userEv.Cancelled || targEv.Cancelled)
return false;
}
TryDrop(ent, hands.ActiveHand, coords, handsComp: hands);
}
// Goobstation end
}

// always send to server.
return false;
Expand Down
2 changes: 2 additions & 0 deletions Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Content.Shared.Storage.EntitySystems;
using Robust.Shared.Containers;
using Robust.Shared.Input.Binding;
using Robust.Shared.Network;

namespace Content.Shared.Hands.EntitySystems;

Expand All @@ -19,6 +20,7 @@ public abstract partial class SharedHandsSystem
[Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly INetManager _net = default!;
[Dependency] private readonly SharedStorageSystem _storage = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;
[Dependency] private readonly SharedVirtualItemSystem _virtualSystem = default!;
Expand Down
46 changes: 45 additions & 1 deletion Content.Shared/Hands/HandEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ public PickupAnimationEvent(NetEntity itemUid,
}
}

// Goobstation start
// Added virtual items for grab intent, this is heavily edited please do not bulldoze.
/// <summary>
/// Raised directed on both the blocking entity and user when
/// a virtual hand item is deleted.
Expand All @@ -148,14 +150,56 @@ public sealed class VirtualItemDeletedEvent : EntityEventArgs
{
public EntityUid BlockingEntity;
public EntityUid User;
public EntityUid VirtualItem;

public VirtualItemDeletedEvent(EntityUid blockingEntity, EntityUid user)
public VirtualItemDeletedEvent(EntityUid blockingEntity, EntityUid user, EntityUid virtualItem)
{
BlockingEntity = blockingEntity;
User = user;
VirtualItem = virtualItem;
}
}

/// <summary>
/// Raised directed on both the blocking entity and user when
/// a virtual hand item is thrown (at least attempted to).
/// </summary>
public sealed class VirtualItemThrownEvent : EntityEventArgs
{
public EntityUid BlockingEntity;
public EntityUid User;
public EntityUid VirtualItem;
public Vector2 Direction;
public VirtualItemThrownEvent(EntityUid blockingEntity, EntityUid user, EntityUid virtualItem, Vector2 direction)
{
BlockingEntity = blockingEntity;
User = user;
VirtualItem = virtualItem;
Direction = direction;
}
}

/// <summary>
/// Raised directed on both the blocking entity and user when
/// user tries to drop it by keybind.
/// Cancellable.
/// </summary>
public sealed class VirtualItemDropAttemptEvent : CancellableEntityEventArgs
{
public EntityUid BlockingEntity;
public EntityUid User;
public EntityUid VirtualItem;
public bool Throw;
public VirtualItemDropAttemptEvent(EntityUid blockingEntity, EntityUid user, EntityUid virtualItem, bool thrown)
{
BlockingEntity = blockingEntity;
User = user;
VirtualItem = virtualItem;
Throw = thrown;
}
}
// Goobstation end

/// <summary>
/// Raised when putting an entity into a hand slot
/// </summary>
Expand Down
Loading
Loading