ECS and bandaid research (#9251)
This commit is contained in:
@@ -2,68 +2,63 @@
|
||||
|
||||
namespace Content.Shared.Research.Components
|
||||
{
|
||||
[Virtual]
|
||||
public class SharedResearchClientComponent : Component
|
||||
/// <summary>
|
||||
/// Sent to the server when the client deselects a research server.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientServerDeselectedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Request that the server updates the client.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientSyncMessage : BoundUserInterfaceMessage
|
||||
public ResearchClientServerDeselectedMessage()
|
||||
{
|
||||
|
||||
public ResearchClientSyncMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent to the server when the client chooses a research server.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientServerSelectedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int ServerId;
|
||||
|
||||
public ResearchClientServerSelectedMessage(int serverId)
|
||||
{
|
||||
ServerId = serverId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent to the server when the client deselects a research server.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientServerDeselectedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ResearchClientServerDeselectedMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum ResearchClientUiKey
|
||||
{
|
||||
Key,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientBoundInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public int ServerCount;
|
||||
public string[] ServerNames;
|
||||
public int[] ServerIds;
|
||||
public int SelectedServerId;
|
||||
|
||||
public ResearchClientBoundInterfaceState(int serverCount, string[] serverNames, int[] serverIds, int selectedServerId = -1)
|
||||
{
|
||||
ServerCount = serverCount;
|
||||
ServerNames = serverNames;
|
||||
ServerIds = serverIds;
|
||||
SelectedServerId = selectedServerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sent to the server when the client chooses a research server.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientServerSelectedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int ServerId;
|
||||
|
||||
public ResearchClientServerSelectedMessage(int serverId)
|
||||
{
|
||||
ServerId = serverId;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request that the server updates the client.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientSyncMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
|
||||
public ResearchClientSyncMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum ResearchClientUiKey
|
||||
{
|
||||
Key,
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchClientBoundInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public int ServerCount;
|
||||
public string[] ServerNames;
|
||||
public int[] ServerIds;
|
||||
public int SelectedServerId;
|
||||
|
||||
public ResearchClientBoundInterfaceState(int serverCount, string[] serverNames, int[] serverIds, int selectedServerId = -1)
|
||||
{
|
||||
ServerCount = serverCount;
|
||||
ServerNames = serverNames;
|
||||
ServerIds = serverIds;
|
||||
SelectedServerId = selectedServerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,54 +1,47 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Research.Components
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
[Virtual]
|
||||
public class SharedResearchConsoleComponent : Component
|
||||
[NetSerializable, Serializable]
|
||||
public enum ResearchConsoleUiKey : byte
|
||||
{
|
||||
Key,
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum ResearchConsoleUiKey
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleUnlockTechnologyMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Id;
|
||||
|
||||
public ConsoleUnlockTechnologyMessage(string id)
|
||||
{
|
||||
Key,
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleUnlockTechnologyMessage : BoundUserInterfaceMessage
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleServerSyncMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ConsoleServerSyncMessage()
|
||||
{}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleServerSelectionMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ConsoleServerSelectionMessage()
|
||||
{}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchConsoleBoundInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public int Points;
|
||||
public int PointsPerSecond;
|
||||
public ResearchConsoleBoundInterfaceState(int points, int pointsPerSecond)
|
||||
{
|
||||
public string Id;
|
||||
|
||||
public ConsoleUnlockTechnologyMessage(string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleServerSyncMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ConsoleServerSyncMessage()
|
||||
{}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ConsoleServerSelectionMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ConsoleServerSelectionMessage()
|
||||
{}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ResearchConsoleBoundInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public int Points;
|
||||
public int PointsPerSecond;
|
||||
public ResearchConsoleBoundInterfaceState(int points, int pointsPerSecond)
|
||||
{
|
||||
Points = points;
|
||||
PointsPerSecond = pointsPerSecond;
|
||||
}
|
||||
Points = points;
|
||||
PointsPerSecond = pointsPerSecond;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,18 +11,13 @@ namespace Content.Shared.Research.Components
|
||||
{
|
||||
[DataField("technologies")] private List<string> _technologyIds = new();
|
||||
|
||||
protected List<TechnologyPrototype> _technologies = new();
|
||||
|
||||
/// <summary>
|
||||
/// A read-only list of unlocked technologies.
|
||||
/// </summary>
|
||||
public IReadOnlyList<TechnologyPrototype> Technologies => _technologies;
|
||||
public List<TechnologyPrototype> Technologies = new();
|
||||
|
||||
void ISerializationHooks.BeforeSerialization()
|
||||
{
|
||||
var techIds = new List<string>();
|
||||
|
||||
foreach (var tech in _technologies)
|
||||
foreach (var tech in Technologies)
|
||||
{
|
||||
techIds.Add(tech.ID);
|
||||
}
|
||||
@@ -38,7 +33,7 @@ namespace Content.Shared.Research.Components
|
||||
{
|
||||
if (prototypeManager.TryIndex(id, out TechnologyPrototype? tech))
|
||||
{
|
||||
_technologies.Add(tech);
|
||||
Technologies.Add(tech);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +56,7 @@ namespace Content.Shared.Research.Components
|
||||
{
|
||||
List<string> techIds = new List<string>();
|
||||
|
||||
foreach (var tech in _technologies)
|
||||
foreach (var tech in Technologies)
|
||||
{
|
||||
techIds.Add(tech.ID);
|
||||
}
|
||||
@@ -76,7 +71,7 @@ namespace Content.Shared.Research.Components
|
||||
/// <returns>Whether it is unlocked or not</returns>
|
||||
public bool IsTechnologyUnlocked(TechnologyPrototype technology)
|
||||
{
|
||||
return _technologies.Contains(technology);
|
||||
return Technologies.Contains(technology);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user