Skip to content

Commit 7dea925

Browse files
committed
make blackholes work on unseen chunks
1 parent 55fde52 commit 7dea925

File tree

2 files changed

+31
-35
lines changed

2 files changed

+31
-35
lines changed

noita-proxy/src/net/world.rs

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,37 +1118,36 @@ impl WorldManager {
11181118
flags: world_model::chunk::PixelFlags::Normal,
11191119
material: 0,
11201120
};
1121-
for (chunk_coord, chunk_encoded) in
1122-
self.chunk_storage.iter_mut().filter(|(chunk_coord, _)| {
1123-
chunk_coord.0 >= min_cx
1124-
&& chunk_coord.0 <= max_cx
1125-
&& chunk_coord.1 >= min_cy
1126-
&& chunk_coord.1 <= max_cy //TODO can filter more
1127-
})
1128-
{
1129-
let chunk_start_x = chunk_coord.0 * CHUNK_SIZE as i32;
1130-
let chunk_start_y = chunk_coord.1 * CHUNK_SIZE as i32;
1131-
let mut chunk = Chunk::default();
1132-
chunk_encoded.apply_to_chunk(&mut chunk);
1133-
for icx in 0..CHUNK_SIZE as i32 {
1134-
let cx = chunk_start_x + icx;
1135-
let dcx = cx - x;
1136-
let dx2 = dcx * dmx;
1137-
for icy in 0..CHUNK_SIZE as i32 {
1138-
let cy = chunk_start_y + icy;
1139-
let dcy = cy - y;
1140-
let m = ((dx2 + dcy * dmy) as f64 * dm2).clamp(0.0, 1.0);
1141-
let px = (m * dmx as f64) as i32;
1142-
let py = (m * dmy as f64) as i32;
1143-
let dx = dcx + px;
1144-
let dy = dcy - py;
1145-
if dx * dx + dy * dy <= r * r {
1146-
let px = icy as usize * CHUNK_SIZE + icx as usize;
1147-
chunk.set_pixel(px, air_pixel);
1121+
for chunk_x in min_cx..=max_cx {
1122+
for chunk_y in min_cy..=max_cy {
1123+
//TODO can filter closer to line
1124+
let coord = ChunkCoord(chunk_x, chunk_y);
1125+
let chunk_start_x = chunk_x * CHUNK_SIZE as i32;
1126+
let chunk_start_y = chunk_y * CHUNK_SIZE as i32;
1127+
let mut chunk = Chunk::default();
1128+
if let Some(chunk_encoded) = self.chunk_storage.get(&coord) {
1129+
chunk_encoded.apply_to_chunk(&mut chunk)
1130+
}
1131+
for icx in 0..CHUNK_SIZE as i32 {
1132+
let cx = chunk_start_x + icx;
1133+
let dcx = cx - x;
1134+
let dx2 = dcx * dmx;
1135+
for icy in 0..CHUNK_SIZE as i32 {
1136+
let cy = chunk_start_y + icy;
1137+
let dcy = cy - y;
1138+
let m = ((dx2 + dcy * dmy) as f64 * dm2).clamp(0.0, 1.0);
1139+
let px = (m * dmx as f64) as i32;
1140+
let py = (m * dmy as f64) as i32;
1141+
let dx = dcx - px;
1142+
let dy = dcy - py;
1143+
if dx * dx + dy * dy <= r * r {
1144+
let px = icy as usize * CHUNK_SIZE + icx as usize;
1145+
chunk.set_pixel(px, air_pixel);
1146+
}
11481147
}
11491148
}
1149+
self.chunk_storage.insert(coord, chunk.to_chunk_data());
11501150
}
1151-
*chunk_encoded = chunk.to_chunk_data();
11521151
}
11531152
}
11541153
pub(crate) fn cut_through_world_circle(&mut self, x: i32, y: i32, r: i32, mat: Option<u16>) {
@@ -1299,12 +1298,9 @@ impl WorldManager {
12991298
let theta = t * (n as f32 + 0.5);
13001299
let end_x = x + (r as f32 * theta.cos()) as i32;
13011300
let end_y = y + (r as f32 * theta.sin()) as i32;
1302-
let mult = if (8.0 * theta / TAU).floor() as u32 % 2 == 0 {
1303-
(theta % (TAU / 8.0)).cos()
1304-
} else {
1305-
(theta % (TAU / 4.0)).sin()
1306-
}
1307-
.recip();
1301+
let mult = (((theta + TAU / 8.0) % (TAU / 4.0)) - TAU / 8.0)
1302+
.cos()
1303+
.recip();
13081304
if let Some((ex, ey)) = self.do_ray(x, y, end_x, end_y, ray, d, mult) {
13091305
let dx = ex - x;
13101306
let dy = ey - y;

quant.ew/files/system/explosion_cuts/explosion_cuts.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ local first = true
4848

4949
local function update(ent)
5050
local proj = EntityGetFirstComponentIncludingDisabled(ent, "ProjectileComponent")
51-
if proj ~= nil and ComponentGetValue2(proj, "on_death_explode") then
51+
if proj ~= nil and (ComponentGetValue2(proj, "on_death_explode") or ComponentGetValue2(proj, "on_lifetime_out_explode")) then
5252
local x, y = EntityGetTransform(ent)
5353
local r = ComponentObjectGetValue2(proj, "config_explosion", "explosion_radius")
5454
alive[ent] = {x, y, r,

0 commit comments

Comments
 (0)