New BlockTracer classes
#1
Lately I'm carrying this idea in my head, so now I'm gonna dump it here for peer analysis.

The current cTracer class is weird. I have tried several times to understand how it is used, but failed every time. Also, it seems to do one job only, so if we needed something very similar but a little bit different, it couldn't do it.

What we'd need is a generic BlockTracer class that would "enumerate" all blocks within a certain path. Let's say we need to simulate entities' movement. So we need to know when each entity hits a wall in the direction they're moving. Or, we need to simulate a projectile, again wall-hitting. But this time, rather than a straight line, it might be better to use a parabolic trajectory instead. Or we need to determine if a monster sees another entity; it's again a line traced through the blocks, but this time we're not only looking at walls, but also transparent materials. I'm pretty sure you now get the picture.

What I'm proposing is quite simple at first: a cBlockTracer class that would call a callback function for each block in the trajectory, until the callback returns a "finish" value instead of "continue". Then, we could make descendant classes that provide the trajectories - line, parabola, etc. Or the trajectories could be fed in through a template.

Using this class should be pretty straightforward: declare the callback to use, then create an instance of this class (+ trajectory) and call its Trace method with whatever parameters it takes.

As for the Lua API, this should be made available; at least the basic trajectories, if not completely custom.

Questions / decisions:
- How to feed in the trajectory
- How to feed in the block data
- Reactions for out-of-world?
Reply
Thanks given by:


Messages In This Thread
New BlockTracer classes - by xoft - 07-22-2013, 06:33 AM
RE: New BlockTracer classes - by NiLSPACE - 07-27-2013, 09:03 PM
RE: New BlockTracer classes - by xoft - 07-27-2013, 09:18 PM
RE: New BlockTracer classes - by NiLSPACE - 07-27-2013, 09:19 PM
RE: New BlockTracer classes - by xoft - 08-04-2013, 02:18 AM
RE: New BlockTracer classes - by bearbin - 08-04-2013, 02:19 AM
RE: New BlockTracer classes - by xoft - 08-04-2013, 02:49 AM
RE: New BlockTracer classes - by xoft - 08-05-2013, 12:30 AM
RE: New BlockTracer classes - by NiLSPACE - 08-05-2013, 04:02 AM
RE: New BlockTracer classes - by bearbin - 08-05-2013, 05:13 AM
RE: New BlockTracer classes - by NiLSPACE - 08-07-2013, 10:23 PM
RE: New BlockTracer classes - by xoft - 08-07-2013, 10:44 PM
RE: New BlockTracer classes - by NiLSPACE - 08-07-2013, 11:06 PM
RE: New BlockTracer classes - by ThuGie - 08-08-2013, 03:57 AM
RE: New BlockTracer classes - by NiLSPACE - 08-08-2013, 04:09 AM
RE: New BlockTracer classes - by tonibm19 - 08-08-2013, 04:35 AM
RE: New BlockTracer classes - by xoft - 08-08-2013, 05:57 AM
RE: New BlockTracer classes - by ThuGie - 08-08-2013, 06:09 AM
RE: New BlockTracer classes - by NiLSPACE - 08-09-2013, 02:11 AM
RE: New BlockTracer classes - by xoft - 08-09-2013, 03:38 AM



Users browsing this thread: 6 Guest(s)