Cleanup / Fixed unlock system in custom games
This commit is contained in:
@@ -232,11 +232,3 @@ project(":kryonet") {
|
|||||||
compile 'com.github.Anuken:WaifUPnP:05eb46bc577fd7674596946ba288c96c0cedd893'
|
compile 'com.github.Anuken:WaifUPnP:05eb46bc577fd7674596946ba288c96c0cedd893'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
project(":reporter"){
|
|
||||||
apply plugin: "java"
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.eclipse.doLast {
|
|
||||||
delete ".project"
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -410,7 +410,7 @@ mode.waves.name=waves
|
|||||||
mode.waves.description=the normal mode. limited resources and automatic incoming waves.
|
mode.waves.description=the normal mode. limited resources and automatic incoming waves.
|
||||||
mode.sandbox.name=sandbox
|
mode.sandbox.name=sandbox
|
||||||
mode.sandbox.description=infinite resources and no timer for waves.
|
mode.sandbox.description=infinite resources and no timer for waves.
|
||||||
mode.custom.warning=Note that blocks cannot be used in custom games until they are unlocked in sectors.\n\n[LIGHT_GRAY]If you have not unlocked any blocks, none will appear.
|
mode.custom.warning=Note that blocks unlocked in custom games are not carried over to sectors.\n\n[LIGHT_GRAY]In sandbox, only blocks unlocked with sector play can be used.
|
||||||
mode.freebuild.name=freebuild
|
mode.freebuild.name=freebuild
|
||||||
mode.freebuild.description=limited resources and no timer for waves.
|
mode.freebuild.description=limited resources and no timer for waves.
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input;
|
|
||||||
import com.badlogic.gdx.audio.Sound;
|
import com.badlogic.gdx.audio.Sound;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
@@ -11,7 +10,7 @@ import io.anuke.mindustry.core.GameState.State;
|
|||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.ContentDatabase;
|
import io.anuke.mindustry.game.Unlocks;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.game.Saves;
|
import io.anuke.mindustry.game.Saves;
|
||||||
import io.anuke.mindustry.input.DefaultKeybinds;
|
import io.anuke.mindustry.input.DefaultKeybinds;
|
||||||
@@ -44,7 +43,7 @@ public class Control extends Module{
|
|||||||
private boolean hiscore = false;
|
private boolean hiscore = false;
|
||||||
private boolean wasPaused = false;
|
private boolean wasPaused = false;
|
||||||
private Saves saves;
|
private Saves saves;
|
||||||
private ContentDatabase db;
|
private Unlocks unlocks;
|
||||||
private InputHandler[] inputs = {};
|
private InputHandler[] inputs = {};
|
||||||
private ObjectMap<Sound, Long> soundMap = new ObjectMap<>();
|
private ObjectMap<Sound, Long> soundMap = new ObjectMap<>();
|
||||||
|
|
||||||
@@ -53,7 +52,7 @@ public class Control extends Module{
|
|||||||
public Control(){
|
public Control(){
|
||||||
|
|
||||||
saves = new Saves();
|
saves = new Saves();
|
||||||
db = new ContentDatabase();
|
unlocks = new Unlocks();
|
||||||
|
|
||||||
Inputs.useControllers(!gwt);
|
Inputs.useControllers(!gwt);
|
||||||
|
|
||||||
@@ -66,7 +65,7 @@ public class Control extends Module{
|
|||||||
Core.atlas.setErrorRegion("error");
|
Core.atlas.setErrorRegion("error");
|
||||||
content.initialize(Content::load);
|
content.initialize(Content::load);
|
||||||
|
|
||||||
db.load();
|
unlocks.load();
|
||||||
|
|
||||||
Sounds.setFalloff(9000f);
|
Sounds.setFalloff(9000f);
|
||||||
Sounds.setPlayer((sound, volume) -> {
|
Sounds.setPlayer((sound, volume) -> {
|
||||||
@@ -219,12 +218,8 @@ public class Control extends Module{
|
|||||||
System.arraycopy(oldi, 0, inputs, 0, inputs.length);
|
System.arraycopy(oldi, 0, inputs, 0, inputs.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentDatabase database(){
|
public Unlocks unlocks(){
|
||||||
return db;
|
return unlocks;
|
||||||
}
|
|
||||||
|
|
||||||
public Input gdxInput(){
|
|
||||||
return Gdx.input;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setError(Throwable error){
|
public void setError(Throwable error){
|
||||||
@@ -239,10 +234,6 @@ public class Control extends Module{
|
|||||||
return inputs[index];
|
return inputs[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void triggerUpdateInput(){
|
|
||||||
//Gdx.input = proxy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playMap(Map map){
|
public void playMap(Map map){
|
||||||
ui.loadfrag.show();
|
ui.loadfrag.show();
|
||||||
|
|
||||||
@@ -265,10 +256,10 @@ public class Control extends Module{
|
|||||||
|
|
||||||
if(entity == null) return;
|
if(entity == null) return;
|
||||||
|
|
||||||
entity.items.forEach((item, amount) -> control.database().unlockContent(item));
|
entity.items.forEach((item, amount) -> control.unlocks().unlockContent(item));
|
||||||
|
|
||||||
if(players[0].inventory.hasItem()){
|
if(players[0].inventory.hasItem()){
|
||||||
control.database().unlockContent(players[0].inventory.getItem().item);
|
control.unlocks().unlockContent(players[0].inventory.getItem().item);
|
||||||
}
|
}
|
||||||
|
|
||||||
outer:
|
outer:
|
||||||
@@ -279,7 +270,7 @@ public class Control extends Module{
|
|||||||
if(!entity.items.has(stack.item, Math.min((int) (stack.amount * unlockResourceScaling), 2000))) continue outer;
|
if(!entity.items.has(stack.item, Math.min((int) (stack.amount * unlockResourceScaling), 2000))) continue outer;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(control.database().unlockContent(recipe)){
|
if(control.unlocks().unlockContent(recipe)){
|
||||||
ui.hudfrag.showUnlock(recipe);
|
ui.hudfrag.showUnlock(recipe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -349,8 +340,6 @@ public class Control extends Module{
|
|||||||
|
|
||||||
saves.update();
|
saves.update();
|
||||||
|
|
||||||
triggerUpdateInput();
|
|
||||||
|
|
||||||
for(InputHandler inputHandler : inputs){
|
for(InputHandler inputHandler : inputs){
|
||||||
inputHandler.updateController();
|
inputHandler.updateController();
|
||||||
}
|
}
|
||||||
@@ -369,9 +358,9 @@ public class Control extends Module{
|
|||||||
if(!state.mode.infiniteResources && Timers.get("timerCheckUnlock", 120)){
|
if(!state.mode.infiniteResources && Timers.get("timerCheckUnlock", 120)){
|
||||||
checkUnlockableBlocks();
|
checkUnlockableBlocks();
|
||||||
|
|
||||||
//save if the db changed
|
//save if the unlocks changed
|
||||||
if(db.isDirty()){
|
if(unlocks.isDirty()){
|
||||||
db.save();
|
unlocks.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -125,8 +125,6 @@ public class Logic extends Module{
|
|||||||
|
|
||||||
if(!state.is(State.menu)){
|
if(!state.is(State.menu)){
|
||||||
|
|
||||||
if(control != null) control.triggerUpdateInput();
|
|
||||||
|
|
||||||
if(!state.is(State.paused) || Net.active()){
|
if(!state.is(State.paused) || Net.active()){
|
||||||
Timers.update();
|
Timers.update();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
|
|
||||||
for(Block block : Vars.content.blocks()){
|
for(Block block : Vars.content.blocks()){
|
||||||
TextureRegion[] regions = block.getCompactIcon();
|
TextureRegion[] regions = block.getCompactIcon();
|
||||||
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.database().isUnlocked(Recipe.getByResult(block))))
|
if((block.synthetic() && (Recipe.getByResult(block) == null || !control.unlocks().isUnlocked(Recipe.getByResult(block))))
|
||||||
&& block != StorageBlocks.core){
|
&& block != StorageBlocks.core){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -480,7 +480,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
return;
|
return;
|
||||||
}else{
|
}else{
|
||||||
//unlock mech when used
|
//unlock mech when used
|
||||||
control.database().unlockContent(mech);
|
control.unlocks().unlockContent(mech);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mobile){
|
if(mobile){
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class UnitDrops{
|
|||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(Item item : dropTable){
|
for(Item item : dropTable){
|
||||||
//only drop unlocked items
|
//only drop unlocked items
|
||||||
if(!Vars.headless && !Vars.control.database().isUnlocked(item)){
|
if(!Vars.headless && !Vars.control.unlocks().isUnlocked(item)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
for(UnlockableContent cont : depend){
|
for(UnlockableContent cont : depend){
|
||||||
if(!control.database().isUnlocked(cont)){
|
if(!control.unlocks().isUnlocked(cont)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ import io.anuke.ucore.core.Settings;
|
|||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ContentDatabase{
|
/**Stores player unlocks. Clientside only.*/
|
||||||
|
public class Unlocks{
|
||||||
private ObjectMap<String, ContentUnlockSet> sets = new ObjectMap<>();
|
private ObjectMap<String, ContentUnlockSet> sets = new ObjectMap<>();
|
||||||
|
|
||||||
static{
|
static{
|
||||||
@@ -40,10 +41,8 @@ public class ContentDatabase{
|
|||||||
return getSet(Net.getLastIP());
|
return getSet(Net.getLastIP());
|
||||||
}else if(world.getSector() != null || state.mode.infiniteResources){ //sector-sandbox have shared set
|
}else if(world.getSector() != null || state.mode.infiniteResources){ //sector-sandbox have shared set
|
||||||
return rootSet();
|
return rootSet();
|
||||||
}else if(control != null && control.getSaves().getCurrent() != null){ //per-save set
|
}else{ //per-mode set
|
||||||
return getSet(String.valueOf(control.getSaves().getCurrent().index));
|
return getSet(state.mode.name());
|
||||||
}else{ //dedicated server set
|
|
||||||
return rootSet();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawOutlined(){
|
public void drawOutlined(){
|
||||||
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
Tile cursor = tileAt(Gdx.input.getX(), Gdx.input.getY());
|
||||||
|
|
||||||
if(cursor == null) return;
|
if(cursor == null) return;
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
rotation = Mathf.mod(rotation + (int) Inputs.getAxisTapped(section, "rotate"), 4);
|
rotation = Mathf.mod(rotation + (int) Inputs.getAxisTapped(section, "rotate"), 4);
|
||||||
|
|
||||||
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
Tile cursor = tileAt(Gdx.input.getX(), Gdx.input.getY());
|
||||||
|
|
||||||
if(player.isDead()){
|
if(player.isDead()){
|
||||||
cursorType = normal;
|
cursorType = normal;
|
||||||
@@ -200,7 +200,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void pollInput(){
|
void pollInput(){
|
||||||
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
Tile cursor = tileAt(Gdx.input.getX(), Gdx.input.getY());
|
||||||
if(cursor == null){
|
if(cursor == null){
|
||||||
mode = none;
|
mode = none;
|
||||||
return;
|
return;
|
||||||
@@ -271,12 +271,12 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMouseX(){
|
public float getMouseX(){
|
||||||
return !controlling ? control.gdxInput().getX() : controlx;
|
return !controlling ? Gdx.input.getX() : controlx;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getMouseY(){
|
public float getMouseY(){
|
||||||
return !controlling ? control.gdxInput().getY() : controly;
|
return !controlling ? Gdx.input.getY() : controly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -329,8 +329,8 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!controlling){
|
if(!controlling){
|
||||||
controlx = control.gdxInput().getX();
|
controlx = Gdx.input.getX();
|
||||||
controly = control.gdxInput().getY();
|
controly = Gdx.input.getY();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.input;
|
package io.anuke.mindustry.input;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.InputAdapter;
|
import com.badlogic.gdx.InputAdapter;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
@@ -130,11 +131,11 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getMouseX(){
|
public float getMouseX(){
|
||||||
return control.gdxInput().getX();
|
return Gdx.input.getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getMouseY(){
|
public float getMouseY(){
|
||||||
return control.gdxInput().getY();
|
return Gdx.input.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetCursor(){
|
public void resetCursor(){
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
//Draw lines
|
//Draw lines
|
||||||
if(lineMode){
|
if(lineMode){
|
||||||
Tile tile = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
Tile tile = tileAt(Gdx.input.getX(), Gdx.input.getY());
|
||||||
|
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,7 @@ public class Recipe extends UnlockableContent{
|
|||||||
|
|
||||||
arr.clear();
|
arr.clear();
|
||||||
for(Recipe r : content.recipes()){
|
for(Recipe r : content.recipes()){
|
||||||
if(r.category == category && (control.database().isUnlocked(r)) &&
|
if(r.category == category && (control.unlocks().isUnlocked(r)) &&
|
||||||
!((r.mode != null && r.mode != state.mode) || (r.desktopOnly && mobile) || (r.isPad && !state.mode.showPads))){
|
!((r.mode != null && r.mode != state.mode) || (r.desktopOnly && mobile) || (r.isPad && !state.mode.showPads))){
|
||||||
arr.add(r);
|
arr.add(r);
|
||||||
}
|
}
|
||||||
@@ -168,7 +168,7 @@ public class Recipe extends UnlockableContent{
|
|||||||
ContentStatValue stat = (ContentStatValue) value;
|
ContentStatValue stat = (ContentStatValue) value;
|
||||||
UnlockableContent[] content = stat.getValueContent();
|
UnlockableContent[] content = stat.getValueContent();
|
||||||
for(UnlockableContent c : content){
|
for(UnlockableContent c : content){
|
||||||
control.database().unlockContent(c);
|
control.unlocks().unlockContent(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,11 +59,11 @@ public class UnlocksDialog extends FloatingDialog{
|
|||||||
|
|
||||||
if(unlock.isHidden()) continue;
|
if(unlock.isHidden()) continue;
|
||||||
|
|
||||||
Image image = control.database().isUnlocked(unlock) ? new Image(unlock.getContentIcon()) : new Image("icon-locked");
|
Image image = control.unlocks().isUnlocked(unlock) ? new Image(unlock.getContentIcon()) : new Image("icon-locked");
|
||||||
image.addListener(new HandCursorListener());
|
image.addListener(new HandCursorListener());
|
||||||
list.add(image).size(size).pad(3);
|
list.add(image).size(size).pad(3);
|
||||||
|
|
||||||
if(control.database().isUnlocked(unlock)){
|
if(control.unlocks().isUnlocked(unlock)){
|
||||||
image.clicked(() -> Vars.ui.content.show(unlock));
|
image.clicked(() -> Vars.ui.content.show(unlock));
|
||||||
image.addListener(new Tooltip<>(new Table("clear"){{
|
image.addListener(new Tooltip<>(new Table("clear"){{
|
||||||
add(unlock.localizedName());
|
add(unlock.localizedName());
|
||||||
|
|||||||
@@ -219,7 +219,7 @@ public class Block extends BaseBlock {
|
|||||||
/**Call when some content is produced. This unlocks the content if it is applicable.*/
|
/**Call when some content is produced. This unlocks the content if it is applicable.*/
|
||||||
public void useContent(UnlockableContent content){
|
public void useContent(UnlockableContent content){
|
||||||
if(!headless){
|
if(!headless){
|
||||||
control.database().unlockContent(content);
|
control.unlocks().unlockContent(content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public interface SelectionTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(Item item : items){
|
for(Item item : items){
|
||||||
if(!control.database().isUnlocked(item)) continue;
|
if(!control.unlocks().isUnlocked(item)) continue;
|
||||||
|
|
||||||
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> consumer.accept(item))
|
ImageButton button = cont.addImageButton("white", "toggle", 24, () -> consumer.accept(item))
|
||||||
.group(group).get();
|
.group(group).get();
|
||||||
|
|||||||
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,6 @@
|
|||||||
|
#Fri Sep 28 23:13:02 PDT 2018
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-bin.zip
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-4.9-all.zip
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
include 'desktop', 'html', 'core', 'android', 'kryonet', 'server', 'ios', 'annotations', 'packer', 'reporter'
|
include 'desktop', 'html', 'core', 'android', 'kryonet', 'server', 'ios', 'annotations', 'packer'
|
||||||
|
|
||||||
if(System.properties["release"] == null || System.properties["release"].equals("false")){
|
if(System.properties["release"] == null || System.properties["release"].equals("false")){
|
||||||
if (new File(settingsDir, '../uCore').exists()) {
|
if (new File(settingsDir, '../uCore').exists()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user