Exemple #1
0
 private void add() {
   Point2D coord = pencil.getCoord();
   for (Trinket t : ModelManager.getBattlefield().getMap().get(coord).getData(Trinket.class)) {
     if (t.pos.equals(coord)) {
       coord = coord.getTranslation(RandomUtil.between(AngleUtil.FLAT, -AngleUtil.FLAT), 0.1);
     }
   }
   Trinket t =
       BuilderManager.getAllEditableTrinketBuilders()
           .get(set.actual)
           .build(coord.get3D(ModelManager.getBattlefield().getMap().getAltitudeAt(coord)));
   MapArtisanUtil.attachTrinket(t, ModelManager.getBattlefield().getMap());
   t.drawOnBattlefield();
 }
Exemple #2
0
 private void remove() {
   Trinket toRemove = getPointedTrinket();
   if (toRemove != null) {
     MapArtisanUtil.dettachTrinket(toRemove, ModelManager.getBattlefield().getMap());
     toRemove.removeFromBattlefield();
   }
 }
Exemple #3
0
 private Trinket getPointedTrinket() {
   if (EntityManager.isValidId(ToolManager.getPointedSpatialEntityId())) {
     return ModelManager.getBattlefield()
         .getMap()
         .getTrinket(ToolManager.getPointedSpatialEntityId());
   }
   return null;
 }
Exemple #4
0
 private void move() {
   if (!pencil.maintained) {
     pencil.maintain();
     actualTrinket = getPointedTrinket();
     actualTrinket.sowed = false;
     if (actualTrinket != null) {
       moveOffset = pencil.getCoord().getSubtraction(actualTrinket.getCoord());
     }
   }
   if (actualTrinket != null) {
     // TODO attention, l'elevation n'est pas forcement juste avec ce calcul
     double elevation =
         actualTrinket.pos.z
             - ModelManager.getBattlefield().getMap().getAltitudeAt(actualTrinket.pos.get2D());
     Point2D newPos = pencil.getCoord().getSubtraction(moveOffset);
     double z = ModelManager.getBattlefield().getMap().getAltitudeAt(newPos) + elevation;
     actualTrinket.pos = newPos.get3D(z);
     MapArtisanUtil.cleanSowing(
         ModelManager.getBattlefield().getMap(), pencil.getCoord(), actualTrinket.getRadius());
   }
 }