2018-08-21 00:59:04 +02:00
|
|
|
|
using Content.Server.Mobs;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Server.Interfaces.Player;
|
|
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Network;
|
|
|
|
|
|
using Robust.Shared.ViewVariables;
|
2018-08-21 00:59:04 +02:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Players
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Content side for all data that tracks a player session.
|
|
|
|
|
|
/// Use <see cref="PlayerDataExt.ContentData(IPlayerData)"/> to retrieve this from an <see cref="IPlayerData"/>.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public sealed class PlayerData
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The session ID of the player owning this data.
|
|
|
|
|
|
/// </summary>
|
2018-09-09 15:34:43 +02:00
|
|
|
|
[ViewVariables]
|
2018-08-21 00:59:04 +02:00
|
|
|
|
public NetSessionId SessionId { get; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The currently occupied mind of the player owning this data.
|
2018-11-24 19:12:22 +01:00
|
|
|
|
/// DO NOT DIRECTLY SET THIS UNLESS YOU KNOW WHAT YOU'RE DOING.
|
2018-08-21 00:59:04 +02:00
|
|
|
|
/// </summary>
|
2018-09-09 15:34:43 +02:00
|
|
|
|
[ViewVariables]
|
2018-08-21 00:59:04 +02:00
|
|
|
|
public Mind Mind { get; set; }
|
|
|
|
|
|
|
2018-11-24 19:12:22 +01:00
|
|
|
|
public void WipeMind()
|
|
|
|
|
|
{
|
2018-11-25 12:52:31 +01:00
|
|
|
|
Mind?.ChangeOwningPlayer(null);
|
|
|
|
|
|
Mind = null;
|
2018-11-24 19:12:22 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-21 00:59:04 +02:00
|
|
|
|
public PlayerData(NetSessionId sessionId)
|
|
|
|
|
|
{
|
|
|
|
|
|
SessionId = sessionId;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static class PlayerDataExt
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the correctly cast instance of content player data from an engine player data storage.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static PlayerData ContentData(this IPlayerData data)
|
|
|
|
|
|
{
|
|
|
|
|
|
return (PlayerData)data.ContentDataUncast;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Gets the correctly cast instance of content player data from an engine player data storage.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public static PlayerData ContentData(this IPlayerSession session)
|
|
|
|
|
|
{
|
|
|
|
|
|
return session.Data.ContentData();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|