Skip to content

Commit

Permalink
port carrying
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian16199 authored and Leander-0 committed Oct 27, 2023
1 parent d475d41 commit b067904
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 17 deletions.
27 changes: 15 additions & 12 deletions Content.Server/Nyanotrasen/Carrying/CarryingSystem.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Threading;
using Content.Server.DoAfter;
using Content.Server.Body.Systems;
using Content.Server.Hands.Systems;
using Content.Server.Resist;
using Content.Server.Popups;
using Content.Server.Contests;
using Content.Shared.Climbing; // Shared instead of Server
using Content.Shared.Mobs;
using Content.Shared.DoAfter;
using Content.Shared.Buckle.Components;
Expand All @@ -11,14 +14,14 @@
using Content.Shared.Stunnable;
using Content.Shared.Interaction.Events;
using Content.Shared.Verbs;
using Content.Shared.Climbing.Events; // Added this.
using Content.Shared.Carrying;
using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems;
using Content.Shared.Pulling;
using Content.Shared.Pulling.Components;
using Content.Shared.Standing;
using Content.Shared.ActionBlocker;
using Content.Shared.Climbing.Events;
using Content.Shared.Throwing;
using Content.Shared.Physics.Pull;
using Content.Shared.Mobs.Systems;
Expand All @@ -30,7 +33,7 @@ public sealed class CarryingSystem : EntitySystem
{
[Dependency] private readonly HandVirtualItemSystem _virtualItemSystem = default!;
[Dependency] private readonly CarryingSlowdownSystem _slowdown = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly StandingStateSystem _standingState = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly SharedPullingSystem _pullingSystem = default!;
Expand All @@ -57,7 +60,7 @@ public override void Initialize()
SubscribeLocalEvent<BeingCarriedComponent, PullAttemptEvent>(OnPullAttempt);
SubscribeLocalEvent<BeingCarriedComponent, StartClimbEvent>(OnStartClimb);
SubscribeLocalEvent<BeingCarriedComponent, BuckleChangeEvent>(OnBuckleChange);
SubscribeLocalEvent<CarriableComponent, DoAfterEvent>(OnDoAfter);
SubscribeLocalEvent<CarriableComponent, CarryDoAfterEvent>(OnDoAfter);
}


Expand Down Expand Up @@ -191,7 +194,7 @@ private void OnBuckleChange(EntityUid uid, BeingCarriedComponent component, ref
DropCarried(component.Carrier, uid);
}

private void OnDoAfter(EntityUid uid, CarriableComponent component, DoAfterEvent args)
private void OnDoAfter(EntityUid uid, CarriableComponent component, CarryDoAfterEvent args)
{
component.CancelToken = null;
if (args.Handled || args.Cancelled)
Expand All @@ -205,14 +208,14 @@ private void OnDoAfter(EntityUid uid, CarriableComponent component, DoAfterEvent
}
private void StartCarryDoAfter(EntityUid carrier, EntityUid carried, CarriableComponent component)
{
float length = 3f;
TimeSpan length = TimeSpan.FromSeconds(3);

var mod = _contests.MassContest(carrier, carried);

if (mod != 0)
length /= mod;

if (length >= 9)
if (length >= TimeSpan.FromSeconds(9))
{
_popupSystem.PopupEntity(Loc.GetString("carry-too-heavy"), carried, carrier, Shared.Popups.PopupType.SmallCaution);
return;
Expand All @@ -221,7 +224,10 @@ private void StartCarryDoAfter(EntityUid carrier, EntityUid carried, CarriableCo
if (!HasComp<KnockedDownComponent>(carried))
length *= 2f;

var args = new DoAfterArgs(EntityManager, carrier, length, new CarryDoAfterEvent(), carried, target: carried)
component.CancelToken = new CancellationTokenSource();

var ev = new CarryDoAfterEvent();
var args = new DoAfterArgs(EntityManager, carrier, length, ev, carried, target: carried)
{
BreakOnTargetMove = true,
BreakOnUserMove = true,
Expand Down Expand Up @@ -293,8 +299,8 @@ public bool CanCarry(EntityUid carrier, EntityUid carried, CarriableComponent? c
if (HasComp<BeingCarriedComponent>(carrier) || HasComp<BeingCarriedComponent>(carried))
return false;

if (_respirator.IsReceivingCPR(carried))
return false;
// if (_respirator.IsReceivingCPR(carried))
// return false;

if (!TryComp<HandsComponent>(carrier, out var hands))
return false;
Expand All @@ -304,8 +310,5 @@ public bool CanCarry(EntityUid carrier, EntityUid carried, CarriableComponent? c

return true;
}

private record struct CarryData()
{}
}
}
17 changes: 14 additions & 3 deletions Content.Server/Resist/EscapeInventorySystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using Content.Server.Contests;
using Content.Server.Popups;
using Content.Shared.Storage;
using Content.Server.Carrying; // Carrying system from Nyanotrasen.
using Content.Shared.Inventory;
using Content.Shared.Hands.EntitySystems;
using Content.Server.Storage.Components;
using Content.Shared.ActionBlocker;
using Content.Shared.DoAfter;
Expand All @@ -23,7 +27,7 @@ public sealed class EscapeInventorySystem : EntitySystem
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly ContestsSystem _contests = default!;
[Dependency] private readonly CarryingSystem _carryingSystem = default!;
[Dependency] private readonly CarryingSystem _carryingSystem = default!; // Carrying system from Nyanotrasen.

/// <summary>
/// You can't escape the hands of an entity this many times more massive than you.
Expand Down Expand Up @@ -67,7 +71,7 @@ private void OnRelayMovement(EntityUid uid, CanEscapeInventoryComponent componen
AttemptEscape(uid, container.Owner, component);
}

public void AttemptEscape(EntityUid user, EntityUid container, CanEscapeInventoryComponent component, float multiplier = 1f)
public void AttemptEscape(EntityUid user, EntityUid container, CanEscapeInventoryComponent component, float multiplier = 1f) //private to public for carrying system.
{
if (component.IsEscaping)
return;
Expand Down Expand Up @@ -96,7 +100,14 @@ private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, Esca
if (args.Handled || args.Cancelled)
return;

if (TryComp<BeingCarriedComponent>(uid, out var carried))
if (TryComp<BeingCarriedComponent>(uid, out var carried)) // Start of carrying system of nyanotrasen.
{
_carryingSystem.DropCarried(carried.Carrier, uid);
return;
} // End of carrying system of nyanotrasen.


if (TryComp<BeingCarriedComponent>(uid, out carried))
{
_carryingSystem.DropCarried(carried.Carrier, uid);
return;
Expand Down
12 changes: 12 additions & 0 deletions Content.Shared/Nyanotrasen/Carrying/CarryingDoAfterEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Robust.Shared.Serialization;
using Content.Shared.DoAfter;

namespace Content.Shared.Carrying
{
}

[Serializable, NetSerializable]
public sealed partial class CarryDoAfterEvent : SimpleDoAfterEvent
{
}

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public sealed partial class CarryingSlowdownComponent : Component
}

[Serializable, NetSerializable]
public sealed partial class CarryingSlowdownComponentState : ComponentState
public sealed class CarryingSlowdownComponentState : ComponentState
{
public float WalkModifier;
public float SprintModifier;
Expand Down
3 changes: 3 additions & 0 deletions Resources/Locale/en-US/nyanotrasen/carrying/carry.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
carry-verb = Carry
carry-too-heavy = You're not strong enough.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
types:
Cold: 0.05
Bloodloss: 0.1
- type: Carriable # Carrying system from nyanotrasen.
- type: Thirst
baseDecayRate: 0.0125
- type: Icon
Expand Down Expand Up @@ -84,7 +85,6 @@
damageContainer: Biological
damageModifierSet: Vulps
- type: Perishable
- type: Carriable
- type: TemperatureProtection
coefficient: 0.1
- type: Temperature
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/arachnid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
types:
Cold: 0.1
Bloodloss: 0.1
- type: Carriable # Carrying system from nyanotrasen.
- type: Thirst
baseDecayRate: 0.0125 # Read comment in hunger
# Damage (Self)
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
- type: MobPrice
price: 1500 # Kidnapping a living person and selling them for cred is a good move.
deathPenalty: 0.01 # However they really ought to be living and intact, otherwise they're worth 100x less.
- type: CanEscapeInventory # Carrying system from nyanotrasen.
- type: Tag
tags:
- CanPilot
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
baseDecayRate: 0.0083
- type: Thirst
baseDecayRate: 0.0083
- type: Carriable # Carrying system from nyanotrasen.
- type: Icon
sprite: Mobs/Species/Diona/parts.rsi
state: full
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/dwarf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
Cold: 0.1
Bloodloss: 0.1
- type: Thirst
- type: Carriable # Carrying system from nyanotrasen.
- type: Icon
sprite: Mobs/Species/Slime/parts.rsi # It was like this beforehand, no idea why.
state: full
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/human.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
sprite: Mobs/Species/Human/parts.rsi
state: full
- type: Thirst
- type: Carriable # Carrying system from nyanotrasen.
- type: Perishable
- type: Butcherable
butcheringType: Spike
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/moth.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Cold: 0.05
Bloodloss: 0.1
- type: Thirst
- type: Carriable # Carrying system from nyanotrasen.
- type: Icon
sprite: Mobs/Species/Moth/parts.rsi
state: full
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/reptilian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- type: Puller
needsHands: false
- type: Thirst
- type: Carriable # Carrying system from nyanotrasen.
- type: Icon
sprite: Mobs/Species/Reptilian/parts.rsi
state: full
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/skeleton.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
components:
- type: HumanoidAppearance
species: Skeleton
- type: Carriable # Carrying system from nyanotrasen.
- type: Icon
sprite: Mobs/Species/Skeleton/parts.rsi
state: full
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Species/slime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
types:
Bloodloss: 0.1
- type: Thirst
- type: Carriable # Carrying system from nyanotrasen.
- type: Icon
sprite: Mobs/Species/Slime/parts.rsi
state: full
Expand Down

0 comments on commit b067904

Please sign in to comment.