updateAgent API & snippet in KF console

This commit is contained in:
STEINNI
2026-06-05 09:09:53 +00:00
parent eb7312c7a8
commit ce9e73ac41
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -48,7 +48,16 @@ app.helpers.kfConsole = {
this.kfArena.removeAgent(aid)
},
updateAgent: async (aid, properties) => {
if(!Object.keys(this.kfArena.agents).includes(aid)) throw(`Agent ${aid} not on scene !`)
const agent = this.kfArena.agents[aid]
const values = { ...agent.values, ...properties }
if(properties.position) values.position = { ...agent.values.position, ...properties.position }
if(properties.speed) values.speed = { ...agent.values.speed, ...properties.speed }
agent.values = values
if(properties.position) this.kfArena.moveAgent(aid, values.position)
if(properties.speed) this.kfArena.changeAgentSpeed(aid, values.speed)
if(this.currentlySelectedAid === aid) this.fillAgentProperties(aid, agent.props, agent.values)
this.updateKfButtons()
},
selectAgent: async (aid) => {
if(!Object.keys(this.kfArena.agents).includes(aid)) throw(`Agent ${aid} not on scene !`)