Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global TSEnemy = {};
- function TSEnemy_Create( eptr, pos, vdir )
- {
- E =
- {
- // enemy pointer for additional queries
- eptr = eptr,
- // set before tick
- position = pos,
- viewdir = vdir,
- // read after tick
- i_crouch = false,
- i_move = vec2(0,0),
- // coroutine + timer
- resume_delay = 0.0,
- coro_ai_main = co_create( function( E ){ E.AI_proc(); } ),
- // global systems
- move_to_target = null,
- };
- E = class( E, TSEnemy );
- co_resume( E.coro_ai_main, E );
- return E;
- }
- function TSEnemy.destroy()
- {
- }
- function TSEnemy.tick( deltaTime )
- {
- this.resume_delay -= deltaTime;
- if( this.resume_delay <= 0.0 )
- {
- this.resume_delay = toreal( co_resume( this.coro_ai_main ) );
- }
- if( this.move_to_target !== null )
- {
- this.i_move = vec2( this.move_to_target - this.position );
- }
- }
- function TSEnemy.AI_proc()
- {
- yield();
- for(;;)
- {
- cp = vec3(-2.5,2.5,0);
- this.move_to_target = cp+vec3(1,0,0);yield(1);
- this.move_to_target = cp+vec3(0,1,0);yield(1);
- this.move_to_target = cp+vec3(-1,0,0);yield(1);
- this.move_to_target = cp+vec3(0,-1,0);yield(1);
- // TODO
- yield();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement