So the collision system is just bonkers. Just bonkers. Instead of go all philosophical about it, I'm just gonna start writing on how badly I messed up.
List of issues in the current implementation:
When a robot moves into the same place as a bullet, say, then firstly, the robot gets notified (not the bullet!) and then moved out of the way with no damage. Next tic, the bullet moves into the same place as the robot. Further, the robot will move out of the way even if the bullet is owned by the robot.
When an object gets displaced by another object, it might still be inside another object. We should make object displacement recursive. But not forever!
Others. I'm just too dumbfonuded by it all to think of them.
A better implementation would:
Keep the displacement in Field; e.g. Field.move is responsible for moving objects out of the way, not the objects themselves.
To facilitate 'maybe-intangible' objects, BOTH objects should somehow have the option of signaling they're intangible; this should be done in a function call because it may depend on the object they collide with. Maybe just have the result of collidedWith(). **But ensure that both collidedWith get run and not just short-circuted (not obj1.collidedWith(obj2) && obj2.collidedWith(obj1))
Both objects should be notified when they collide. But what happens when a bullet and a robot meet head-on? In that case, then the bullet will be notified and will disappear. Then, when the robot asks to be moved, the bullet won't be there.
The move() function will account for if objects are added or removed from the field as a result of calling an object's collidedWith function.
So the collision system is just bonkers. Just bonkers. Instead of go all philosophical about it, I'm just gonna start writing on how badly I messed up.
List of issues in the current implementation:
A better implementation would:
obj1.collidedWith(obj2) && obj2.collidedWith(obj1)
)