Compare commits
1 Commits
ed-12-11-2
...
ed-27-06-2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73d0ee0ea1 |
35
Content.Shared/_CP14/Cliffs/CP14CliffComponent.cs
Normal file
35
Content.Shared/_CP14/Cliffs/CP14CliffComponent.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Numerics;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.FixedPoint;
|
||||
using Robust.Shared.Audio;
|
||||
|
||||
namespace Content.Shared._CP14.Cliffs;
|
||||
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class CP14CliffComponent : Component
|
||||
{
|
||||
[DataField(required: true)]
|
||||
public string TriggerFallFixtureId = string.Empty;
|
||||
|
||||
[DataField]
|
||||
public Angle fallDirection = Angle.Zero;
|
||||
|
||||
[DataField]
|
||||
public float LaunchForwardsMultiplier = 2f;
|
||||
|
||||
[DataField]
|
||||
public TimeSpan ParalyzeTime = TimeSpan.FromSeconds(3f);
|
||||
|
||||
[DataField]
|
||||
public DamageSpecifier FallDamage = new()
|
||||
{
|
||||
DamageDict = new Dictionary<string, FixedPoint2>
|
||||
{
|
||||
{ "Blunt", 15.00 },
|
||||
},
|
||||
};
|
||||
|
||||
[DataField]
|
||||
public SoundSpecifier FallSound = new SoundPathSpecifier("/Audio/Effects/slip.ogg");
|
||||
}
|
||||
41
Content.Shared/_CP14/Cliffs/CP14CliffSystem.cs
Normal file
41
Content.Shared/_CP14/Cliffs/CP14CliffSystem.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Content.Shared.Stunnable;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Events;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
|
||||
namespace Content.Shared._CP14.Cliffs;
|
||||
|
||||
public partial class CP14CliffSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CP14CliffComponent, StartCollideEvent>(OnStartCollide);
|
||||
}
|
||||
|
||||
private void OnStartCollide(Entity<CP14CliffComponent> cliff, ref StartCollideEvent args)
|
||||
{
|
||||
if (cliff.Comp.TriggerFallFixtureId != args.OurFixtureId)
|
||||
return;
|
||||
|
||||
if (!TryComp<PhysicsComponent>(args.OtherEntity, out var physics))
|
||||
return;
|
||||
|
||||
_stun.TryParalyze(args.OtherEntity, cliff.Comp.ParalyzeTime, true);
|
||||
_audio.PlayPredicted(cliff.Comp.FallSound, args.OtherEntity, args.OtherEntity);
|
||||
|
||||
var offset = (Transform(cliff).LocalRotation + cliff.Comp.fallDirection).ToWorldVec();
|
||||
var targetPos = _transform.GetWorldPosition(cliff) + offset;
|
||||
_transform.SetWorldPosition(args.OtherEntity, targetPos);
|
||||
|
||||
var velocity = physics.LinearVelocity * cliff.Comp.LaunchForwardsMultiplier;
|
||||
_physics.SetLinearVelocity(args.OtherEntity, velocity, body: physics);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
fix1:
|
||||
hard: false
|
||||
shape:
|
||||
!type:PhysShapeAabb
|
||||
bounds: "0.49,0.49,-0.49,0.25"
|
||||
@@ -24,10 +25,21 @@
|
||||
- TableMask
|
||||
layer:
|
||||
- TableLayer
|
||||
- type: Climbable
|
||||
cliffTrigger:
|
||||
shape:
|
||||
!type:PhysShapeAabb
|
||||
bounds: "0.49,0.59,-0.49,0.35"
|
||||
density: 1000
|
||||
mask:
|
||||
- TableMask
|
||||
layer:
|
||||
- TableLayer
|
||||
- type: CP14Cliff
|
||||
triggerFallFixtureId: cliffTrigger
|
||||
angle: 90
|
||||
|
||||
- type: entity
|
||||
parent: CP14Cliff
|
||||
parent: BaseStructure
|
||||
id: CP14CliffCorner
|
||||
components:
|
||||
- type: Sprite
|
||||
@@ -37,6 +49,8 @@
|
||||
- type: Icon
|
||||
sprite: _CP14/Structures/Walls/Natural/cliffs.rsi
|
||||
state: corner
|
||||
- type: Physics
|
||||
bodyType: Static
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
fix1:
|
||||
|
||||
Reference in New Issue
Block a user