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:
Kara
2023-04-06 10:33:40 -07:00
committed by GitHub
parent b943d83ae1
commit 9688544e78
6 changed files with 23 additions and 64 deletions

View File

@@ -20,25 +20,14 @@ public abstract class SharedBiomeSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<BiomeComponent, ComponentGetState>(OnBiomeGetState);
SubscribeLocalEvent<BiomeComponent, ComponentHandleState>(OnBiomeHandleState);
SubscribeLocalEvent<BiomeComponent, AfterAutoHandleStateEvent>(OnBiomeAfterHandleState);
}
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);
}
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)
{
DebugTools.Assert(value is >= 0f and <= 1f);
@@ -317,17 +306,4 @@ public abstract class SharedBiomeSystem : EntitySystem
// 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;
}
}
}