Glass tables break when climbed on (#6246)
This commit is contained in:
@@ -139,17 +139,17 @@ namespace Content.Server.Climbing.Components
|
||||
{
|
||||
if (eventArgs.User == eventArgs.Dragged)
|
||||
{
|
||||
TryClimb(eventArgs.User);
|
||||
TryClimb(eventArgs.User, eventArgs.Target);
|
||||
}
|
||||
else
|
||||
{
|
||||
TryMoveEntity(eventArgs.User, eventArgs.Dragged);
|
||||
TryMoveEntity(eventArgs.User, eventArgs.Dragged, eventArgs.Target);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private async void TryMoveEntity(EntityUid user, EntityUid entityToMove)
|
||||
private async void TryMoveEntity(EntityUid user, EntityUid entityToMove, EntityUid climbable)
|
||||
{
|
||||
var doAfterEventArgs = new DoAfterEventArgs(user, _climbDelay, default, entityToMove)
|
||||
{
|
||||
@@ -184,6 +184,9 @@ namespace Content.Server.Climbing.Components
|
||||
// we may potentially need additional logic since we're forcing a player onto a climbable
|
||||
// there's also the cases where the user might collide with the person they are forcing onto the climbable that i haven't accounted for
|
||||
|
||||
_entities.EventBus.RaiseLocalEvent(entityToMove, new StartClimbEvent(climbable), false);
|
||||
_entities.EventBus.RaiseLocalEvent(climbable, new ClimbedOnEvent(entityToMove), false);
|
||||
|
||||
var othersMessage = Loc.GetString("comp-climbable-user-climbs-force-other",
|
||||
("user", user), ("moved-user", entityToMove), ("climbable", Owner));
|
||||
user.PopupMessageOtherClients(othersMessage);
|
||||
@@ -193,7 +196,7 @@ namespace Content.Server.Climbing.Components
|
||||
}
|
||||
}
|
||||
|
||||
public async void TryClimb(EntityUid user)
|
||||
public async void TryClimb(EntityUid user, EntityUid climbable)
|
||||
{
|
||||
if (!_entities.TryGetComponent(user, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing)
|
||||
return;
|
||||
@@ -216,6 +219,9 @@ namespace Content.Server.Climbing.Components
|
||||
var direction = (_entities.GetComponent<TransformComponent>(Owner).WorldPosition - userPos).Normalized;
|
||||
var endPoint = _entities.GetComponent<TransformComponent>(Owner).WorldPosition;
|
||||
|
||||
_entities.EventBus.RaiseLocalEvent(user, new StartClimbEvent(climbable), false);
|
||||
_entities.EventBus.RaiseLocalEvent(climbable, new ClimbedOnEvent(user), false);
|
||||
|
||||
var climbMode = _entities.GetComponent<ClimbingComponent>(user);
|
||||
climbMode.IsClimbing = true;
|
||||
|
||||
@@ -239,3 +245,29 @@ namespace Content.Server.Climbing.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised on an entity when it is climbed on.
|
||||
/// </summary>
|
||||
public class ClimbedOnEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid Climber;
|
||||
|
||||
public ClimbedOnEvent(EntityUid climber)
|
||||
{
|
||||
Climber = climber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised on an entity when it successfully climbs on something.
|
||||
/// </summary>
|
||||
public class StartClimbEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid Climbable;
|
||||
|
||||
public StartClimbEvent(EntityUid climbable)
|
||||
{
|
||||
Climbable = climbable;
|
||||
}
|
||||
}
|
||||
|
||||
33
Content.Server/Climbing/Components/GlassTableComponent.cs
Normal file
33
Content.Server/Climbing/Components/GlassTableComponent.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Climbing.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Glass tables shatter and stun you when climbed on.
|
||||
/// This is a really entity-specific behavior, so opted to make it
|
||||
/// not very generalized with regards to naming.
|
||||
/// </summary>
|
||||
[RegisterComponent, Friend(typeof(ClimbSystem))]
|
||||
[ComponentProtoName("GlassTable")]
|
||||
public class GlassTableComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// How much damage should be given to the climber?
|
||||
/// </summary>
|
||||
[DataField("climberDamage")]
|
||||
public DamageSpecifier ClimberDamage = default!;
|
||||
|
||||
/// <summary>
|
||||
/// How much damage should be given to the table when climbed on?
|
||||
/// </summary>
|
||||
[DataField("tableDamage")]
|
||||
public DamageSpecifier TableDamage = default!;
|
||||
|
||||
/// <summary>
|
||||
/// How long should someone who climbs on this table be stunned for?
|
||||
/// </summary>
|
||||
public float StunTime = 5.0f;
|
||||
}
|
||||
Reference in New Issue
Block a user