This is the action type.
Code:
TEntityAction = record
{action and it's properties}
action, effect, properties: longword;
{action is complete}
done: boolean;
{direction}
vDir: TVector3f;
{distance traveled, speed}
distance, speed: single;
{minimum duration, max duration, start wait time minimum, start wait time maximum}
minTime, maxTime, startWaitTimeMin, startWaitTimeMax: single;
along: PEntityAction; {action to be performed along with this one}
next: PEntityAction; {action to be performed after this one}
{an associated path}
path: PPath;
{an associated projectile group}
projectileGroup: PProjectileGroup;
end;
This holds action data per each entity and action.
Code:
TEntityActionData = record
initialized, done: boolean;
distancemoved: single;
lineardir: longint;
actionTime, startWaitTime: single;
timer: TTimerData;
waitedAtStart: boolean;
vPos: TVector3f;
end;
Here is a simple move action.
Code:
procedure actionMoveDistance(var ent: TEntity; var a: TEntityAction; var d: TEntityActionData);
var
vmMov: TVector3f;
dist: Single;
begin
if(d.distancemoved < a.distance) then begin
vmMov := a.vDir * (a.speed * oxMainTimeFlow);
dist := vmDistance(vmvZero3f, vmMov);
d.distancemoved := d.distancemoved + dist;
ent.vPos := ent.vPos + vmMov;
if(a.distance < d.distancemoved) then begin
ent.vPos := ent.vPos - (a.vDir * (d.distancemoved - a.distance));
d.distancemoved := a.distance;
nextAction(ent);
end;
end;
end;
There is a lot more, but I think if I shown how everything works this would be one really huge post. I still need to expand this and improve the already existing code.
Bookmarks