DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.84k stars 463 forks source link

Implement df::coord iterator and cuboid class #4675

Closed Bumber64 closed 3 weeks ago

Bumber64 commented 3 weeks ago

Implement an iterator that operates on all df::coords within a cuboid box. Iterates in the direction of x/y/z provided (rather than always min to max.) By default iterates per z-level, but has an option to iterate in the z direction first. Closes #4596

Cuboid class for defining a cuboid of tiles. Can test if a coord is inside itself. Can be expanded to contain a given coord. Has a method to call the above iterator using the defined cuboid. Closes #4595

Also update plugins to use plant_type enum attrs, since we're removing the cuboid struct from plugins/plant.cpp in this PR anyway.

Bumber64 commented 3 weeks ago

Need to apply this to existing functions (e.g., Units::isUnitInBox and Units::getUnitsInBox, as well as plugins that iterate map tiles).

Bumber64 commented 3 weeks ago

Should a class with only public members more properly be a struct, or is it weirder to have a struct with member functions?

myk002 commented 3 weeks ago

Should a class with only public members more properly be a struct, or is it weirder to have a struct with member functions?

I don't have an opinion one way or the other here. I'd say do whatever feels natural.