123 lines
4.0 KiB
C#
123 lines
4.0 KiB
C#
using Sand.Core;
|
|
|
|
namespace Sand.ChunkPrototype;
|
|
|
|
[Flags]
|
|
public enum PrototypeParticleFlags : ushort
|
|
{
|
|
None = 0,
|
|
WaterLike = 1 << 0,
|
|
FireLike = 1 << 1,
|
|
Acidic = 1 << 2,
|
|
HotSource = 1 << 3,
|
|
}
|
|
|
|
public readonly record struct PrototypeParticle(
|
|
ushort TypeId,
|
|
string Id,
|
|
PrototypeParticleType MotionType,
|
|
ParticleKind Kind,
|
|
ParticleBehaviorKind BehaviorKind,
|
|
byte R,
|
|
byte G,
|
|
byte B,
|
|
float Mass,
|
|
float Velocity,
|
|
float Friction,
|
|
float Viscosity,
|
|
bool IsStatic = false,
|
|
PrototypeParticleFlags Flags = PrototypeParticleFlags.None,
|
|
bool IsMolten = false,
|
|
ushort HydrateTargetTypeId = 0,
|
|
ushort MeltTypeId = 0,
|
|
ushort EvaporateTypeId = 0,
|
|
ushort SolidifyTypeId = 0,
|
|
ushort FreezeTypeId = 0,
|
|
ushort BrokenTypeId = 0,
|
|
ushort ProduceTypeId = 0,
|
|
ushort ProducesOnDeathTypeId = 0,
|
|
float PressureThreshold = 0f,
|
|
float PressureResistance = 0f,
|
|
float PressureTolerance = 0f,
|
|
short PressureThresholdDuration = 0,
|
|
float PressureResponse = 1f,
|
|
float ForceResponseMultiplier = 1f,
|
|
float LateralFlowMultiplier = 1f,
|
|
float DiagonalFlowMultiplier = 1f,
|
|
float UpwardBias = 0f,
|
|
float SideDriftBias = 0f,
|
|
float InitialTemperature = 22f,
|
|
float MeltTemperature = float.PositiveInfinity,
|
|
float EvaporateTemperature = float.PositiveInfinity,
|
|
float SolidifyTemperature = float.NegativeInfinity,
|
|
float FreezeTemperature = float.NegativeInfinity,
|
|
float BurnDuration = 0f,
|
|
float BurnTemperature = 0f,
|
|
float BurnRate = 1f,
|
|
bool BurningInit = false,
|
|
float DefaultLifetime = 0f,
|
|
float HeatEmission = 0f,
|
|
float SmokeSpawnChance = 0f,
|
|
float EmberSpawnChance = 0f,
|
|
float Hardness = 0.5f,
|
|
float Durability = 100f,
|
|
float Flamability = 0f,
|
|
float Conductivity = 0f,
|
|
bool Conductive = false,
|
|
float AmbientCoolingMultiplier = 1f,
|
|
float NeighborHeatTransferMultiplier = 1f,
|
|
float PhaseTransitionHysteresis = 0f)
|
|
{
|
|
public bool IsEmpty => TypeId == 0 || MotionType == PrototypeParticleType.Empty;
|
|
|
|
public bool HasFlag(PrototypeParticleFlags flag) => (Flags & flag) != 0;
|
|
|
|
public bool HasLifetimeBehavior => DefaultLifetime > 0f;
|
|
|
|
public bool HasBurnBehavior => BurningInit || BurnTemperature > 0f || BurnDuration > 0f || Flamability > 0f;
|
|
|
|
public bool HasEmissionBehavior => HeatEmission > 0f || SmokeSpawnChance > 0f || EmberSpawnChance > 0f || ProduceTypeId != 0 || ProducesOnDeathTypeId != 0;
|
|
|
|
public bool HasSpecialBehavior => BehaviorKind != ParticleBehaviorKind.None;
|
|
|
|
public bool HasReactionBehavior =>
|
|
HydrateTargetTypeId != 0 ||
|
|
HasFlag(PrototypeParticleFlags.WaterLike) ||
|
|
HasFlag(PrototypeParticleFlags.FireLike) ||
|
|
HasFlag(PrototypeParticleFlags.Acidic) ||
|
|
HasFlag(PrototypeParticleFlags.HotSource);
|
|
|
|
public bool HasPhaseBehavior =>
|
|
(MeltTypeId != 0 && !float.IsPositiveInfinity(MeltTemperature)) ||
|
|
(EvaporateTypeId != 0 && !float.IsPositiveInfinity(EvaporateTemperature)) ||
|
|
(SolidifyTypeId != 0 && !float.IsNegativeInfinity(SolidifyTemperature)) ||
|
|
(FreezeTypeId != 0 && !float.IsNegativeInfinity(FreezeTemperature)) ||
|
|
(MotionType == PrototypeParticleType.Steam && SolidifyTypeId != 0);
|
|
|
|
public bool HasPressureBehavior =>
|
|
BrokenTypeId != 0 ||
|
|
PressureThreshold > 0f ||
|
|
PressureResistance > 0f ||
|
|
PressureTolerance > 0f ||
|
|
PressureThresholdDuration > 0;
|
|
|
|
public bool HasThermalBehavior =>
|
|
HasBurnBehavior ||
|
|
HasEmissionBehavior ||
|
|
HasPhaseBehavior ||
|
|
HasSpecialBehavior ||
|
|
Conductivity > 0f ||
|
|
AmbientCoolingMultiplier != 1f ||
|
|
NeighborHeatTransferMultiplier != 1f;
|
|
|
|
public bool RequiresFullRuntimeStep =>
|
|
HasLifetimeBehavior ||
|
|
HasBurnBehavior ||
|
|
HasEmissionBehavior ||
|
|
HasSpecialBehavior ||
|
|
HasReactionBehavior ||
|
|
HasPhaseBehavior ||
|
|
HasPressureBehavior ||
|
|
HasThermalBehavior;
|
|
}
|