Re: Is there a good way to handle multiple enemies who can effect each oth

I didn't realize non_exhaustive had finally stabilized.  That is useful, but doesn't solve the problem.  I'm not actually making a judgement call on open unions one way or the other, but irregardless of how you slice it Rust has a very poor story around representing inheritance-like relationships, and open unions solves that problem.  Mind you, there's almost no good way to implement them that doesn't end with them allocated on the heap.

Synthizer just solved this problem in C++.  I hide the actual concrete implementation of the type behind function pointers paerameterized over the type itself, place a block of inline storage in a generic command struct, allocate the command type in that storage, use the aforementioned callbacks to erase the type from the external interface, put them in a MPSC ringbuffer that allocates as one contiguous block, and fail compilation with compile-time asserts if the size limit would be exceeded.

Keep in mind: audio is a weird special snowflake where even at very low CPU utilization you still can't actually go around allocating and deallocating.  There were actually something like 10 other ways to do what Synthizer needed, they just all unfortunately meant interacting with malloc from the audio threads in some way.  For a game the throughput of just allocating them will be fine until some threshold.  But at the end of the day I don't think messages for everything is an answer, getting into the details of how to do it is beside the point I was trying to make originally, and you really have to code how Rust wants you to.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Ethin via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Dragonlee via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : keithwipf1 via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : defender via Audiogames-reflector
  • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector

Reply via email to