示例#1
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;
 }
示例#2
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);
     }
   }
 }
示例#3
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);
 }
示例#4
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();
   }
 }
示例#5
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()));
 }
示例#6
0
 @Override
 public void shutdown() {
   if (activeminion != null) {
     SkeletalMeshComponent skelcomp = activeminion.getComponent(SkeletalMeshComponent.class);
     if (skelcomp != null) {
       skelcomp.material = Assets.getMaterial("OreoMinions:OreonSkin");
     }
   }
 }
示例#7
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;
 }
示例#8
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;
 }
示例#9
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;
 }
示例#10
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;
 }
示例#11
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;
 }