logs in console, caching in getAgentProps, console createAgent independent of GUI
This commit is contained in:
@@ -3,6 +3,7 @@ class AgentsModel extends WindozModel {
|
||||
constructor() {
|
||||
super()
|
||||
this.ressource = '/agents'
|
||||
this.agentProps = {}
|
||||
}
|
||||
|
||||
async getTypes(family) {
|
||||
@@ -23,14 +24,28 @@ class AgentsModel extends WindozModel {
|
||||
)
|
||||
}
|
||||
|
||||
async getProperties(id) {
|
||||
let endpoint = {...app.config.api[this.ressource].getProperties}
|
||||
endpoint.uri = endpoint.uri.replace('{id}', id)
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => serverData.payload.agentProperties)
|
||||
)
|
||||
}
|
||||
async getProperties(id, force=false) {
|
||||
if((!(id in this.agentProps)) || force){
|
||||
let endpoint = {...app.config.api[this.ressource].getProperties}
|
||||
endpoint.uri = endpoint.uri.replace('{id}', id)
|
||||
return (
|
||||
this.request(endpoint.uri, endpoint.method)
|
||||
.then( async serverData => {
|
||||
this.agentProps[id] = serverData.payload.agentProperties.atp_props
|
||||
return(serverData.payload.agentProperties.atp_props)
|
||||
})
|
||||
)
|
||||
} else {
|
||||
return(this.agentProps[id])
|
||||
}
|
||||
}
|
||||
|
||||
async getDefaultProps(id){
|
||||
const aprops = await this.getProperties(id)
|
||||
const defaults={ position: { x:0, y:0, z:0 }, speed: { x:0, y:0, z:0 }}
|
||||
for(const p in aprops) defaults[p] = aprops[p].default
|
||||
return(defaults)
|
||||
}
|
||||
}
|
||||
|
||||
app.registerClass('AgentsModel', AgentsModel);
|
||||
Reference in New Issue
Block a user