Content PR for auto-componentstate sourcegen (#14845)
* Content PR for auto-componentstate sourcegen # Conflicts: # Content.Shared/Chat/TypingIndicator/TypingIndicatorComponent.cs # Content.Shared/Content.Shared.csproj # SpaceStation14.sln * shared file too * afterautohandlestate example * oops * anudda * access fixed * smart
This commit is contained in:
@@ -6,28 +6,18 @@ using Robust.Shared.Serialization;
|
|||||||
namespace Content.Shared.Access.Components
|
namespace Content.Shared.Access.Components
|
||||||
{
|
{
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
[AutoGenerateComponentState]
|
||||||
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem))]
|
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem))]
|
||||||
public sealed class IdCardComponent : Component
|
public sealed partial class IdCardComponent : Component
|
||||||
{
|
{
|
||||||
[DataField("fullName")]
|
[DataField("fullName")]
|
||||||
|
[AutoNetworkedField]
|
||||||
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem),
|
[Access(typeof(SharedIdCardSystem), typeof(SharedPDASystem), typeof(SharedAgentIdCardSystem),
|
||||||
Other = AccessPermissions.ReadWrite)] // FIXME Friends
|
Other = AccessPermissions.ReadWrite)] // FIXME Friends
|
||||||
public string? FullName;
|
public string? FullName;
|
||||||
|
|
||||||
[DataField("jobTitle")]
|
[DataField("jobTitle")]
|
||||||
|
[AutoNetworkedField]
|
||||||
public string? JobTitle;
|
public string? JobTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public sealed class IdCardComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public string? FullName;
|
|
||||||
public string? JobTitle;
|
|
||||||
|
|
||||||
public IdCardComponentState(string? fullName, string? jobTitle)
|
|
||||||
{
|
|
||||||
FullName = fullName;
|
|
||||||
JobTitle = jobTitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,28 +11,6 @@ public abstract class SharedIdCardSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
[Dependency] private readonly InventorySystem _inventorySystem = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
|
|
||||||
SubscribeLocalEvent<IdCardComponent, ComponentGetState>(OnComponentGetState);
|
|
||||||
SubscribeLocalEvent<IdCardComponent, ComponentHandleState>(OnComponentHandleState);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnComponentGetState(EntityUid uid, IdCardComponent component, ref ComponentGetState args)
|
|
||||||
{
|
|
||||||
args.State = new IdCardComponentState(component.FullName, component.JobTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnComponentHandleState(EntityUid uid, IdCardComponent component, ref ComponentHandleState args)
|
|
||||||
{
|
|
||||||
if (args.Current is IdCardComponentState state)
|
|
||||||
{
|
|
||||||
component.FullName = state.FullName;
|
|
||||||
component.JobTitle = state.JobTitle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Attempt to find an ID card on an entity. This will look in the entity itself, in the entity's hands, and
|
/// Attempt to find an ID card on an entity. This will look in the entity itself, in the entity's hands, and
|
||||||
/// in the entity's inventory.
|
/// in the entity's inventory.
|
||||||
|
|||||||
@@ -28,4 +28,5 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
<Import Project="..\RobustToolbox\MSBuild\Robust.Properties.targets" />
|
||||||
|
<Import Project="..\RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -4,16 +4,18 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
|
|||||||
|
|
||||||
namespace Content.Shared.Parallax.Biomes;
|
namespace Content.Shared.Parallax.Biomes;
|
||||||
|
|
||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||||
public sealed class BiomeComponent : Component
|
public sealed partial class BiomeComponent : Component
|
||||||
{
|
{
|
||||||
public FastNoiseLite Noise = new();
|
public FastNoiseLite Noise = new();
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite), DataField("seed")]
|
[ViewVariables(VVAccess.ReadWrite), DataField("seed")]
|
||||||
|
[AutoNetworkedField]
|
||||||
public int Seed;
|
public int Seed;
|
||||||
|
|
||||||
[ViewVariables(VVAccess.ReadWrite),
|
[ViewVariables(VVAccess.ReadWrite),
|
||||||
DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<BiomePrototype>))]
|
DataField("prototype", customTypeSerializer: typeof(PrototypeIdSerializer<BiomePrototype>))]
|
||||||
|
[AutoNetworkedField]
|
||||||
public string BiomePrototype = "Grasslands";
|
public string BiomePrototype = "Grasslands";
|
||||||
|
|
||||||
// TODO: Need to flag tiles as not requiring custom data anymore, e.g. if we spawn an ent and don't unspawn it.
|
// TODO: Need to flag tiles as not requiring custom data anymore, e.g. if we spawn an ent and don't unspawn it.
|
||||||
|
|||||||
@@ -20,25 +20,14 @@ public abstract class SharedBiomeSystem : EntitySystem
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
SubscribeLocalEvent<BiomeComponent, ComponentGetState>(OnBiomeGetState);
|
SubscribeLocalEvent<BiomeComponent, AfterAutoHandleStateEvent>(OnBiomeAfterHandleState);
|
||||||
SubscribeLocalEvent<BiomeComponent, ComponentHandleState>(OnBiomeHandleState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBiomeHandleState(EntityUid uid, BiomeComponent component, ref ComponentHandleState args)
|
private void OnBiomeAfterHandleState(EntityUid uid, BiomeComponent component, ref AfterAutoHandleStateEvent args)
|
||||||
{
|
{
|
||||||
if (args.Current is not BiomeComponentState state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
component.Seed = state.Seed;
|
|
||||||
component.BiomePrototype = state.Prototype;
|
|
||||||
component.Noise.SetSeed(component.Seed);
|
component.Noise.SetSeed(component.Seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnBiomeGetState(EntityUid uid, BiomeComponent component, ref ComponentGetState args)
|
|
||||||
{
|
|
||||||
args.State = new BiomeComponentState(component.Seed, component.BiomePrototype);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected T Pick<T>(List<T> collection, float value)
|
protected T Pick<T>(List<T> collection, float value)
|
||||||
{
|
{
|
||||||
DebugTools.Assert(value is >= 0f and <= 1f);
|
DebugTools.Assert(value is >= 0f and <= 1f);
|
||||||
@@ -317,17 +306,4 @@ public abstract class SharedBiomeSystem : EntitySystem
|
|||||||
|
|
||||||
// Domain warps require separate noise
|
// Domain warps require separate noise
|
||||||
}
|
}
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
private sealed class BiomeComponentState : ComponentState
|
|
||||||
{
|
|
||||||
public int Seed;
|
|
||||||
public string Prototype;
|
|
||||||
|
|
||||||
public BiomeComponentState(int seed, string prototype)
|
|
||||||
{
|
|
||||||
Seed = seed;
|
|
||||||
Prototype = prototype;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MSBuild", "MSBuild", "{5040
|
|||||||
RobustToolbox\MSBuild\Robust.Trimming.targets = RobustToolbox\MSBuild\Robust.Trimming.targets
|
RobustToolbox\MSBuild\Robust.Trimming.targets = RobustToolbox\MSBuild\Robust.Trimming.targets
|
||||||
RobustToolbox\MSBuild\Robust.Platform.props = RobustToolbox\MSBuild\Robust.Platform.props
|
RobustToolbox\MSBuild\Robust.Platform.props = RobustToolbox\MSBuild\Robust.Platform.props
|
||||||
RobustToolbox\MSBuild\Robust.Configurations.props = RobustToolbox\MSBuild\Robust.Configurations.props
|
RobustToolbox\MSBuild\Robust.Configurations.props = RobustToolbox\MSBuild\Robust.Configurations.props
|
||||||
|
RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets = RobustToolbox\MSBuild\Robust.CompNetworkGenerator.targets
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{806ED41A-411B-4B3B-BEB6-DEC6DCA4C205}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{806ED41A-411B-4B3B-BEB6-DEC6DCA4C205}"
|
||||||
@@ -120,6 +121,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Project Files", "Project Fi
|
|||||||
RobustToolbox\RELEASE-NOTES.md = RobustToolbox\RELEASE-NOTES.md
|
RobustToolbox\RELEASE-NOTES.md = RobustToolbox\RELEASE-NOTES.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Robust.Shared.CompNetworkGenerator", "RobustToolbox\Robust.Shared.CompNetworkGenerator\Robust.Shared.CompNetworkGenerator.csproj", "{07CA34A1-1D37-4771-A2E3-495A1044AE0B}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -399,6 +402,14 @@ Global
|
|||||||
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU
|
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU
|
||||||
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
|
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
|
||||||
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.Build.0 = Tools|Any CPU
|
{424445D4-F5D9-4CA9-A435-0A36E8AA28F3}.Tools|Any CPU.Build.0 = Tools|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.DebugOpt|Any CPU.ActiveCfg = DebugOpt|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.DebugOpt|Any CPU.Build.0 = DebugOpt|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Tools|Any CPU.ActiveCfg = Tools|Any CPU
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B}.Tools|Any CPU.Build.0 = Tools|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@@ -428,6 +439,7 @@ Global
|
|||||||
{8A21C7CA-2EB8-40E5-8043-33582C06D139} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
{8A21C7CA-2EB8-40E5-8043-33582C06D139} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
||||||
{952AAF2A-DF63-4A7D-8094-3453893EBA80} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
{952AAF2A-DF63-4A7D-8094-3453893EBA80} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
||||||
{A965CB3B-FD31-44AF-8872-85ABA436098D} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
{A965CB3B-FD31-44AF-8872-85ABA436098D} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
||||||
|
{07CA34A1-1D37-4771-A2E3-495A1044AE0B} = {83B4CBBA-547A-42F0-A7CD-8A67D93196CE}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A}
|
SolutionGuid = {AA37ED9F-F8D6-468E-A101-658AD605B09A}
|
||||||
|
|||||||
Reference in New Issue
Block a user