Bugfixes / Cleanup

This commit is contained in:
Anuken
2020-05-11 23:40:23 -04:00
parent 8e50228df2
commit 43642ff546
8 changed files with 37 additions and 32 deletions

View File

@@ -1,6 +1,7 @@
package mindustry.game;
import arc.*;
import arc.math.*;
import arc.struct.*;
import arc.files.*;
import arc.util.ArcAnnotate.*;
@@ -98,8 +99,10 @@ public class GlobalData{
items.getAndIncrement(item, 0, amount);
state.stats.itemsDelivered.getAndIncrement(item, 0, amount);
//clamp to capacity
items.put(item, Mathf.clamp(items.get(item), 0, getItemCapacity()));
//clamp overflow
if(items.get(item, 0) < 0) items.put(item, Integer.MAX_VALUE);
if(state.stats.itemsDelivered.get(item, 0) < 0) state.stats.itemsDelivered.put(item, Integer.MAX_VALUE);
}
@@ -139,6 +142,11 @@ public class GlobalData{
return items;
}
//TODO: make it upgradeable
public int getItemCapacity(){
return 10000;
}
/** Returns whether or not this piece of content is unlocked yet. */
public boolean isUnlocked(UnlockableContent content){
return content.alwaysUnlocked() || unlocked.getOr(content.getContentType(), ObjectSet::new).contains(content.name);