2022-02-17 15:40:03 +13:00
|
|
|
using System.Linq;
|
2019-04-15 21:11:38 -06:00
|
|
|
using Robust.Shared.Map;
|
|
|
|
|
using Robust.Shared.Serialization;
|
2022-02-17 15:40:03 +13:00
|
|
|
using static Content.Shared.Interaction.SharedInteractionSystem;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Shared.Construction
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2022-02-16 00:23:23 -07:00
|
|
|
public abstract class SharedConstructionSystem : EntitySystem
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2022-02-17 15:40:03 +13:00
|
|
|
[Dependency] private readonly IMapManager _mapManager = default!;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Get predicate for construction obstruction checks.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Ignored? GetPredicate(bool canBuildInImpassable, MapCoordinates coords)
|
|
|
|
|
{
|
|
|
|
|
if (!canBuildInImpassable)
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
if (!_mapManager.TryFindGridAt(coords, out var grid))
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
var ignored = grid.GetAnchoredEntities(coords).ToHashSet();
|
|
|
|
|
return e => ignored.Contains(e);
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-02 08:29:55 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Sent client -> server to to tell the server that we started building
|
|
|
|
|
/// a structure-construction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class TryStartStructureConstructionMessage : EntityEventArgs
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Position to start building.
|
|
|
|
|
/// </summary>
|
2020-09-06 16:11:53 +02:00
|
|
|
public readonly EntityCoordinates Location;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The construction prototype to start building.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly string PrototypeName;
|
|
|
|
|
|
|
|
|
|
public readonly Angle Angle;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Identifier to be sent back in the acknowledgement so that the client can clean up its ghost.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly int Ack;
|
|
|
|
|
|
2020-09-06 16:11:53 +02:00
|
|
|
public TryStartStructureConstructionMessage(EntityCoordinates loc, string prototypeName, Angle angle, int ack)
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
|
|
|
|
Location = loc;
|
|
|
|
|
PrototypeName = prototypeName;
|
|
|
|
|
Angle = angle;
|
|
|
|
|
Ack = ack;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-06 10:40:53 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Sent client -> server to to tell the server that we started building
|
|
|
|
|
/// an item-construction.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class TryStartItemConstructionMessage : EntityEventArgs
|
2020-06-06 10:40:53 +02:00
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The construction prototype to start building.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public readonly string PrototypeName;
|
|
|
|
|
|
|
|
|
|
public TryStartItemConstructionMessage(string prototypeName)
|
|
|
|
|
{
|
|
|
|
|
PrototypeName = prototypeName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-15 12:30:11 -07:00
|
|
|
/// <summary>
|
2021-11-02 11:24:32 +01:00
|
|
|
/// Sent server -> client to tell the client that a ghost has started to be constructed.
|
2020-06-15 12:30:11 -07:00
|
|
|
/// </summary>
|
2018-08-02 08:29:55 +02:00
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class AckStructureConstructionMessage : EntityEventArgs
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2020-06-15 12:30:11 -07:00
|
|
|
public readonly int GhostId;
|
2018-08-02 08:29:55 +02:00
|
|
|
|
2020-06-15 12:30:11 -07:00
|
|
|
public AckStructureConstructionMessage(int ghostId)
|
2018-08-02 08:29:55 +02:00
|
|
|
{
|
2020-06-15 12:30:11 -07:00
|
|
|
GhostId = ghostId;
|
2018-08-02 08:29:55 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-11-02 11:24:32 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sent client -> server to request a specific construction guide.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class RequestConstructionGuide : EntityEventArgs
|
2021-11-02 11:24:32 +01:00
|
|
|
{
|
|
|
|
|
public readonly string ConstructionId;
|
|
|
|
|
|
|
|
|
|
public RequestConstructionGuide(string constructionId)
|
|
|
|
|
{
|
|
|
|
|
ConstructionId = constructionId;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sent server -> client as a response to a <see cref="RequestConstructionGuide"/> net message.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class ResponseConstructionGuide : EntityEventArgs
|
2021-11-02 11:24:32 +01:00
|
|
|
{
|
|
|
|
|
public readonly string ConstructionId;
|
|
|
|
|
public readonly ConstructionGuide Guide;
|
|
|
|
|
|
|
|
|
|
public ResponseConstructionGuide(string constructionId, ConstructionGuide guide)
|
|
|
|
|
{
|
|
|
|
|
ConstructionId = constructionId;
|
|
|
|
|
Guide = guide;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-08-02 08:29:55 +02:00
|
|
|
}
|
|
|
|
|
}
|