Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -68,6 +68,9 @@ public class Planets{
|
||||
hiddenItems.addAll(Items.serpuloItems).removeAll(Items.erekirItems);
|
||||
enemyBuildSpeedMultiplier = 0.4f;
|
||||
|
||||
//TODO disallowed for now
|
||||
allowLaunchToNumbered = false;
|
||||
|
||||
//TODO SHOULD there be lighting?
|
||||
updateLighting = false;
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public abstract class PlanetGenerator extends BasicGenerator implements HexMeshe
|
||||
|
||||
/** @return whether to allow landing on the specified procedural sector */
|
||||
public boolean allowLanding(Sector sector){
|
||||
return sector.hasBase() || sector.near().contains(Sector::hasBase);
|
||||
return sector.planet.allowLaunchToNumbered && (sector.hasBase() || sector.near().contains(Sector::hasBase));
|
||||
}
|
||||
|
||||
public void addWeather(Sector sector, Rules rules){
|
||||
|
||||
@@ -62,12 +62,6 @@ public class ErekirPlanetGenerator extends PlanetGenerator{
|
||||
return 2000 * 1.07f * 6f / 5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowLanding(Sector sector){
|
||||
//TODO disallowed for now
|
||||
return false;
|
||||
}
|
||||
|
||||
float rawHeight(Vec3 position){
|
||||
return Simplex.noise3d(seed, octaves, persistence, 1f/heightScl, 10f + position.x, 10f + position.y, 10f + position.z);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package mindustry.type;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.struct.*;
|
||||
import arc.struct.ObjectIntMap.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.*;
|
||||
import mindustry.ctype.*;
|
||||
@@ -26,6 +28,7 @@ public class PayloadSeq{
|
||||
}
|
||||
|
||||
public void add(UnlockableContent block, int amount){
|
||||
if(block == null) return;
|
||||
payloads.increment(block, amount);
|
||||
total += amount;
|
||||
}
|
||||
@@ -42,6 +45,19 @@ public class PayloadSeq{
|
||||
stacks.each(b -> remove(b.item, b.amount));
|
||||
}
|
||||
|
||||
/** @return this object */
|
||||
public PayloadSeq removeAll(Boolf<UnlockableContent> pred){
|
||||
Entries<UnlockableContent> iter = payloads.iterator();
|
||||
while(iter.hasNext()){
|
||||
Entry<UnlockableContent> e = iter.next();
|
||||
if(pred.get(e.key)){
|
||||
iter.remove();
|
||||
total -= e.value;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
payloads.clear();
|
||||
total = 0;
|
||||
@@ -90,7 +106,7 @@ public class PayloadSeq{
|
||||
}else{
|
||||
//new format
|
||||
for(int i = 0; i < -amount; i++){
|
||||
add((UnlockableContent)Vars.content.getBy(ContentType.all[read.ub()]).get(read.s()), read.i());
|
||||
add(Vars.content.getByID(ContentType.all[read.ub()], read.s()), read.i());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import mindustry.content.*;
|
||||
import mindustry.content.TechTree.*;
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.game.EventType.ContentInitEvent;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.graphics.g3d.*;
|
||||
import mindustry.graphics.g3d.PlanetGrid.*;
|
||||
@@ -114,6 +115,8 @@ public class Planet extends UnlockableContent{
|
||||
public boolean prebuildBase = true;
|
||||
/** If true, waves are created on sector loss. TODO remove. */
|
||||
public boolean allowWaves = false;
|
||||
/** If false, players are unable to land on this planet's numbered sectors. */
|
||||
public boolean allowLaunchToNumbered = true;
|
||||
/** Icon as displayed in the planet selection dialog. This is a string, as drawables are null at load time. */
|
||||
public String icon = "planet";
|
||||
/** Default core block for launching. */
|
||||
@@ -130,8 +133,10 @@ public class Planet extends UnlockableContent{
|
||||
public @Nullable TechNode techTree;
|
||||
/** TODO remove? Planets that can be launched to from this one. Made mutual in init(). */
|
||||
public Seq<Planet> launchCandidates = new Seq<>();
|
||||
/** Items not available on this planet. */
|
||||
/** Items not available on this planet. Left out for backwards compatibility. */
|
||||
public Seq<Item> hiddenItems = new Seq<>();
|
||||
/** The only items available on this planet, if defined. */
|
||||
public Seq<Item> itemWhitelist = new Seq<>();
|
||||
/** Content (usually planet-specific) that is unlocked upon landing here. */
|
||||
public Seq<UnlockableContent> unlockedOnLand = new Seq<>();
|
||||
/** Loads the mesh. Clientside only. Defaults to a boring sphere mesh. */
|
||||
@@ -159,6 +164,13 @@ public class Planet extends UnlockableContent{
|
||||
parent.updateTotalRadius();
|
||||
}
|
||||
|
||||
//if an item whitelist exists, add everything else not in that whitelist to hidden items
|
||||
Events.on(ContentInitEvent.class, e -> {
|
||||
if(itemWhitelist.size > 0){
|
||||
hiddenItems.addAll(content.items().select(i -> !itemWhitelist.contains(i)));
|
||||
}
|
||||
});
|
||||
|
||||
//calculate solar system
|
||||
for(solarSystem = this; solarSystem.parent != null; solarSystem = solarSystem.parent);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class PayloadAmmoTurret extends Turret{
|
||||
public void read(Reads read, byte revision){
|
||||
super.read(read, revision);
|
||||
payloads.read(read);
|
||||
//TODO remove invalid ammo
|
||||
payloads.removeAll(u -> !ammoTypes.containsKey(u));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,8 @@ public class PayloadSource extends PayloadBlock{
|
||||
commandable = true;
|
||||
|
||||
config(Block.class, (PayloadSourceBuild build, Block block) -> {
|
||||
if(canProduce(block) && build.block != block){
|
||||
build.block = block;
|
||||
if(canProduce(block) && build.configBlock != block){
|
||||
build.configBlock = block;
|
||||
build.unit = null;
|
||||
build.payload = null;
|
||||
build.scl = 0f;
|
||||
@@ -51,14 +51,14 @@ public class PayloadSource extends PayloadBlock{
|
||||
config(UnitType.class, (PayloadSourceBuild build, UnitType unit) -> {
|
||||
if(canProduce(unit) && build.unit != unit){
|
||||
build.unit = unit;
|
||||
build.block = null;
|
||||
build.configBlock = null;
|
||||
build.payload = null;
|
||||
build.scl = 0f;
|
||||
}
|
||||
});
|
||||
|
||||
configClear((PayloadSourceBuild build) -> {
|
||||
build.block = null;
|
||||
build.configBlock = null;
|
||||
build.unit = null;
|
||||
build.payload = null;
|
||||
build.scl = 0f;
|
||||
@@ -87,7 +87,7 @@ public class PayloadSource extends PayloadBlock{
|
||||
|
||||
public class PayloadSourceBuild extends PayloadBlockBuild<Payload>{
|
||||
public UnitType unit;
|
||||
public Block block;
|
||||
public Block configBlock;
|
||||
public @Nullable Vec2 commandPos;
|
||||
public float scl;
|
||||
|
||||
@@ -111,7 +111,7 @@ public class PayloadSource extends PayloadBlock{
|
||||
|
||||
@Override
|
||||
public Object config(){
|
||||
return unit == null ? block : unit;
|
||||
return unit == null ? configBlock : unit;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -133,8 +133,8 @@ public class PayloadSource extends PayloadBlock{
|
||||
}
|
||||
|
||||
Events.fire(new UnitCreateEvent(p, this));
|
||||
}else if(block != null){
|
||||
payload = new BuildPayload(block, team);
|
||||
}else if(configBlock != null){
|
||||
payload = new BuildPayload(configBlock, team);
|
||||
}
|
||||
payVector.setZero();
|
||||
payRotation = rotdeg();
|
||||
@@ -159,14 +159,14 @@ public class PayloadSource extends PayloadBlock{
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
write.s(unit == null ? -1 : unit.id);
|
||||
write.s(block == null ? -1 : block.id);
|
||||
write.s(configBlock == null ? -1 : configBlock.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Reads read, byte revision){
|
||||
super.read(read, revision);
|
||||
unit = Vars.content.unit(read.s());
|
||||
block = Vars.content.block(read.s());
|
||||
configBlock = Vars.content.block(read.s());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user