Minor comp message removal (#6733)

This commit is contained in:
mirrorcult
2022-02-15 20:04:33 -07:00
committed by GitHub
parent 9d422d0762
commit e427381be6
9 changed files with 19 additions and 190 deletions

View File

@@ -237,9 +237,8 @@ namespace Content.Server.Buckle.Components
UpdateBuckleStatus(); UpdateBuckleStatus();
#pragma warning disable 618 var ev = new BuckleChangeEvent() { Buckling = true, Strap = BuckledTo.Owner };
SendMessage(new BuckleMessage(Owner, to)); _entMan.EventBus.RaiseLocalEvent(Owner, ev, false);
#pragma warning restore 618
if (_entMan.TryGetComponent(Owner, out SharedPullableComponent? ownerPullable)) if (_entMan.TryGetComponent(Owner, out SharedPullableComponent? ownerPullable))
{ {
@@ -330,9 +329,8 @@ namespace Content.Server.Buckle.Components
oldBuckledTo.Remove(this); oldBuckledTo.Remove(this);
SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound.GetSound(), Owner); SoundSystem.Play(Filter.Pvs(Owner), oldBuckledTo.UnbuckleSound.GetSound(), Owner);
#pragma warning disable 618 var ev = new BuckleChangeEvent() { Buckling = false, Strap = oldBuckledTo.Owner };
SendMessage(new UnbuckleMessage(Owner, oldBuckledTo.Owner)); _entMan.EventBus.RaiseLocalEvent(Owner, ev, false);
#pragma warning restore 618
return true; return true;
} }

View File

@@ -162,10 +162,6 @@ namespace Content.Server.Buckle.Components
appearance.SetData("StrapState", true); appearance.SetData("StrapState", true);
} }
#pragma warning disable 618
SendMessage(new StrapMessage(buckle.Owner, Owner));
#pragma warning restore 618
return true; return true;
} }
@@ -184,9 +180,6 @@ namespace Content.Server.Buckle.Components
} }
_occupiedSize -= buckle.Size; _occupiedSize -= buckle.Size;
#pragma warning disable 618
SendMessage(new UnStrapMessage(buckle.Owner, Owner));
#pragma warning restore 618
} }
} }

View File

@@ -5,6 +5,7 @@ using Content.Server.Climbing.Components;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Server.Stunnable; using Content.Server.Stunnable;
using Content.Shared.ActionBlocker; using Content.Shared.ActionBlocker;
using Content.Shared.Buckle.Components;
using Content.Shared.Climbing; using Content.Shared.Climbing;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
@@ -33,6 +34,7 @@ namespace Content.Server.Climbing
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset); SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<ClimbableComponent, GetVerbsEvent<AlternativeVerb>>(AddClimbVerb); SubscribeLocalEvent<ClimbableComponent, GetVerbsEvent<AlternativeVerb>>(AddClimbVerb);
SubscribeLocalEvent<ClimbingComponent, BuckleChangeEvent>(OnBuckleChange);
SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed); SubscribeLocalEvent<GlassTableComponent, ClimbedOnEvent>(OnGlassClimbed);
} }
@@ -62,6 +64,12 @@ namespace Content.Server.Climbing
args.Verbs.Add(verb); args.Verbs.Add(verb);
} }
private void OnBuckleChange(EntityUid uid, ClimbingComponent component, BuckleChangeEvent args)
{
if (args.Buckling)
component.IsClimbing = false;
}
private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ClimbedOnEvent args) private void OnGlassClimbed(EntityUid uid, GlassTableComponent component, ClimbedOnEvent args)
{ {
_damageableSystem.TryChangeDamage(args.Climber, component.ClimberDamage); _damageableSystem.TryChangeDamage(args.Climber, component.ClimberDamage);

View File

@@ -53,22 +53,6 @@ namespace Content.Server.Climbing.Components
} }
} }
[Obsolete("Component Messages are deprecated, use Entity Events instead.")]
public override void HandleMessage(ComponentMessage message, IComponent? component)
{
#pragma warning disable 618
base.HandleMessage(message, component);
#pragma warning restore 618
switch (message)
{
case BuckleMessage msg:
if (msg.Buckled)
IsClimbing = false;
break;
}
}
/// <summary> /// <summary>
/// Make the owner climb from one point to another /// Make the owner climb from one point to another
/// </summary> /// </summary>

View File

@@ -110,9 +110,7 @@ namespace Content.Server.Configurable
_config[key] = value; _config[key] = value;
} }
#pragma warning disable 618 // TODO raise event.
SendMessage(new ConfigUpdatedComponentMessage(config));
#pragma warning restore 618
} }
} }

View File

@@ -59,69 +59,15 @@ namespace Content.Shared.Buckle.Components
public int? DrawDepth; public int? DrawDepth;
} }
public sealed class BuckleChangeEvent : EntityEventArgs
{
public EntityUid Strap;
public bool Buckling;
}
[Serializable, NetSerializable] [Serializable, NetSerializable]
public enum BuckleVisuals public enum BuckleVisuals
{ {
Buckled Buckled
} }
[Serializable, NetSerializable]
#pragma warning disable 618
public abstract class BuckleChangeMessage : ComponentMessage
#pragma warning restore 618
{
/// <summary>
/// Constructs a new instance of <see cref="BuckleChangeMessage"/>
/// </summary>
/// <param name="entity">The entity that had its buckling status changed</param>
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
/// <param name="buckled">True if the entity was buckled, false otherwise</param>
protected BuckleChangeMessage(EntityUid entity, EntityUid strap, bool buckled)
{
Entity = entity;
Strap = strap;
Buckled = buckled;
}
/// <summary>
/// The entity that had its buckling status changed
/// </summary>
public EntityUid Entity { get; }
/// <summary>
/// The strap that the entity was buckled to or unbuckled from
/// </summary>
public EntityUid Strap { get; }
/// <summary>
/// True if the entity was buckled, false otherwise.
/// </summary>
public bool Buckled { get; }
}
[Serializable, NetSerializable]
public class BuckleMessage : BuckleChangeMessage
{
/// <summary>
/// Constructs a new instance of <see cref="BuckleMessage"/>
/// </summary>
/// <param name="entity">The entity that had its buckling status changed</param>
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
public BuckleMessage(EntityUid entity, EntityUid strap) : base(entity, strap, true)
{
}
}
[Serializable, NetSerializable]
public class UnbuckleMessage : BuckleChangeMessage
{
/// <summary>
/// Constructs a new instance of <see cref="UnbuckleMessage"/>
/// </summary>
/// <param name="entity">The entity that had its buckling status changed</param>
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
public UnbuckleMessage(EntityUid entity, EntityUid strap) : base(entity, strap, false)
{
}
}
} }

View File

@@ -60,65 +60,4 @@ namespace Content.Shared.Buckle.Components
RotationAngle, RotationAngle,
BuckledState BuckledState
} }
// TODO : Convert this to an Entity Message. Careful, it will Break ShuttleControllerComponent (only place where it's used)
[Serializable, NetSerializable]
#pragma warning disable 618
public abstract class StrapChangeMessage : ComponentMessage
#pragma warning restore 618
{
/// <summary>
/// Constructs a new instance of <see cref="StrapChangeMessage"/>
/// </summary>
/// <param name="entity">The entity that had its buckling status changed</param>
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
/// <param name="buckled">True if the entity was buckled, false otherwise</param>
protected StrapChangeMessage(EntityUid entity, EntityUid strap, bool buckled)
{
Entity = entity;
Strap = strap;
Buckled = buckled;
}
/// <summary>
/// The entity that had its buckling status changed
/// </summary>
public EntityUid Entity { get; }
/// <summary>
/// The strap that the entity was buckled to or unbuckled from
/// </summary>
public EntityUid Strap { get; }
/// <summary>
/// True if the entity was buckled, false otherwise.
/// </summary>
public bool Buckled { get; }
}
[Serializable, NetSerializable]
public class StrapMessage : StrapChangeMessage
{
/// <summary>
/// Constructs a new instance of <see cref="StrapMessage"/>
/// </summary>
/// <param name="entity">The entity that had its buckling status changed</param>
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
public StrapMessage(EntityUid entity, EntityUid strap) : base(entity, strap, true)
{
}
}
[Serializable, NetSerializable]
public class UnStrapMessage : StrapChangeMessage
{
/// <summary>
/// Constructs a new instance of <see cref="UnStrapMessage"/>
/// </summary>
/// <param name="entity">The entity that had its buckling status changed</param>
/// <param name="strap">The strap that the entity was buckled to or unbuckled from</param>
public UnStrapMessage(EntityUid entity, EntityUid strap) : base(entity, strap, false)
{
}
}
} }

View File

@@ -18,21 +18,6 @@ namespace Content.Shared.Configurable
} }
} }
/// <summary>
/// Message sent to other components on this entity when DeviceNetwork configuration updated.
/// </summary>
#pragma warning disable 618
public class ConfigUpdatedComponentMessage : ComponentMessage
#pragma warning restore 618
{
public Dictionary<string, string> Config { get; }
public ConfigUpdatedComponentMessage(Dictionary<string, string> config)
{
Config = config;
}
}
/// <summary> /// <summary>
/// Message data sent from client to server when the device configuration is updated. /// Message data sent from client to server when the device configuration is updated.
/// </summary> /// </summary>

View File

@@ -1,22 +0,0 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.Singularity
{
[Serializable, NetSerializable]
#pragma warning disable 618
public class SingularitySoundMessage : ComponentMessage
#pragma warning restore 618
{
public bool Start { get; }
public SingularitySoundMessage(bool start)
{
Directed = true;
Start = start;
}
}
}