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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user