Currently supported:
- size, color, temperature, mass
- liquid, solid, is_gas states
- conductivity (heat transfer maybe)
- friction, viscosity (movement i think)
- pressure (basic pressure calculations maybe)

- melt/solidify temperatures and states
- (except steam it used to go back to water )
- freeze/evaporate temperatures and states (yes)

- flamability (fire spread maybe)
- burning (basic fire behavior last i checked)
- melting (melting/freezing yes)

Missing Implementation:
- durability (need to be implemented in progress)
- explosion_radius
- explosion_force
- explosion_duration
- explosion_color

- pressure_resistance
- pressure_tolerance
- pressure_threshold_duration

- burn_intensity
- burn_rate
- burn_rate_multiplier
- burn_color changes
This commit is contained in:
Stan44 2024-12-29 16:44:04 -06:00
parent d2a50413db
commit 9c0812b3d9
4 changed files with 180 additions and 126 deletions

View File

@ -14,6 +14,30 @@
"solid": true,
"is_gas": false
},
"wsand": {
"name": "Wet Sand",
"size": 1,
"hardness": 0.5,
"color": [200, 200, 25, 255],
"velocity": 0.5,
"mass": 0.5,
"conductivity": 0,
"heat_capacity": 1,
"flamability": 0.8,
"temperature": 20,
"explosive": false,
"explosion_radius": 0,
"explosion_color": [0, 0, 0],
"friction": 0.5,
"viscosity": 0.3,
"pressure": 0,
"melt": "sand",
"melt_temperature": 100,
"conductive": false,
"liquid": false,
"solid": true,
"is_gas": false
},
"rock": {
"name": "Rock",
"size": 1,
@ -56,6 +80,8 @@
"velocity": 1.5,
"color": [128, 128, 128, 220],
"mass": 1,
"durability": 100.0,
"Broken": "brkstone",
"temperature": 20,
"melt": "molten-Stone",
"melt_temperature": 800,
@ -63,5 +89,23 @@
"liquid": false,
"solid": true,
"is_gas": false
},
"brkstone": {
"name": "Broken Stone",
"size": 1,
"hardness": 0.4,
"velocity": 0.5,
"color": [
128,
128,
128,
220
],
"mass": 0.5,
"temperature": 20,
"friction": 0.5,
"liquid": false,
"solid": true,
"is_gas": false
}
}

View File

@ -1,28 +1,5 @@
{
"wsand": {
"name": "Wet Sand",
"size": 1,
"hardness": 0.5,
"color": [200, 200, 25, 255],
"velocity": 0.5,
"mass": 0.5,
"conductivity": 0,
"heat_capacity": 1,
"flamability": 0.8,
"temperature": 20,
"explosive": false,
"explosion_radius": 0,
"explosion_color": [0, 0, 0],
"friction": 0.5,
"viscosity": 0.3,
"pressure": 0,
"melt": "sand",
"melt_temperature": 100,
"conductive": false,
"liquid": false,
"solid": true,
"is_gas": false
},
"ultratanium": {
"name": "Ultra Tanium",
"size": 1,

View File

@ -35,7 +35,8 @@ class Particle:
self.hardness = properties.get("hardness", 0.5)
self.color = properties.get("color", [255, 255, 255, 255])
self.temperature = properties.get("temperature", temperature)
self.durability = properties.get("durability", 100.0)
# Physics properties
self.conductivity = properties.get("conductivity", 0)
self.heat_capacity = properties.get("heat_capacity", 1)
@ -63,6 +64,23 @@ class Particle:
self.explosive = properties.get("explosive", False)
self.explosion_radius = properties.get("explosion_radius", 0)
self.explosion_color = properties.get("explosion_color", [0, 0, 0])
self.explosion_force = properties.get("explosion_force", 0)
self.explosion_duration = properties.get("explosion_duration", 0)
# Pressure properties
self.pressure_resistance = properties.get("pressure_resistance", 0)
self.pressure_tolerance = properties.get("pressure_tolerance", 0)
self.pressure_threshold = properties.get("pressure_threshold", 0)
self.pressure_threshold_duration = properties.get("pressure_threshold_duration", 0)
# Burning properties
self.burning = properties.get("burning", False)
self.burn_temperature = properties.get("burn_temperature", 0)
self.burn_duration = properties.get("burn_duration", 0)
self.burn_color = properties.get("burn_color", [255, 0, 0])
self.burn_rate = properties.get("burn_rate", 0)
self.burn_intensity = properties.get("burn_intensity", 0)
self.burn_rate_multiplier = properties.get("burn_rate_multiplier", 1.0)
@classmethod
def from_type(cls, position, particle_type, properties):
@ -93,7 +111,7 @@ class Simulation:
self.brush_size = 1
self.max_brush_size = 20
self.particle_properties = particle_properties
self.current_particle_type = 'sand'
self.particle_types = list(self.particle_properties.keys())
self.gravity = 9.8 # m/s^2, adjustable based on the scale of simulation
self.wind_zones = []
self.wind = [0.0, 0.0] # Global wind vector (x, y)
@ -177,39 +195,81 @@ class Simulation:
if hasattr(particle, 'evaporate_temperature') and particle.evaporate_temperature is not None:
if particle.temperature >= particle.evaporate_temperature and particle.evaporate:
self.transform_particle(x, y, particle.evaporate)
if not state_changed:
# Check freezing
if hasattr(particle, 'freeze_temperature') and particle.freeze_temperature is not None:
if particle.temperature <= particle.freeze_temperature and particle.freeze:
if hasattr(particle, 'freeze_temperature') and particle.freeze_temperature is not None:
if particle.temperature <= particle.freeze_temperature and particle.freeze:
self.transform_particle(x, y, particle.freeze)
# Check for melting with proper attribute validation
if (hasattr(particle, 'melt') and hasattr(particle, 'melt_temperature')
and particle.melt_temperature is not None):
if particle.temperature >= particle.melt_temperature:
new_type = particle.melt
if new_type in self.particle_properties:
self.transform_particle(x, y, new_type)
# Check for melting with proper attribute validation
if (hasattr(particle, 'melt') and hasattr(particle, 'melt_temperature')
and particle.melt_temperature is not None):
if particle.temperature >= particle.melt_temperature:
new_type = particle.melt
if new_type in self.particle_properties:
self.transform_particle(x, y, new_type)
# Check for solidification with proper attribute validation
if (hasattr(particle, 'solidify') and hasattr(particle, 'solidify_temperature')
and particle.solidify_temperature is not None):
if particle.temperature < particle.solidify_temperature:
new_type = particle.solidify
if new_type in self.particle_properties:
self.transform_particle(x, y, new_type)
return new_type
# Check for solidification with proper attribute validation
if (hasattr(particle, 'solidify') and hasattr(particle, 'solidify_temperature')
and particle.solidify_temperature is not None):
if particle.temperature < particle.solidify_temperature:
new_type = particle.solidify
if new_type in self.particle_properties:
self.transform_particle(x, y, new_type)
return new_type
if particle.particle_type == 'steam':
# Steam should condense when it cools
if particle.temperature <= particle.solidify_temperature:
self.transform_particle(x, y, new_type)
return new_type
# Check durability property from JSON
if (hasattr(particle, 'durability') and hasattr(particle, 'brk')
and particle.brk is not None):
if particle.durability <= 0:
self.transform_particle(x, y, particle.broken)
return new_type
def handle_particle_damage(self, particle, x, y):
"""Handle damage calculations for particles with durability"""
if not hasattr(particle, 'durability'):
return
# Pressure damage
pressure = self.calculate_forces(particle, x, y)
if hasattr(particle, 'pressure_threshold') and pressure > particle.pressure_threshold:
particle.durability -= 0.1
# Impact damage
neighbors = self._get_neighbors_from_grid(x, y)
for nx, ny in neighbors:
neighbor = self.particles[nx][ny]
if neighbor and neighbor.velocity[1] > 5.0:
particle.durability -= 0.2
# Heat damage
if particle.temperature > 900:
particle.durability -= 1
# Check if particle should break
if particle.durability <= 0 and hasattr(particle, 'broken'):
self.transform_particle(x, y, particle.broken)
return
def handle_particle_interactions(self, dt): # this is where we handle all the particle interactions.
"""Handle interactions between different particle types"""
for x, y in list(self.active_particles):
particle = self.particles[x][y]
if not particle:
continue
# Handle damage for any particle with durability
self.handle_particle_damage(particle, x, y)
# Check neighboring particles
for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1), (-1, -1), (1, -1), (-1, 1), (1, 1)]:
nx, ny = x + dx, y + dy
@ -404,8 +464,12 @@ class Simulation:
"""Handle temperature changes and state transitions"""
for x, y in list(self.active_particles):
particle = self.particles[x][y]
if particle and particle.is_gas:
particle.temperature -= 0.5 * dt
if not particle:
continue
if particle.temperature > 1700:
# Transition to gas
particle.is_gas = True
@ -486,7 +550,7 @@ class Simulation:
for x, y in list(self.active_particles):
particle = self.particles[x][y]
if not particle or particle.particle_type == 'wall':
if not particle or particle.particle_type in ['wall', 'stone', 'wood']:
continue
# Apply gravity

View File

@ -1,81 +1,50 @@
{
"Template": {
"description": "Defines the properties and behavior of various particle types, including sand, water, and steam.",
"description2": "This template can be used as a starting point for creating custom particle mods.",
"description3": "Remove 'Template' for your own particle mods to work only particles like below will work."
},
"sand": {
"name": "Sand",
"size": 1,
"hardness": 0.5,
"color": [255, 255, 0, 255],
"velocity": 0.5,
"mass": 0.5,
"conductivity": 0,
"heat_capacity": 1,
"flamability": 0.8,
"temperature": 0,
"explosive": false,
"explosion_radius": 0,
"explosion_color": [0, 0, 0],
"friction": 0.5,
"viscosity": 0,
"pressure": 0,
"melt": "molten-Glass",
"melt_temperature": 1000,
"conductive": false,
"liquid": false,
"solid": true,
"is_gas": false
},
"water": {
"name": "Water",
"size": 1,
"hardness": 0.2,
"velocity": 0.3,
"conductivity": 1,
"heat_capacity": 1,
"color": [0, 0, 255, 255],
"mass": 1,
"flamability": 0,
"temperature": 22,
"explosive": false,
"explosion_radius": 0,
"explosion_color": [0, 0, 0],
"friction": 1,
"viscosity": 1,
"pressure": 0.5,
"evaporate": "steam",
"evaporate_temperature": 145,
"freeze": "ice",
"freeze_temperature": 0,
"melt": "water",
"melt_temperature": 20,
"liquid": true,
"solid": false,
"is_gas": false
},
"steam": {
"name": "Steam",
"size": 1,
"hardness": 0.0,
"velocity": 0.2,
"conductivity": 1,
"heat_capacity": 1,
"color": [255, 255, 255, 255],
"mass": 0.01,
"flamability": 0,
"temperature": 100,
"solidify_temperature": 98,
"solidify": "water",
"explosive": false,
"explosion_radius": 0,
"explosion_color": [0, 0, 0],
"friction": 0.5,
"viscosity": 0.5,
"liquid": false,
"solid": false,
"is_gas": true,
"conductive": false
}
"particle_name": {
"name": "Particle Name",
"size": 1,
"hardness": 0.5,
"durability": 100.0,
"color": [255, 255, 255, 255],
"temperature": 20,
"mass": 1.0,
"conductivity": 0,
"heat_capacity": 1,
"flamability": 0.0,
"friction": 0.5,
"viscosity": 1.0,
"pressure": 0,
"liquid": false,
"solid": true,
"is_gas": false,
"melt": null,
"melt_temperature": null,
"solidify": null,
"solidify_temperature": null,
"evaporate": null,
"evaporate_temperature": null,
"freeze": null,
"freeze_temperature": null,
"explosive": false,
"explosion_radius": 0,
"explosion_color": [0, 0, 0],
"explosion_force": 0,
"explosion_duration": 0,
"pressure_resistance": 0,
"pressure_tolerance": 0,
"pressure_threshold": 0,
"pressure_threshold_duration": 0,
"burning": false,
"burn_temperature": 0,
"burn_duration": 0,
"burn_color": [255, 0, 0],
"burn_rate": 0,
"burn_intensity": 0,
"burn_rate_multiplier": 1.0
}
}