Красивое УИ телепорта для призрака (#378)

* add: nice ghost teleport ui

* fix: fix unused import

* wtf

* fuck you, search bar

* fix-add: finally
This commit is contained in:
ThereDrD0
2024-06-26 05:13:42 +03:00
committed by GitHub
parent 331eb0ece5
commit e35098f7dd
27 changed files with 835 additions and 239 deletions

View File

@@ -1,8 +1,10 @@
using Content.Shared._White.Antag;
using Content.Shared.Emoting;
using Content.Shared.Hands;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared.Roles;
using Robust.Shared.Serialization;
namespace Content.Shared.Ghost
@@ -62,18 +64,122 @@ namespace Content.Shared.Ghost
{
}
/// <summary>
/// An player body a ghost can warp to.
/// This is used as part of <see cref="GhostWarpsResponseEvent"/>
/// </summary>
[Serializable, NetSerializable]
public struct GhostWarpPlayer
{
public GhostWarpPlayer(NetEntity entity, string playerName, string playerJobName, string playerDepartmentID, bool isGhost, bool isLeft, bool isDead, bool isAlive)
{
Entity = entity;
Name = playerName;
JobName = playerJobName;
DepartmentID = playerDepartmentID;
IsGhost = isGhost;
IsLeft = isLeft;
IsDead = isDead;
IsAlive = isAlive;
}
/// <summary>
/// The entity representing the warp point.
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
/// </summary>
public NetEntity Entity { get; }
/// <summary>
/// The display player name to be surfaced in the ghost warps menu
/// </summary>
public string Name { get; }
/// <summary>
/// The display player job to be surfaced in the ghost warps menu
/// </summary>
public string JobName { get; }
/// <summary>
/// The display player department to be surfaced in the ghost warps menu
/// </summary>
public string DepartmentID { get; set; }
/// <summary>
/// Is player is ghost
/// </summary>
public bool IsGhost { get; }
/// <summary>
/// Is player body alive
/// </summary>
public bool IsAlive { get; }
/// <summary>
/// Is player body dead
/// </summary>
public bool IsDead { get; }
/// <summary>
/// Is player left from body
/// </summary>
public bool IsLeft { get; }
}
[Serializable, NetSerializable]
public struct GhostWarpGlobalAntagonist
{
public GhostWarpGlobalAntagonist(NetEntity entity, string playerName, string antagonistName, string antagonistDescription, string prototypeID)
{
Entity = entity;
Name = playerName;
AntagonistName = antagonistName;
AntagonistDescription = antagonistDescription;
PrototypeID = prototypeID;
}
/// <summary>
/// The entity representing the warp point.
/// This is passed back to the server in <see cref="GhostWarpToTargetRequestEvent"/>
/// </summary>
public NetEntity Entity { get; }
/// <summary>
/// The display player name to be surfaced in the ghost warps menu
/// </summary>
public string Name { get; }
/// <summary>
/// The display antagonist name to be surfaced in the ghost warps menu
/// </summary>
public string AntagonistName { get; }
/// <summary>
/// The display antagonist description to be surfaced in the ghost warps menu
/// </summary>
public string AntagonistDescription { get; }
/// <summary>
/// A antagonist prototype id
/// </summary>
public string PrototypeID { get; }
}
/// <summary>
/// An individual place a ghost can warp to.
/// This is used as part of <see cref="GhostWarpsResponseEvent"/>
/// </summary>
[Serializable, NetSerializable]
public struct GhostWarp
public struct GhostWarpPlace
{
public GhostWarp(NetEntity entity, string displayName, bool isWarpPoint)
public GhostWarpPlace(NetEntity entity, string name, string description)
{
Entity = entity;
DisplayName = displayName;
IsWarpPoint = isWarpPoint;
Name = name;
Description = description;
}
/// <summary>
@@ -85,14 +191,14 @@ namespace Content.Shared.Ghost
/// <summary>
/// The display name to be surfaced in the ghost warps menu
/// </summary>
public string DisplayName { get; }
public string Name { get; }
/// <summary>
/// Whether this warp represents a warp point or a player
/// The display name to be surfaced in the ghost warps menu
/// </summary>
public bool IsWarpPoint { get; }
}
public string Description { get; }
}
/// <summary>
/// A server to client response for a <see cref="GhostWarpsRequestEvent"/>.
/// Contains players, and locations a ghost can warp to
@@ -100,15 +206,27 @@ namespace Content.Shared.Ghost
[Serializable, NetSerializable]
public sealed class GhostWarpsResponseEvent : EntityEventArgs
{
public GhostWarpsResponseEvent(List<GhostWarp> warps)
public GhostWarpsResponseEvent(List<GhostWarpPlayer> players, List<GhostWarpPlace> places, List<GhostWarpGlobalAntagonist> antagonists)
{
Warps = warps;
Players = players;
Places = places;
Antagonists = antagonists;
}
/// <summary>
/// A list of players to teleport.
/// </summary>
public List<GhostWarpPlayer> Players { get; }
/// <summary>
/// A list of warp points.
/// </summary>
public List<GhostWarp> Warps { get; }
public List<GhostWarpPlace> Places { get; }
/// <summary>
/// A list of antagonists to teleport.
/// </summary>
public List<GhostWarpGlobalAntagonist> Antagonists { get; }
}
/// <summary>
@@ -159,3 +277,4 @@ namespace Content.Shared.Ghost
{
}
}

View File

@@ -17,6 +17,10 @@ namespace Content.Shared.Mind.Components
[Access(typeof(SharedMindSystem), Other = AccessPermissions.ReadWriteExecute)] // FIXME Friends
public EntityUid? Mind { get; set; }
[DataField, AutoNetworkedField]
[Access(typeof(SharedMindSystem), Other = AccessPermissions.ReadWriteExecute)]
public EntityUid? LastMindStored { get; set; }
/// <summary>
/// True if we have a mind, false otherwise.
/// </summary>
@@ -59,6 +63,7 @@ namespace Content.Shared.Mind.Components
public MindRemovedMessage(Entity<MindComponent> mind, Entity<MindContainerComponent> container)
: base(mind, container)
{
container.Comp.LastMindStored = mind; // Holy shit
}
}

View File

@@ -8,20 +8,25 @@ public sealed partial class DepartmentPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
/// <summary>
/// A name string.
/// </summary>
[DataField(required: true)]
public string Name = default!;
/// <summary>
/// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
[DataField("description", required: true)]
[DataField (required: true)]
public string Description = default!;
/// <summary>
/// A color representing this department to use for text.
/// </summary>
[DataField("color", required: true)]
[DataField(required: true)]
public Color Color = default!;
[ViewVariables(VVAccess.ReadWrite),
DataField("roles", customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
[ViewVariables(VVAccess.ReadWrite), DataField(customTypeSerializer: typeof(PrototypeIdListSerializer<JobPrototype>))]
public List<string> Roles = new();
/// <summary>
@@ -34,8 +39,14 @@ public sealed partial class DepartmentPrototype : IPrototype
/// <summary>
/// Departments with a higher weight sorted before other departments in UI.
/// </summary>
[DataField("weight")]
[DataField]
public int Weight { get; private set; } = 0;
/// <summary>
/// A style string references to style in StyleNano.cs
/// </summary>
[DataField]
public string ButtonStyle = default!;
}
/// <summary>

View File

@@ -0,0 +1,29 @@
using Robust.Shared.Prototypes;
namespace Content.Shared._White.Antag;
[Prototype("antagonist")]
public sealed partial class AntagonistPrototype : IPrototype
{
[IdDataField] public string ID { get; } = default!;
/// <summary>
/// A name string to display in ghost teleport menu .
/// </summary>
[DataField(required: true)]
public string Name = default!;
/// <summary>
/// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
[DataField(required: true)]
public string Description = default!;
/// <summary>
/// A description string to display in the character menu as an explanation of the department's function.
/// </summary>
[DataField(required: true)]
public int Weight = default!;
}

View File

@@ -0,0 +1,11 @@
using Robust.Shared.GameStates;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared._White.Antag;
[RegisterComponent, NetworkedComponent]
public sealed partial class GlobalAntagonistComponent : Component
{
[DataField(required: true, customTypeSerializer: typeof(PrototypeIdSerializer<AntagonistPrototype>))]
public string? AntagonistPrototype;
}