147 lines
5.4 KiB
C#
147 lines
5.4 KiB
C#
namespace Sand.Core;
|
|
|
|
public static class ParticleRuntimeProfileBuilder
|
|
{
|
|
public static ParticleRuntimeProfile Build(ParticleDef definition)
|
|
{
|
|
return new ParticleRuntimeProfile
|
|
{
|
|
Definition = definition,
|
|
Balance = BuildBalance(definition),
|
|
};
|
|
}
|
|
|
|
private static ParticleBalanceProfile BuildBalance(ParticleDef definition)
|
|
{
|
|
return definition.Id switch
|
|
{
|
|
"fire" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
BehaviorKind = ParticleBehaviorKind.Fire,
|
|
LifetimeMultiplier = 1f,
|
|
BurnDecayPerStep = 2.5f,
|
|
AmbientCoolingMultiplier = 0.2f,
|
|
NeighborHeatTransferMultiplier = 0.45f,
|
|
UpwardBias = 1f,
|
|
SideDriftBias = 0.45f,
|
|
FireSpreadChance = 0.14f,
|
|
SmokeSpawnChance = 0.18f,
|
|
EmberSpawnChance = 0.04f,
|
|
HeatEmissionMultiplier = 1.1f,
|
|
MinLifetimeTicks = 18f,
|
|
MaxLifetimeTicks = 40f,
|
|
PhaseTransitionHysteresis = 0f,
|
|
},
|
|
"burning_wood" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
BehaviorKind = ParticleBehaviorKind.BurningWood,
|
|
BurnDecayPerStep = 0.65f,
|
|
AmbientCoolingMultiplier = 0.35f,
|
|
NeighborHeatTransferMultiplier = 0.75f,
|
|
SmokeSpawnChance = 0.14f,
|
|
EmberSpawnChance = 0.025f,
|
|
ProduceChance = 0.12f,
|
|
HeatEmissionMultiplier = 1f,
|
|
FireSpreadChance = 0.08f,
|
|
PressureSensitivity = 0.8f,
|
|
MinLifetimeTicks = 240f,
|
|
MaxLifetimeTicks = 420f,
|
|
},
|
|
"ember" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
BehaviorKind = ParticleBehaviorKind.Ember,
|
|
LifetimeMultiplier = 1f,
|
|
BurnDecayPerStep = 1.5f,
|
|
AmbientCoolingMultiplier = 0.3f,
|
|
NeighborHeatTransferMultiplier = 0.65f,
|
|
UpwardBias = 0.35f,
|
|
SideDriftBias = 0.25f,
|
|
FireSpreadChance = 0.05f,
|
|
SmokeSpawnChance = 0.10f,
|
|
ProduceChance = 0.08f,
|
|
HeatEmissionMultiplier = 0.8f,
|
|
MinLifetimeTicks = 20f,
|
|
MaxLifetimeTicks = 45f,
|
|
},
|
|
"plasma" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
BehaviorKind = ParticleBehaviorKind.Plasma,
|
|
AmbientCoolingMultiplier = 0.1f,
|
|
NeighborHeatTransferMultiplier = 0.5f,
|
|
UpwardBias = 0.95f,
|
|
SideDriftBias = 0.55f,
|
|
FireSpreadChance = 0.18f,
|
|
HeatEmissionMultiplier = 1.6f,
|
|
EnergyTransferMultiplier = 1.75f,
|
|
MinLifetimeTicks = 18f,
|
|
MaxLifetimeTicks = 60f,
|
|
},
|
|
"lava" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
AmbientCoolingMultiplier = 0.05f,
|
|
NeighborHeatTransferMultiplier = 0.12f,
|
|
FireSpreadChance = 0.08f,
|
|
HeatEmissionMultiplier = 1.35f,
|
|
ForceResponseMultiplier = 0.22f,
|
|
LateralFlowMultiplier = 0.38f,
|
|
DiagonalFlowMultiplier = 0.6f,
|
|
PhaseTransitionHysteresis = 60f,
|
|
PressureSensitivity = 1.1f,
|
|
},
|
|
var id when id.StartsWith("molten_", StringComparison.Ordinal) => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
AmbientCoolingMultiplier = 0.08f,
|
|
NeighborHeatTransferMultiplier = 0.16f,
|
|
HeatEmissionMultiplier = 1.15f,
|
|
ForceResponseMultiplier = 0.32f,
|
|
LateralFlowMultiplier = 0.5f,
|
|
DiagonalFlowMultiplier = 0.72f,
|
|
PhaseTransitionHysteresis = 45f,
|
|
PressureSensitivity = 1.05f,
|
|
},
|
|
"steam" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
AmbientCoolingMultiplier = 0.2f,
|
|
NeighborHeatTransferMultiplier = 0.45f,
|
|
PhaseTransitionHysteresis = 15f,
|
|
},
|
|
"smoke" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
LifetimeMultiplier = 1.25f,
|
|
AmbientCoolingMultiplier = 0.25f,
|
|
UpwardBias = 0.4f,
|
|
SideDriftBias = 0.2f,
|
|
MinLifetimeTicks = 100f,
|
|
MaxLifetimeTicks = 140f,
|
|
},
|
|
"ice" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
AmbientCoolingMultiplier = 0.15f,
|
|
NeighborHeatTransferMultiplier = 0.4f,
|
|
PhaseTransitionHysteresis = 24f,
|
|
},
|
|
"snow" => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
AmbientCoolingMultiplier = 0.22f,
|
|
NeighborHeatTransferMultiplier = 0.5f,
|
|
PhaseTransitionHysteresis = 18f,
|
|
},
|
|
_ => new ParticleBalanceProfile
|
|
{
|
|
Id = definition.Id,
|
|
BurnDecayPerStep = 1f,
|
|
},
|
|
};
|
|
}
|
|
}
|