NoiseDrivenDebrisSelectorComponent.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using Content.Server.Worldgen.Prototypes;
  2. using Content.Server.Worldgen.Systems.Debris;
  3. using Content.Server.Worldgen.Tools;
  4. using Content.Shared.Storage;
  5. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
  6. namespace Content.Server.Worldgen.Components.Debris;
  7. /// <summary>
  8. /// This is used for selecting debris with a probability determined by a noise channel.
  9. /// Takes priority over SimpleDebrisSelectorComponent and should likely be used in combination.
  10. /// </summary>
  11. [RegisterComponent]
  12. [Access(typeof(NoiseDrivenDebrisSelectorSystem))]
  13. public sealed partial class NoiseDrivenDebrisSelectorComponent : Component
  14. {
  15. private EntitySpawnCollectionCache? _cache;
  16. /// <summary>
  17. /// The prototype-facing debris table entries.
  18. /// </summary>
  19. [DataField("debrisTable", required: true)]
  20. private List<EntitySpawnEntry> _entries = default!;
  21. /// <summary>
  22. /// The debris entity spawn collection.
  23. /// </summary>
  24. public EntitySpawnCollectionCache CachedDebrisTable
  25. {
  26. get
  27. {
  28. _cache ??= new EntitySpawnCollectionCache(_entries);
  29. return _cache;
  30. }
  31. }
  32. /// <summary>
  33. /// The noise channel to use as a density controller.
  34. /// </summary>
  35. /// <remarks>This noise channel should be mapped to exactly the range [0, 1] unless you want a lot of warnings in the log.</remarks>
  36. [DataField("noiseChannel", customTypeSerializer: typeof(PrototypeIdSerializer<NoiseChannelPrototype>))]
  37. public string NoiseChannel { get; private set; } = default!;
  38. }