« first day (3708 days earlier)      last day (1302 days later) » 

9:05 AM
gamedev is difficult
3
 
 
2 hours later…
11:19 AM
So... im simulating timers inside my ecs. They actually have four states. Started, Running, Completed and aborted. I wanna react to them inside my ecs. I have found two possible ways to achieve this. I could either create 4 different "Marker" components and simply mark my timer entity with those. Or i could create a "State" component that contains an enum of those four states.
I would like to choose the first variant due to performance reasons ( should be quicker, because we only iterate over what we want and dont need to check ). But currently those components stay forever... such a marker should actually only stay one single frame ( Started, Completed, Aborted ). How could we achieve this ? Whats the proper way ?
 
user92578
Setup a system that removes the components after a frame?
 
@Tyyppi_77 So some sort of generic solution ?
 
user92578
Huh? Could be hardcoded to just remove those 4 types of components or you could choose to write it in some other way, like instantiating a removal system for each type
 
Alright thanks ^^
 
 
2 hours later…
1:19 PM
hi
 
user92578
hello
 
how are ya?
 
user92578
trying to motivate myself to write about bike locks for a school project, kinda boring stuff... you?
 
waiting on class to start, fiddling around with a card game I wrote with Python in, like, 30 minutes
 
nwp
I'm screwing around with linker scripts with barely any understanding of what I'm doing.
 
1:26 PM
lol
 
@genaray somewhat late to the party, but:
Why not store the remaining time in a component on entities that should have sth happening after that time? If necessary also store a ptr to whatever function should be executed on the entity after time. Then have a system that simply decreases the timer by the delta between executions, calls the function at reaching <= 0, and removes the component
 
user92578
Arbitrary callbacks are kind of nasty as they make it harder to reason about code flow
 
2:19 PM
not really arbitray though?
I mean the proposal of storing a function ptr is mainly to reduce the amount of systems you need running; could also have different systems for each functionality, or have a switch reacting to arbitrary markers
 
2:43 PM
I'll agree with Tyyppi_77 here: when you have some code that is stored in the system, some code that is stored in a component, some code that is injected into a function pointer, some code that is in "special entities", it becomes hard to figure out where to look for the code, and where one should put new code.
 
Now that is another matter though. In practice the code should reside where other code resides. The function pointer pointing to that code is set on Componentcreation then
 
yes. Maybe. I don't have code in my components ;)
But the component could store a lambda that is declared in a system. Or preferably a non-lamda. But that would apply to the ECS I wrote. Others may have approaches that make as much sense as the way I did mine.
If one can come up with simple rules as to where to put the code, and they make sense, then I guess it's possible to have code at multiple places.
 
@Vaillancourt that's basically another name for a function ptr
But yeah that is the gist, and reason to sometimes strictly apply patterns. I got a simple rule for where gamecode goes: Systems
so i start looking there if sth don't work
 
Yep, that's what I did too.
 
user92578
The issue about code flow is not about where the code lives
 
user92578
2:50 PM
It's about at what timepoint it is invoked
 
user92578
Function pointers break that flow, especially in a component pattern where the pointer is long lived outside of the scope that creates it
 
I suppose it depends on how it's done.
 
System-execution in a very naive implementation here
If you go fancy you can have another system for execution down the pipeline and buffer the callbacks
also: tesselation is awesome
 
@Tyyppi_77 Do you not know when the function pointer is executed?
 
user92578
Most likely yes, but it breaks the whole idea of a system to be a self-contained thing, when it offloads some work that is found in file A, that ends up being invoked 10ms later from file B
 
2:56 PM
@Tyyppi_77 what does this have to do with files..?
 
Absolutely, sounds smelly
 
user92578
It seems like it's definitely not worth the time to explain myself here
 
I agree. On the flip-side, it allows for "greater flexibility".
 
A function ptr is just a variable that you can push around, instead of hardcoding a function name. It will still get executed on the same thread (unless you spawn a new execution environment, e.g. another thread; or put it into a queue where another bit of code executes the contents).

Having code in different files should not incur a 10ms delay under any normal circumstances
 
user92578
2:58 PM
That is missing the point big time
 
user92578
The execution is delayed because it is no longer the responsibility of the creator of the function to call the function
 
Probably, but I am trying to point out that I do not see what seems so obvious to you, and attempt to show that I am willing to work to understand
 
user92578
It happens in another system down the line
 
user92578
Which might very well be on another thread
 
Well yeah, but that is going to happen anyway due to delayed execution due to using a timer?
 
nwp
3:01 PM
The point is that you can no longer follow the code step by step because the code simply puts a function pointer somewhere and that's the end of it. Also on the other side you see a function pointer being called but not which one. This makes understanding the code rather complicated.
Event-based systems tend to have this problem of it being impossible to follow what code is actually being executed, even with a debugger.
 
And if you put a breakpoint in the function, you still don't have a clue who created it and when it was assigned.
 
I would like to beg to differ, but I got a good decade of experience working with systems that are heavily decoupled and event-based (i.e. webservers, etc.) so I am biased
 
nwp
I'm not saying event-based systems are bad, I'm saying they have the problem of making following the program flow rather difficult. With your experience you should know that.
 
I def agree on the 'who created it and when' part, videogames tend to be notoriously nondeterministic due to all manner of randoms being applied everywhere
@nwp yeah no i got that, sorry if that didn't show from my writing :)
 
nwp
Randomness when you roll damage is not the same as randomness when you don't know which functions will be called when.
 
3:04 PM
that sounds pretty scary
 
It's hard to follow indeed. Usually you'd assign ids to events and such so you can track them through logging; if you fear runtime impacts you could use #debug macros or similar
But then there's technically no need to use a proper eventsystem for that usecase(?) (just tell me to stop if I'm overdoing it, I really enjoy the subject right now so I will go deeper and deeper)
 
nwp
That was the point, yes. Not using a callback would be better because it would avoid the issue of the code being difficult to follow.
 
3:29 PM
I guess depending on your use of callbacks that is true. But callbacks don't automatically make your code harder to follow, no.
 
 
1 hour later…
4:44 PM
@dot_Sp0T We had some interesting Q&A a while back about a similar wrapping scheme... gamedev.stackexchange.com/q/162223/39518
I've got a few answers about neat tricks you can use with geodesic grids too, to work in familiar 2D coordinates even if the tiles themselves wrap around in 3D. gamedev.stackexchange.com/a/108683/39518
 
oooh looks nice
gonna look into it later i think
rn I'm doing some camera work first to make sure these transforms all work
 
 
4 hours later…
9:03 PM
Another answer about flattening a geodesic sphere into rectangular charts: gamedev.stackexchange.com/a/141032/39518
 

« first day (3708 days earlier)      last day (1302 days later) »