Memory optimizations, multithreading fixes, uCore updated

This commit is contained in:
Anuken
2018-06-05 14:03:08 -04:00
parent c5ed0afb4e
commit 917e2e40fb
87 changed files with 1018 additions and 752 deletions

View File

@@ -1,14 +1,22 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.utils.Array;
/**Base interface for an unlockable content type.*/
public interface Content {
/**Returns the unqiue name of this piece of content.
* The name only needs to be unique for all content of this type.
* Do not use IDs for names! Make sure this string stays constant with each update unless removed.
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).*/
String getContentName();
/**Returns the type name of this piece of content.
* This should return the same value for all instances of this content type.*/
String getContentTypeName();
/**Returns a list of all instances of this content.*/
Array<? extends Content> getAll();
/**Called after all content is created. Use for loading texture regions and other data.
* Do not use to load regions!*/
default void init(){}
/**Called after all content is created, only on non-headless versions.
* Use for loading regions or other image data.*/
default void load(){}
}

View File

@@ -15,7 +15,7 @@ public class ContentDatabase {
private boolean dirty;
/**Returns whether or not this piece of content is unlocked yet.*/
public boolean isUnlocked(Content content){
public boolean isUnlocked(UnlockableContent content){
if(!unlocked.containsKey(content.getContentTypeName())){
unlocked.put(content.getContentTypeName(), new ObjectSet<>());
}
@@ -29,7 +29,7 @@ public class ContentDatabase {
* If this piece of content is already unlocked, nothing changes.
* Results are not saved until you call {@link #save()}.
* @return whether or not this content was newly unlocked.*/
public boolean unlockContent(Content content){
public boolean unlockContent(UnlockableContent content){
if(!unlocked.containsKey(content.getContentTypeName())){
unlocked.put(content.getContentTypeName(), new ObjectSet<>());
}

View File

@@ -1,19 +1,20 @@
package io.anuke.mindustry.game;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectSet;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.util.ThreadArray;
import io.anuke.ucore.util.ThreadSet;
/**Class for various team-based utilities.*/
public class TeamInfo {
private ObjectMap<Team, TeamData> map = new ObjectMap<>();
private ObjectSet<Team> allies = new ObjectSet<>(),
enemies = new ObjectSet<>();
private ObjectSet<TeamData> allyData = new ObjectSet<>(),
enemyData = new ObjectSet<>();
private ObjectSet<TeamData> allTeamData = new ObjectSet<>();
private ObjectSet<Team> allTeams = new ObjectSet<>();
private ThreadSet<Team> allies = new ThreadSet<>(),
enemies = new ThreadSet<>();
private ThreadSet<TeamData> allyData = new ThreadSet<>(),
enemyData = new ThreadSet<>();
private ThreadSet<TeamData> allTeamData = new ThreadSet<>();
private ThreadSet<Team> allTeams = new ThreadSet<>();
/**Returns all teams on a side.*/
public ObjectSet<TeamData> getTeams(boolean ally) {
@@ -93,7 +94,7 @@ public class TeamInfo {
}
public class TeamData {
public final Array<Tile> cores = new Array<>();
public final ThreadArray<Tile> cores = new ThreadArray<>();
public final Team team;
public final boolean ally;

View File

@@ -0,0 +1,11 @@
package io.anuke.mindustry.game;
/**Base interface for an unlockable content type.*/
public interface UnlockableContent extends Content{
/**Returns the unqiue name of this piece of content.
* The name only needs to be unique for all content of this type.
* Do not use IDs for names! Make sure this string stays constant with each update unless removed.
* (e.g. having a recipe and a block, both with name "wall" is fine, as they are different types).*/
String getContentName();
}