Skip to content

Commit

Permalink
#74: Split edict into compoments
Browse files Browse the repository at this point in the history
+think component part 1
  • Loading branch information
demoth committed Oct 31, 2022
1 parent 180d3a8 commit f5bca41
Show file tree
Hide file tree
Showing 20 changed files with 105 additions and 97 deletions.
6 changes: 3 additions & 3 deletions game/src/main/java/jake2/game/GameAI.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
};

public static void walkmonster_start(SubgameEntity self, GameExportsImpl gameExports) {
self.think = walkmonster_start_go;
self.think.action = walkmonster_start_go;
Monster.monster_start(self, gameExports);
}

Expand All @@ -328,7 +328,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
public String getID() { return "flymonster_start";}
public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
self.flags |= GameDefines.FL_FLY;
self.think = flymonster_start_go;
self.think.action = flymonster_start_go;
Monster.monster_start(self, gameExports);
return true;
}
Expand All @@ -353,7 +353,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
public String getID() { return "swimmonster_start";}
public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
self.flags |= GameDefines.FL_SWIM;
self.think = swimmonster_start_go;
self.think.action = swimmonster_start_go;
Monster.monster_start(self, gameExports);
return true;
}
Expand Down
46 changes: 23 additions & 23 deletions game/src/main/java/jake2/game/GameFunc.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ private static void Move_Calc(SubgameEntity ent, float[] dest, EntThinkAdapter f
Move_Begin.think(ent, gameExports);
} else {
ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
ent.think = Move_Begin;
ent.think.action = Move_Begin;
}
} else {
// accelerative
ent.moveinfo.current_speed = 0;
ent.think = Think_AccelMove;
ent.think.action = Think_AccelMove;
ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
}
}
Expand All @@ -65,7 +65,7 @@ private static void AngleMove_Calc(SubgameEntity ent, EntThinkAdapter func, Game
AngleMove_Begin.think(ent, gameExports);
} else {
ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
ent.think = AngleMove_Begin;
ent.think.action = AngleMove_Begin;
}
}

Expand Down Expand Up @@ -499,7 +499,7 @@ static void SP_func_train(SubgameEntity self, GameExportsImpl gameExports) {
// had
// a chance to spawn
self.nextthink = gameExports.level.time + Defines.FRAMETIME;
self.think = func_train_find;
self.think.action = func_train_find;
} else {
gameExports.gameImports.dprintf("func_train without a target at "
+ Lib.vtos(self.absmin) + "\n");
Expand All @@ -511,7 +511,7 @@ static void SP_func_timer(SubgameEntity self, GameExportsImpl gameExports) {
self.wait = 1.0f;

self.use = func_timer_use;
self.think = func_timer_think;
self.think.action = func_timer_think;

if (self.random >= self.wait) {
self.random = self.wait - Defines.FRAMETIME;
Expand Down Expand Up @@ -595,7 +595,7 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {
ent.moveinfo.remaining_distance / Defines.FRAMETIME,
ent.velocity);

ent.think = Move_Done;
ent.think.action = Move_Done;
ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
return true;
}
Expand All @@ -619,7 +619,7 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {
ent.moveinfo.remaining_distance -= frames * ent.moveinfo.speed
* Defines.FRAMETIME;
ent.nextthink = gameExports.level.time + (frames * Defines.FRAMETIME);
ent.think = Move_Final;
ent.think.action = Move_Final;
return true;
}
};
Expand Down Expand Up @@ -656,7 +656,7 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {

Math3D.VectorScale(move, 1.0f / Defines.FRAMETIME, ent.avelocity);

ent.think = AngleMove_Done;
ent.think.action = AngleMove_Done;
ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
return true;
}
Expand Down Expand Up @@ -697,7 +697,7 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {

// set nextthink to trigger a think when dest is reached
ent.nextthink = gameExports.level.time + frames * Defines.FRAMETIME;
ent.think = AngleMove_Final;
ent.think.action = AngleMove_Final;
return true;
}
};
Expand All @@ -721,7 +721,7 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {
Math3D.VectorScale(ent.moveinfo.dir,
ent.moveinfo.current_speed * 10, ent.velocity);
ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
ent.think = Think_AccelMove;
ent.think.action = Think_AccelMove;
return true;
}
};
Expand All @@ -738,7 +738,7 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {
}
ent.moveinfo.state = STATE_TOP;

ent.think = plat_go_down;
ent.think.action = plat_go_down;
ent.nextthink = gameExports.level.time + 3;
return true;
}
Expand Down Expand Up @@ -991,7 +991,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
self.s.frame = 1;
if (self.moveinfo.wait >= 0) {
self.nextthink = gameExports.level.time + self.moveinfo.wait;
self.think = button_return;
self.think.action = button_return;
}
return true;
}
Expand Down Expand Up @@ -1126,7 +1126,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
if ((self.spawnflags & DOOR_TOGGLE) != 0)
return true;
if (self.moveinfo.wait >= 0) {
self.think = door_go_down;
self.think.action = door_go_down;
self.nextthink = gameExports.level.time + self.moveinfo.wait;
}
return true;
Expand Down Expand Up @@ -1487,9 +1487,9 @@ public boolean think(SubgameEntity ent, GameExportsImpl gameExports) {

ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
if (ent.health != 0 || ent.targetname != null)
ent.think = Think_CalcMoveSpeed;
ent.think.action = Think_CalcMoveSpeed;
else
ent.think = Think_SpawnDoorTrigger;
ent.think.action = Think_SpawnDoorTrigger;
return true;
}
};
Expand Down Expand Up @@ -1622,9 +1622,9 @@ else if ((ent.spawnflags & DOOR_Y_AXIS) != 0)

ent.nextthink = gameExports.level.time + Defines.FRAMETIME;
if (ent.health != 0 || ent.targetname != null)
ent.think = Think_CalcMoveSpeed;
ent.think.action = Think_CalcMoveSpeed;
else
ent.think = Think_SpawnDoorTrigger;
ent.think.action = Think_SpawnDoorTrigger;
return true;
}
};
Expand Down Expand Up @@ -1693,7 +1693,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
if (self.moveinfo.wait != 0) {
if (self.moveinfo.wait > 0) {
self.nextthink = gameExports.level.time + self.moveinfo.wait;
self.think = train_next;
self.think.action = train_next;
} else if (0 != (self.spawnflags & TRAIN_TOGGLE)) // && wait < 0
{
train_next.think(self, gameExports);
Expand Down Expand Up @@ -1805,7 +1805,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {

if ((self.spawnflags & TRAIN_START_ON) != 0) {
self.nextthink = gameExports.level.time + Defines.FRAMETIME;
self.think = train_next;
ent.think.action = train_next;
self.activator = self;
}
return true;
Expand Down Expand Up @@ -1890,7 +1890,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
static EntThinkAdapter SP_trigger_elevator = new EntThinkAdapter() {
public String getID() { return "sp_trigger_elevator";}
public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
self.think = trigger_elevator_init;
self.think.action = trigger_elevator_init;
self.nextthink = gameExports.level.time + Defines.FRAMETIME;
return true;
}
Expand Down Expand Up @@ -2019,7 +2019,7 @@ public void use(SubgameEntity self, SubgameEntity other, SubgameEntity activator
public String getID() { return "door_secret_move1";}
public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
self.nextthink = gameExports.level.time + 1.0f;
self.think = door_secret_move2;
self.think.action = door_secret_move2;
return true;
}
};
Expand All @@ -2038,7 +2038,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
if (self.wait == -1)
return true;
self.nextthink = gameExports.level.time + self.wait;
self.think = door_secret_move4;
self.think.action = door_secret_move4;
return true;
}
};
Expand All @@ -2055,7 +2055,7 @@ public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
public String getID() { return "door_secret_move5";}
public boolean think(SubgameEntity self, GameExportsImpl gameExports) {
self.nextthink = gameExports.level.time + 1.0f;
self.think = door_secret_move6;
self.think.action = door_secret_move6;
return true;
}
};
Expand Down
Loading

0 comments on commit f5bca41

Please sign in to comment.