2 ms·
If you want to delay the hit, i.e. transactioning / buffering / delaying: This is sound engineering! But that part is not even included in above boilerplate. It
by jstimpfle 8y ago
If you want to delay the hit, i.e. transactioning / buffering / delaying: This is sound engineering! But that part is not even included in above boilerplate. It would be:
struct PlayerMonsterWeaponHit {
Player player;
Monster monster;
Weapon weapon;
}
Array<PlayerMonsterWeaponHit> playerMonsterWeaponHits;
doTheActualFrigginHit(Player player, Monster monster, Weapon weapon) {
playerMonsterWeaponHits.emplace(player, monster, weapon);
}
In case it isn't obvious you can do that with either implementation, the above OOP boilerplate or the above imperative 1 line of code.
> Yes – this code is stupid if all you need to implement is a single line
No, it's stupid because it doesn't do anything. The data structures are only for temporaries that will never have any other use. In the end it's going to be PlayerMonsterWeaponHit. So the other classes are just stupid, and no amount of context will change that.