Files
crystall-punk-14/Content.Shared/RCD/RCDPrototype.cs

145 lines
4.8 KiB
C#
Raw Normal View History

Improved RCDs (#22799) * Initial radial menu prototyping for the RCD * Radial UI buttons can send messages to the server * Beginning to update RCDSystem * RCD building system in progress * Further updates * Added extra effects, RCDSystem now reads RCD prototype data * Replacing tiles is instant, multiple constructions are allowed, deconstruction is broken * Added extra functionality to RadialContainers plus documentation * Fixed localization of RCD UI strings * Menu opens near cursor, added basic RCD * Avoiding merge conflict * Implemented atomized construction / deconstruction rules * Increased RCD ammo base charges * Moved input context definition to content * Removed obsoleted code * Updates to system * Switch machine and computer frames for electrical cabling * Added construction ghosts * Fixed issue with keybind detection code * Fixed RCD construction ghost mispredications * Code clean up * Updated deconstruction effects * RCDs effects don't rotate * Code clean up * Balancing for ammo counts * Code clean up * Added missing localized strings * More clean up * Made directional window handling more robust * Added documentation to radial menus and made them no longer dependent on Content * Made radial containers more robust * Further robustness to the radial menu * The RCD submenu buttons are only shown when the destination layer has at least one children * Expanded upon deconstructing plus construction balance * Fixed line endings * Updated list of RCD deconstructable entities. Now needs a component to deconstruct instead of a tag * Bug fixes * Revert unnecessary change * Updated RCD strings * Fixed bug * More fixes * Deconstructed tiles/subflooring convert to lattice instead * Fixed failed tests (Linux doesn't like invalid spritespecifer paths) * Fixing merge conflict * Updated airlock assembly * Fixing merge conflict * Fixing merge conflict * More fixing... * Removed erroneous project file change * Fixed string handling issue * Trying to fix merge conflict * Still fixing merge conflicts * Balancing * Hidden RCD construction ghosts when in 'build' mode * Fixing merge conflict * Implemented requested changes (Part 1) * Added more requested changes * Fix for failed test. Removed sussy null suppression * Made requested changes - custom construction ghost system was replaced * Fixing merge conflict * Fixed merge conflict * Fixed bug in RCD construction ghost validation * Fixing merge conflict * Merge conflict fixed * Made required update * Removed lingering RCD deconstruct tag * Fixing merge conflict * Merge conflict fixed * Made requested changes * Bug fixes and balancing * Made string names more consistent * Can no longer stack catwalks
2024-03-30 23:29:47 -05:00
using Content.Shared.Physics;
using Robust.Shared.Physics.Collision.Shapes;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.RCD;
/// <summary>
/// Contains the parameters for a RCD construction / operation
/// </summary>
[Prototype("rcd")]
public sealed class RCDPrototype : IPrototype
{
[IdDataField]
public string ID { get; private set; } = default!;
/// <summary>
/// The RCD mode associated with the operation
/// </summary>
[DataField(required: true), ViewVariables(VVAccess.ReadOnly)]
public RcdMode Mode { get; private set; } = RcdMode.Invalid;
/// <summary>
/// The name associated with the prototype
/// </summary>
[DataField("name"), ViewVariables(VVAccess.ReadOnly)]
public string SetName { get; private set; } = "Unknown";
/// <summary>
/// The name of the radial container that this prototype will be listed under on the RCD menu
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public string Category { get; private set; } = "Undefined";
/// <summary>
/// Texture path for this prototypes menu icon
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public SpriteSpecifier? Sprite { get; private set; } = null;
/// <summary>
/// The entity prototype that will be constructed (mode dependent)
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public string? Prototype { get; private set; } = string.Empty;
/// <summary>
/// Number of charges consumed when the operation is completed
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public int Cost { get; private set; } = 1;
/// <summary>
/// The length of the operation
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public float Delay { get; private set; } = 1f;
/// <summary>
/// The visual effect that plays during this operation
/// </summary>
[DataField("fx"), ViewVariables(VVAccess.ReadOnly)]
public EntProtoId? Effect { get; private set; } = null;
/// <summary>
/// A list of rules that govern where the entity prototype can be contructed
/// </summary>
[DataField("rules"), ViewVariables(VVAccess.ReadOnly)]
public HashSet<RcdConstructionRule> ConstructionRules { get; private set; } = new();
/// <summary>
/// The collision mask used for determining whether the entity prototype will fit into a target tile
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public CollisionGroup CollisionMask { get; private set; } = CollisionGroup.None;
/// <summary>
/// Specifies a set of custom collision bounds for determining whether the entity prototype will fit into a target tile
/// </summary>
/// <remarks>
/// Should be set assuming that the entity faces south.
/// Make sure that Rotation is set to RcdRotation.User if the entity is to be rotated by the user
/// </remarks>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public Box2? CollisionBounds
{
get
{
return _collisionBounds;
}
private set
{
_collisionBounds = value;
if (_collisionBounds != null)
{
var poly = new PolygonShape();
poly.SetAsBox(_collisionBounds.Value);
CollisionPolygon = poly;
}
}
}
private Box2? _collisionBounds = null;
/// <summary>
/// The polygon shape associated with the prototype CollisionBounds (if set)
/// </summary>
[ViewVariables(VVAccess.ReadOnly)]
public PolygonShape? CollisionPolygon { get; private set; } = null;
/// <summary>
/// Governs how the local rotation of the constructed entity will be set
/// </summary>
[DataField, ViewVariables(VVAccess.ReadOnly)]
public RcdRotation Rotation { get; private set; } = RcdRotation.User;
}
public enum RcdMode : byte
{
Invalid,
Deconstruct,
ConstructTile,
ConstructObject,
}
// These are to be replaced with more flexible 'RulesRule' at a later time
public enum RcdConstructionRule : byte
{
MustBuildOnEmptyTile, // Can only be built on empty space (e.g. lattice)
CanBuildOnEmptyTile, // Can be built on empty space or replace an existing tile (e.g. hull plating)
MustBuildOnSubfloor, // Can only be built on exposed subfloor (e.g. catwalks on lattice or hull plating)
IsWindow, // The entity is a window and can be built on grilles
IsCatwalk, // The entity is a catwalk
}
public enum RcdRotation : byte
{
Fixed, // The entity has a local rotation of zero
Camera, // The rotation of the entity matches the local player camera
User, // The entity can be rotated by the local player prior to placement
}