Пример #1
0
 /** creates a zonelist component used to save all zones (persist) */
 private static void createZoneList() {
   zonelist = CoreRegistry.get(EntityManager.class).create();
   ZoneListComponent zonecomp = new ZoneListComponent();
   zonelist.addComponent(zonecomp);
   zonelist.setPersisted(true);
   zonelist.saveComponent(zonecomp);
 }
Пример #2
0
 /**
  * adds a new zone to the corresponding zone list
  *
  * @param zone the zone to be added
  */
 public static void addZone(Zone zone) {
   ZoneListComponent zonelistcomp = zonelist.getComponent(ZoneListComponent.class);
   switch (zone.zonetype) {
     case Gather:
       {
         zonelistcomp.Gatherzones.add(zone);
         break;
       }
     case Work:
       {
         zonelistcomp.Workzones.add(zone);
         break;
       }
     case Terraform:
       {
         zonelistcomp.Terrazones.add(zone);
         break;
       }
     case Storage:
       {
         zonelistcomp.Storagezones.add(zone);
         break;
       }
     case OreonFarm:
       {
         zonelistcomp.OreonFarmzones.add(zone);
         break;
       }
   }
   zonelist.saveComponent(zonelistcomp);
 }
Пример #3
0
 /**
  * destroys a minion at the end of their dying animation this implies that setting their animation
  * to die will destroy them.
  */
 @ReceiveEvent(components = {SkeletalMeshComponent.class, AnimationComponent.class})
 public void onAnimationEnd(AnimEndEvent event, EntityRef entity) {
   AnimationComponent animcomp = entity.getComponent(AnimationComponent.class);
   if (animcomp != null && event.getAnimation().equals(animcomp.dieAnim)) {
     entity.destroy();
   }
 }
Пример #4
0
 /**
  * Ugly way to retrieve a name from a prefab
  *
  * @return a ":" seperated string, with name and flavor text.
  */
 public static String getName() {
   PrefabManager prefMan = CoreRegistry.get(PrefabManager.class);
   Prefab prefab = prefMan.getPrefab("miniion:nameslist");
   EntityRef namelist = CoreRegistry.get(EntityManager.class).create(prefab);
   namelist.hasComponent(namesComponent.class);
   namesComponent namecomp = namelist.getComponent(namesComponent.class);
   Random rand = new Random();
   return namecomp.namelist.get(rand.nextInt(namecomp.namelist.size()));
 }
Пример #5
0
 /**
  * triggered when a block was destroyed and dropped in the world used to intercept gathering by
  * minions and sending the block to their inventory the droppedblock in the world then gets
  * destroyed, possible duplication exploit
  */
 @ReceiveEvent(components = {MinionComponent.class})
 public void onBlockDropped(BlockDroppedEvent event, EntityRef entity) {
   if (entity.hasComponent(MinionComponent.class)) {
     EntityRef item;
     if (event.getOldBlock().getEntityMode() == BlockEntityMode.PERSISTENT) {
       item = blockItemFactory.newInstance(event.getOldBlock().getBlockFamily(), entity);
     } else {
       item = blockItemFactory.newInstance(event.getOldBlock().getBlockFamily());
     }
     entity.send(new ReceiveItemEvent(item));
     event.getDroppedBlock().destroy();
   }
 }
Пример #6
0
 /**
  * The active minion, to be commanded by the minion command item etc uses a slightly different
  * texture to indicate selection
  *
  * @param minion : the new active minion entity
  */
 public static void setActiveMinion(EntityRef minion) {
   SkeletalMeshComponent skelcomp;
   if (activeminion != null) {
     skelcomp = activeminion.getComponent(SkeletalMeshComponent.class);
     if (skelcomp != null) {
       skelcomp.material = Assets.getMaterial("OreoMinions:OreonSkin");
     }
   }
   skelcomp = minion.getComponent(SkeletalMeshComponent.class);
   if (skelcomp != null) {
     skelcomp.material = Assets.getMaterial("OreoMinions:OreonSkinSelected");
   }
   activeminion = minion;
 }
Пример #7
0
 @Override
 public void shutdown() {
   if (activeminion != null) {
     SkeletalMeshComponent skelcomp = activeminion.getComponent(SkeletalMeshComponent.class);
     if (skelcomp != null) {
       skelcomp.material = Assets.getMaterial("OreoMinions:OreonSkin");
     }
   }
 }
Пример #8
0
 /** order the minions by id and return the previous one, or the first if none were active! */
 public static void getPreviousMinion(boolean deleteactive) {
   EntityManager entman = CoreRegistry.get(EntityManager.class);
   List<Integer> sortedlist = new ArrayList<Integer>();
   for (EntityRef minion : entman.iteratorEntities(MinionComponent.class)) {
     if (!minion.getComponent(MinionComponent.class).dying) {
       sortedlist.add(minion.getId());
     }
   }
   if (sortedlist.size() == 0) {
     return;
   } else if (deleteactive && sortedlist.size() == 1) {
     activeminion = null;
     return;
   }
   Collections.sort(sortedlist);
   int index = 0;
   if (activeminion != null) {
     index = sortedlist.indexOf(activeminion.getId());
   }
   if (index == 0) {
     index = sortedlist.size() - 1;
   } else {
     index--;
   }
   index = sortedlist.get(index);
   for (EntityRef minion : entman.iteratorEntities(MinionComponent.class)) {
     if (minion.getId() == index) {
       setActiveMinion(minion);
     }
   }
 }
Пример #9
0
 /**
  * returns a list with all Oreon farm zones
  *
  * @return a list with all Oreon farm zones
  */
 public static List<Zone> getOreonFarmZoneList() {
   if (zonelist == null) {
     return null;
   }
   return zonelist.getComponent(ZoneListComponent.class).OreonFarmzones;
 }
Пример #10
0
 /**
  * returns a list with all storage zones
  *
  * @return a list with all storage zones
  */
 public static List<Zone> getStorageZoneList() {
   if (zonelist == null) {
     return null;
   }
   return zonelist.getComponent(ZoneListComponent.class).Storagezones;
 }
Пример #11
0
 /**
  * returns a list with all terraform zones
  *
  * @return a list with all terraform zones
  */
 public static List<Zone> getTerraformZoneList() {
   if (zonelist == null) {
     return null;
   }
   return zonelist.getComponent(ZoneListComponent.class).Terrazones;
 }
Пример #12
0
 /**
  * returns a list with all work zones
  *
  * @return a list with all work zones
  */
 public static List<Zone> getWorkZoneList() {
   if (zonelist == null) {
     return null;
   }
   return zonelist.getComponent(ZoneListComponent.class).Workzones;
 }
Пример #13
0
 /**
  * returns a list with all gather zones
  *
  * @return a list with all gather zones
  */
 public static List<Zone> getGatherZoneList() {
   if (zonelist == null) {
     return null;
   }
   return zonelist.getComponent(ZoneListComponent.class).Gatherzones;
 }