}
} else {
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).getInventory().deleteAll();
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).getInventory().updateMiniatures();
}
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).setSparklingPosition(new Vector2D(pointX, pointY), isStatic);
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).setColliding(isColliding);
Singleton.getPhysics().setLinearVelocity(actorName, new Vector2D(velX, velY));
Singleton.getPhysics().setBodyPosition(actorName, new Vector2D(posX, posY));
Singleton.getPhysics().setRotation(actorName, rot);
if (!((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).getPowerDown() && isPoweredDown) {
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).applyPowerDown();
} else if (((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).getPowerDown() && !isPoweredDown) {
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).deletePowerDown();
}
if (!((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).getBoost() && isBoosted) {
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).applyBoost();
} else if (((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).getBoost() && !isBoosted) {
((RaceGameState) Singleton.getWorldModel().getState()).getCars().get(i).deleteBoost();
}
} catch (NullPointerException e) {
System.out.println("error update actor");
}
}
//Update missilesingleton.getWorldModel().
Set<String> currentItemList = ((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().keySet();
ArrayList<String> newItemList = new ArrayList();
ArrayList<String> currentMissileList = new ArrayList();
ArrayList<String> currentBombList = new ArrayList();
ArrayList<String> currentMineList = new ArrayList();
ArrayList<String> currentDynamicObjectList = new ArrayList();
for (String it : currentItemList) {
if (it.startsWith("Missile_") && !it.endsWith("_Explosion")) {
currentMissileList.add(it);
} else if (it.startsWith("Bomb_") && !it.endsWith("_Explosion")) {
currentBombList.add(it);
} else if (it.startsWith("Mine_") && !it.endsWith("_Explosion")) {
currentMineList.add(it);
} else if (it.startsWith("dynamic")) {
currentDynamicObjectList.add(it);
}
}
int cptMissiles = Integer.parseInt(st.nextToken());
for (int i = 0; i < cptMissiles; i++) {
String missileName = st.nextToken();
Float posX = Float.parseFloat(st.nextToken());
Float posY = Float.parseFloat(st.nextToken());
Float rot = Float.parseFloat(st.nextToken());
String emitter = st.nextToken();
newItemList.add(missileName);
if (((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().containsKey(missileName)) {
Singleton.getPhysics().setBodyPosition(missileName, new Vector2D(posX, posY));
Singleton.getPhysics().setRotation(missileName, rot);
} else {
((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().put(missileName, new WEMissile(missileName, new Vector2D(posX, posY), rot, (WECar) ((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().get(emitter), ((RaceGameState) Singleton.getWorldModel().getState())));
}
}
int cptBomb = Integer.parseInt(st.nextToken());
for (int i = 0; i < cptBomb; i++) {
String bombName = st.nextToken();
Float posX = Float.parseFloat(st.nextToken());
Float posY = Float.parseFloat(st.nextToken());
Float rot = Float.parseFloat(st.nextToken());
String emitter = st.nextToken();
newItemList.add(bombName);
if (((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().containsKey(bombName)) {
Singleton.getPhysics().setBodyPosition(bombName, new Vector2D(posX, posY));
Singleton.getPhysics().setRotation(bombName, rot);
//Singleton.getVisualisation().updateActor(missileName, posX, posY, rot);
} else {
((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().put(bombName, new WEBomb(bombName, new Vector2D(posX, posY), rot, (WECar) ((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().get(emitter), ((RaceGameState) Singleton.getWorldModel().getState())));
}
}
int cptMine = Integer.parseInt(st.nextToken());
for (int i = 0; i < cptMine; i++) {
String mineName = st.nextToken();
Float posX = Float.parseFloat(st.nextToken());
Float posY = Float.parseFloat(st.nextToken());
Float rot = Float.parseFloat(st.nextToken());
newItemList.add(mineName);
if (!((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().containsKey(mineName)) {
((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().put(mineName, new WEMine(mineName, new Vector2D(posX, posY), rot, null, ((RaceGameState) Singleton.getWorldModel().getState())));
}
}
int cptDynamicObjects = Integer.parseInt(st.nextToken());
for (int i = 0; i < cptDynamicObjects; i++) {
String dynamicObjectName = st.nextToken();
Float posX = Float.parseFloat(st.nextToken());
Float posY = Float.parseFloat(st.nextToken());
Float rot = Float.parseFloat(st.nextToken());
newItemList.add(dynamicObjectName);
if (((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().containsKey(dynamicObjectName)) {
Singleton.getPhysics().setBodyPosition(dynamicObjectName, new Vector2D(posX, posY));
Singleton.getPhysics().setRotation(dynamicObjectName, rot);
//Singleton.getVisualisation().updateActor(missileName, posX, posY, rot);
} else {
//rien
}
}
boolean isTrolling = Boolean.parseBoolean(st.nextToken());
String emitter = st.nextToken();
if (isTrolling) {
((RaceGameState) Singleton.getWorldModel().getState()).activateTroll((WECar) ((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().get(emitter));
}
//Finish list
int cptFinish = Integer.parseInt(st.nextToken());
ArrayList<String> nameList = new ArrayList<>();
ArrayList<Long> timeList = new ArrayList<>();
for (int i = 0; i < cptFinish; i++) {
nameList.add(st.nextToken());
timeList.add(Long.parseLong(st.nextToken()));
}
((RaceGameState) Singleton.getWorldModel().getState()).setFinishNames(nameList);
((RaceGameState) Singleton.getWorldModel().getState()).setFinishTimes(timeList);
//Suppression des items
for (String str : currentMissileList) {
if (newItemList.indexOf(str) < 0) {
((WEMissile) ((RaceGameState) Singleton.getWorldModel().getState()).getWorldEntities().get(str)).startStaticContact(new Vector2D(0, 0), new Vector2D(0, 0));
// Singleton.getVisualisation().deleteActor(str,false);
// ((RaceGameState)Singleton.getWorldModel().getState()).getWorldEntities().get(str).setActive(false);
}
}
for (String str : currentBombList) {