Launch pad destination selection

This commit is contained in:
Anuken
2020-09-23 18:00:24 -04:00
parent 1cc8d7e3f4
commit 3db2ffb843
8 changed files with 101 additions and 39 deletions

View File

@@ -33,6 +33,8 @@ public class SectorInfo{
public boolean hasCore = true;
/** Sector that was launched from. */
public @Nullable Sector origin;
/** Launch destination. */
public @Nullable Sector destination;
/** Resources known to occur at this sector. */
public Seq<UnlockableContent> resources = new Seq<>();
/** Time spent at this sector. Do not use unless you know what you're doing. */
@@ -43,6 +45,12 @@ public class SectorInfo{
/** Core item storage to prevent spoofing. */
private transient int[] lastCoreItems;
/** @return the real location items go when launched on this sector */
public Sector getRealDestination(){
//on multiplayer the destination is, by default, the first captured sector (basically random)
return !net.client() || destination != null ? destination : state.rules.sector.planet.sectors.find(Sector::hasBase);
}
/** Updates export statistics. */
public void handleItemExport(ItemStack stack){
handleItemExport(stack.item, stack.amount);

View File

@@ -165,10 +165,23 @@ public class Universe{
//if so, just delete the save for now. it's lost.
//TODO don't delete it later maybe
sector.save.delete();
//clear recieved
sector.setExtraItems(new ItemSeq());
sector.save = null;
}
}
//export to another sector
if(sector.save.meta.secinfo.destination != null){
Sector to = sector.save.meta.secinfo.destination;
if(to.save != null){
ItemSeq items = to.getExtraItems();
//calculated exported items to this sector
sector.save.meta.secinfo.export.each((item, stat) -> items.add(item, (int)(stat.mean * newSecondsPassed)));
to.setExtraItems(items);
}
}
//reset time spent to 0
sector.setTimeSpent(0f);
}