Entity name mapping

This commit is contained in:
Anuken
2020-02-07 09:36:51 -05:00
parent eeae5149a1
commit 33e818a757
12 changed files with 453 additions and 387 deletions

View File

@@ -1,21 +1,24 @@
package mindustry.content;
import mindustry.ctype.*;
import mindustry.gen.*;
import mindustry.type.*;
public class UnitTypes implements ContentList{
public static UnitDef
draug, spirit, phantom,
wraith, ghoul, revenant, lich, reaper,
dagger, crawler, titan, fortress, eruptor, chaosArray, eradicator;
crawler, titan, fortress, eruptor, chaosArray, eradicator;
//TODO can't get comp classes
public static UnitDef dagger;
public static UnitDef vanguard, alpha, delta, tau, omega, dart, javelin, trident, glaive;
public static UnitDef starter;
@Override
public void load(){
dagger = new UnitDef("dagger", GenericUnitEntity::create){{
dagger = new UnitDef("dagger"){{
speed = 0.2f;
drag = 0.4f;
hitsize = 8f;

View File

@@ -340,7 +340,7 @@ public class NetClient implements ApplicationListener{
//entity must not be added yet, so create it
if(entity == null){
entity = (Syncc)ClassMapping.map(typeID).get();
entity = (Syncc)EntityMapping.map(typeID).get();
entity.id(id);
if(!netClient.isEntityUsed(entity.id())){
add = true;

View File

@@ -138,8 +138,8 @@ abstract class UnitComp implements Healthc, Velc, Statusc, Teamc, Itemsc, Hitbox
//ScorchDecal.create(getX(), getY());
Fx.explosion.at(this);
Effects.shake(2f, 2f, this);
type.deathSound.at(this);
Sounds.bang.at(this);
Events.fire(new UnitDestroyEvent(this));
//TODO implement suicide bomb trigger

View File

@@ -247,7 +247,7 @@ public abstract class SaveVersion extends SaveFileReader{
for(int j = 0; j < amount; j++){
readChunk(stream, true, in -> {
byte typeid = in.readByte();
Syncc sync = (Syncc)ClassMapping.map(typeid).get();
Syncc sync = (Syncc)EntityMapping.map(typeid).get();
sync.read(in);
});
}

View File

@@ -53,13 +53,14 @@ public class UnitDef extends UnlockableContent{
public Array<Weapon> weapons = new Array<>();
public TextureRegion baseRegion, legRegion, region, cellRegion, occlusionRegion;
public UnitDef(String name, Prov<Unitc> constructor){
super(name);
this.constructor = constructor;
}
public UnitDef(String name){
this(name, () -> Nulls.unit);
super(name);
if(EntityMapping.map(name) != null){
constructor = EntityMapping.map(name);
}else{
constructor = () -> Nulls.unit;
}
}
public UnitController createController(){