Remove ILand (#4582)

* Remove ILand

* Make land not handleable

* Rename ILand
This commit is contained in:
metalgearsloth
2021-09-12 16:22:58 +10:00
committed by GitHub
parent 0137884e16
commit f301e45163
13 changed files with 99 additions and 103 deletions

View File

@@ -1,37 +1,14 @@
using System;
using JetBrains.Annotations;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.Shared.Throwing
{
/// <summary>
/// This interface gives components behavior when landing after being thrown.
/// </summary>
[RequiresExplicitImplementation]
public interface ILand
{
void Land(LandEventArgs eventArgs);
}
public class LandEventArgs : EventArgs
{
public LandEventArgs(IEntity? user, EntityCoordinates landingLocation)
{
User = user;
LandingLocation = landingLocation;
}
public IEntity? User { get; }
public EntityCoordinates LandingLocation { get; }
}
/// <summary>
/// Raised when an entity that was thrown lands.
/// </summary>
[PublicAPI]
public class LandEvent : HandledEntityEventArgs
public sealed class LandEvent : EntityEventArgs
{
/// <summary>
/// Entity that threw the item.

View File

@@ -124,25 +124,8 @@ namespace Content.Shared.Throwing
var user = thrownItem.Thrower;
var coordinates = landing.Transform.Coordinates;
// LandInteraction
// TODO: Refactor these to system messages
var landMsg = new LandEvent(user, landing, coordinates);
RaiseLocalEvent(landing.Uid, landMsg);
if (landMsg.Handled)
{
return;
}
var comps = landing.GetAllComponents<ILand>().ToArray();
var landArgs = new LandEventArgs(user, coordinates);
// Call Land on all components that implement the interface
foreach (var comp in comps)
{
if (landing.Deleted) break;
comp.Land(landArgs);
}
ComponentManager.RemoveComponent(landing.Uid, thrownItem);
}