Daedeross / Subterra

Factorio mod that adds an underground along with specialized structures.
MIT License
9 stars 1 forks source link

Use collision layer to prevent unplaceable items on underground layers #13

Open anythingapplied opened 5 years ago

anythingapplied commented 5 years ago

Add a custom collision layer, then add that layer to the underground surfaces (not sure if you'd have to do that on chunk load events), then go through and for every prototype not allowed, add the custom collision layer to its collision mask.

anythingapplied commented 5 years ago

You could even add "up-collison" to specific tiles that have entities on the surface above. This would let you "see" where an upstairs, for example, is placeable a bit better. Same thing for a "down-collision". So you'd probably need 3 custom collision layer.

anythingapplied commented 5 years ago

Looks like you can't create custom layers, but there are 5 unused layers available, "layer-11" through "layer-15"

https://lua-api.factorio.com/latest/Concepts.html#CollisionMaskLayer

Daedeross commented 5 years ago
anythingapplied commented 5 years ago

You mentioned the idea that you came up with to simply draw the above layer (when having an up block in your hand) onto the current layer is better. No affect on save size. No complexity with decimal bounding boxes. No conflicts with other mod's collision layers. Also, it has a huge advantage of being able to show you a larger area and not just the area your entity is currently on top of. You would just have to do a quick find_entities_filtered, and I guess maybe a find_tiles_filtered too.

I'm just not sure how to (or if you can) trigger that appropriately. I don't think there is a "take item into your hand" event, let alone the opposite. You may just have to add buttons to the GUI to show entities on the surface above and one to show entities below, which wouldn't be too bad of a way to do it.

Daedeross commented 5 years ago

This is what I have come up with so far: 427520_screenshots_20190518201519_1

It redraws once a second right now and doesn't seem to noticeably impact performance. I think I'll make this an option in the mod settings and add it to 0.6.0