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, "solid": true,
"is_gas": false "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": { "rock": {
"name": "Rock", "name": "Rock",
"size": 1, "size": 1,
@ -56,6 +80,8 @@
"velocity": 1.5, "velocity": 1.5,
"color": [128, 128, 128, 220], "color": [128, 128, 128, 220],
"mass": 1, "mass": 1,
"durability": 100.0,
"Broken": "brkstone",
"temperature": 20, "temperature": 20,
"melt": "molten-Stone", "melt": "molten-Stone",
"melt_temperature": 800, "melt_temperature": 800,
@ -63,5 +89,23 @@
"liquid": false, "liquid": false,
"solid": true, "solid": true,
"is_gas": false "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": { "ultratanium": {
"name": "Ultra Tanium", "name": "Ultra Tanium",
"size": 1, "size": 1,

View File

@ -35,6 +35,7 @@ class Particle:
self.hardness = properties.get("hardness", 0.5) self.hardness = properties.get("hardness", 0.5)
self.color = properties.get("color", [255, 255, 255, 255]) self.color = properties.get("color", [255, 255, 255, 255])
self.temperature = properties.get("temperature", temperature) self.temperature = properties.get("temperature", temperature)
self.durability = properties.get("durability", 100.0)
# Physics properties # Physics properties
self.conductivity = properties.get("conductivity", 0) self.conductivity = properties.get("conductivity", 0)
@ -63,6 +64,23 @@ class Particle:
self.explosive = properties.get("explosive", False) self.explosive = properties.get("explosive", False)
self.explosion_radius = properties.get("explosion_radius", 0) self.explosion_radius = properties.get("explosion_radius", 0)
self.explosion_color = properties.get("explosion_color", [0, 0, 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 @classmethod
def from_type(cls, position, particle_type, properties): def from_type(cls, position, particle_type, properties):
@ -93,7 +111,7 @@ class Simulation:
self.brush_size = 1 self.brush_size = 1
self.max_brush_size = 20 self.max_brush_size = 20
self.particle_properties = particle_properties 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.gravity = 9.8 # m/s^2, adjustable based on the scale of simulation
self.wind_zones = [] self.wind_zones = []
self.wind = [0.0, 0.0] # Global wind vector (x, y) 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 hasattr(particle, 'evaporate_temperature') and particle.evaporate_temperature is not None:
if particle.temperature >= particle.evaporate_temperature and particle.evaporate: if particle.temperature >= particle.evaporate_temperature and particle.evaporate:
self.transform_particle(x, y, particle.evaporate) self.transform_particle(x, y, particle.evaporate)
if not state_changed:
# Check freezing # Check freezing
if hasattr(particle, 'freeze_temperature') and particle.freeze_temperature is not None: if hasattr(particle, 'freeze_temperature') and particle.freeze_temperature is not None:
if particle.temperature <= particle.freeze_temperature and particle.freeze: if particle.temperature <= particle.freeze_temperature and particle.freeze:
self.transform_particle(x, y, particle.freeze) self.transform_particle(x, y, particle.freeze)
# Check for melting with proper attribute validation # Check for melting with proper attribute validation
if (hasattr(particle, 'melt') and hasattr(particle, 'melt_temperature') if (hasattr(particle, 'melt') and hasattr(particle, 'melt_temperature')
and particle.melt_temperature is not None): and particle.melt_temperature is not None):
if particle.temperature >= particle.melt_temperature: if particle.temperature >= particle.melt_temperature:
new_type = particle.melt new_type = particle.melt
if new_type in self.particle_properties: if new_type in self.particle_properties:
self.transform_particle(x, y, new_type) self.transform_particle(x, y, new_type)
# Check for solidification with proper attribute validation # Check for solidification with proper attribute validation
if (hasattr(particle, 'solidify') and hasattr(particle, 'solidify_temperature') if (hasattr(particle, 'solidify') and hasattr(particle, 'solidify_temperature')
and particle.solidify_temperature is not None): and particle.solidify_temperature is not None):
if particle.temperature < particle.solidify_temperature: if particle.temperature < particle.solidify_temperature:
new_type = particle.solidify new_type = particle.solidify
if new_type in self.particle_properties: if new_type in self.particle_properties:
self.transform_particle(x, y, new_type) self.transform_particle(x, y, new_type)
return 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. def handle_particle_interactions(self, dt): # this is where we handle all the particle interactions.
"""Handle interactions between different particle types""" """Handle interactions between different particle types"""
for x, y in list(self.active_particles): for x, y in list(self.active_particles):
particle = self.particles[x][y] particle = self.particles[x][y]
if not particle: if not particle:
continue continue
# Handle damage for any particle with durability
self.handle_particle_damage(particle, x, y)
# Check neighboring particles # Check neighboring particles
for dx, dy in [(-1, 0), (1, 0), (0, -1), (0, 1), (-1, -1), (1, -1), (-1, 1), (1, 1)]: 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 nx, ny = x + dx, y + dy
@ -404,8 +464,12 @@ class Simulation:
"""Handle temperature changes and state transitions""" """Handle temperature changes and state transitions"""
for x, y in list(self.active_particles): for x, y in list(self.active_particles):
particle = self.particles[x][y] particle = self.particles[x][y]
if particle and particle.is_gas:
particle.temperature -= 0.5 * dt
if not particle: if not particle:
continue continue
if particle.temperature > 1700: if particle.temperature > 1700:
# Transition to gas # Transition to gas
particle.is_gas = True particle.is_gas = True
@ -486,7 +550,7 @@ class Simulation:
for x, y in list(self.active_particles): for x, y in list(self.active_particles):
particle = self.particles[x][y] 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 continue
# Apply gravity # Apply gravity

View File

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