Open leftiness opened 8 years ago
This one's a bit of a change to the util::line function.
I might accept opaque: Set
Alternatively, I might just require a Set
Maybe not. The idea of accepting these sets is feeling meh.
Maybe instead of having a Set<> for opaque, I should accept a function which will accept a HasValues and return a HasWalls for me to check? The library user would have to provide basically his entire map in order to be sure that I get the points that I need. Alternatively, he could just give me the function myEntireMapHashSet
Anyway, I'll also have to write some function which will help me determine which direction a line is going in. With that, I'll then need to check if the HasWalls has a wall in that direction, and then I'd finally be able to check if the remaining strength of the ray can pass through that.
That's another thing. util::line will need to accept a strength. Is strength the same thing as range? Maybe. If I subtract one in order to move one, and I subtract an extra one in order to break through a wall with strength one, then that makes things pretty simple.
Would it be better to have a separate strength? Maybe. I mean... realistically, I'd have like mass and velocity for the ray and then idk some science word for quantifying resistance to force. Then I'd reduce the velocity for breaking through the resistance.... maybe I don't want to do all that.
Cannons and longbows start to cause problems if you consider "strength" and "range" to be the same thing.
You're not going to fire a cannonball with a longbow, but a longbow might be able to fire an arrow about as far as a cannon can shoot a cannonball. The cannonball will have way more force on impact. You won't break through a big wall with a longbow's arrow. Still, the arrow could still deal enough abstract "damage" to a goblin.
So the question is, "Do I want to deal with these things?"
Maybe I just have arbitrary attributes on a cannon and a longbow which are not backed up by physics. If I want to break through some walls, I could still add an explosive effect, and then I can just calculate that with this simplified flood_with_strength() concept. Without regards to physics concepts like mass, velocity, and force, the system could work on a more abstract level.
A projectile has enough "range" to reach the target location. It is then able to apply a certain amount of "damage," which is "explosive," and so it will break through barriers of a certain "strength."
At the same time, maybe it's not so bad to use mass and velocity. It would certainly provide the system with more options. Still, I think I want to be abstract in some cases. I certainly think I would prefer using "HP" as opposed to idk keeping track of blood loss or internal organ damage. At some point you have to draw the line.
Is one strength value really a problem for physics?
If I shoot an arrow, and it has an arbitary strength rating of 5, then maybe it can go through walls with a strength of 5 before it stops. Similarly, a cannon has a strength of 50, so it can go through lots of strong walls.
The way to prevent an arrow from going through the stone walls is obviously to give them high strength. If the arrow does pierce an obstacle, then it results in reduced strength, which can be directly translated to reduced abstract damage due to the implied reduction in velocity.
I don't really want to deal with the bullet drop that results from reduced velocity just like I don't want to deal with tracking internal organ damage, so using range, strength, and damage should work out to be a decent abstraction.
fn ray_with_strength(point, i32 range, map<point, f32 strength>);
flood with strength
The idea is that the ray/flood would be able to pass through certain semi-opaque points. However, passing through a point with strength 0.5 would reduce the range by an extra 0.5.
Could be useful to have these. For example: