MCPcopy Create free account
hub / github.com/Code-Bullet/Jump-King / UpdateAIAction

Method UpdateAIAction

Player.js:1147–1172  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1145 }
1146
1147 UpdateAIAction() {
1148 // ran every frame
1149 if (this.isWaitingToStartAction && this.isOnGround) {
1150 this.isWaitingToStartAction = false;
1151 }
1152
1153 //if the action hasnt started yet then start it
1154 //also if the ai is not on the ground and the action has already started then end the action
1155 if (this.isOnGround && !this.actionStarted) {
1156 this.currentAction = this.brain.getNextAction();
1157 if (this.currentAction === null) {
1158 this.hasFinishedInstructions = true;
1159 return;
1160 }
1161 this.StartCurrentAction();
1162 this.actionStarted = true;
1163 } else if (this.actionStarted) {
1164 //if the action has been held for long enough then we end the current action
1165 this.aiActionTimer += 1;
1166 if (this.aiActionTimer >= this.aiActionMaxTime) {
1167 this.EndCurrentAction()
1168 this.actionStarted = false;
1169
1170 }
1171 }
1172 }
1173
1174
1175 StartCurrentAction() {

Callers 1

UpdateMethod · 0.95

Calls 3

StartCurrentActionMethod · 0.95
EndCurrentActionMethod · 0.95
getNextActionMethod · 0.80

Tested by

no test coverage detected