mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-01-28 08:30:08 +07:00
Fixed changing cof components of an existing animation
Introduced CofComponent.setComponent(int,int) to auto set dirty flags for changed components AnimationLoaderSystem will now unset load flag for null layers and remove transform and alpha update flags CofLoaderSystem will now trigger a layer load when a nil component is encountered
This commit is contained in:
parent
d34964c4ba
commit
22d7701647
@ -95,4 +95,11 @@ public class CofComponent implements Component, Pool.Poolable {
|
||||
System.arraycopy(DEFAULT_ALPHA, 0, alpha, 0, COF.Component.NUM_COMPONENTS);
|
||||
Arrays.fill(layer, null);
|
||||
}
|
||||
|
||||
public void setComponent(int component, int code) {
|
||||
if (this.component[component] != code) {
|
||||
this.component[component] = code;
|
||||
dirty |= (1 << component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,15 +61,29 @@ public class AnimationLoaderSystem extends IteratingSystem {
|
||||
for (int l = 0, numLayers = cof.getNumLayers(); l < numLayers; l++) {
|
||||
COF.Layer layer = cof.getLayer(l);
|
||||
if (!Dirty.isDirty(cofComponent.load, layer.component)) continue;
|
||||
int flag = (1 << layer.component);
|
||||
if (cofComponent.component[layer.component] == CofComponent.COMPONENT_NIL) {
|
||||
cofComponent.load &= ~flag;
|
||||
anim.setLayer(layer, null, false);
|
||||
|
||||
transformUpdate = this.transformUpdate.get(entity);
|
||||
if (transformUpdate != null) {
|
||||
transformUpdate.flags &= ~flag;
|
||||
if (transformUpdate.flags == Dirty.NONE) entity.remove(TransformUpdate.class);
|
||||
}
|
||||
|
||||
alphaUpdate = this.alphaUpdate.get(entity);
|
||||
if (alphaUpdate != null) {
|
||||
alphaUpdate.flags &= ~flag;
|
||||
if (alphaUpdate.flags == Dirty.NONE) entity.remove(AlphaUpdate.class);
|
||||
}
|
||||
|
||||
changed = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
AssetDescriptor<? extends DC> descriptor = cofComponent.layer[layer.component];
|
||||
if (Riiablo.assets.isLoaded(descriptor)) {
|
||||
int flag = (1 << layer.component);
|
||||
cofComponent.load &= ~flag;
|
||||
if (DEBUG_LOAD) Gdx.app.debug(TAG, "finished loading " + descriptor);
|
||||
DC dc = Riiablo.assets.get(descriptor);
|
||||
|
@ -55,8 +55,8 @@ public class CofLoaderSystem extends IteratingSystem {
|
||||
if (!Dirty.isDirty(cofComponent.dirty, layer.component)) continue;
|
||||
// TODO: should also ignore COMPONENT_NULL? used to set default components
|
||||
if (cofComponent.component[layer.component] == CofComponent.COMPONENT_NIL) {
|
||||
cofComponent.layer[layer.component] = null;
|
||||
// TODO: unload existing asset?
|
||||
cofComponent.layer[layer.component] = null; // TODO: unload existing asset?
|
||||
cofComponent.load |= (1 << layer.component);
|
||||
continue;
|
||||
} else if (cofComponent.component[layer.component] == CofComponent.COMPONENT_NULL) {
|
||||
cofComponent.component[layer.component] = CofComponent.COMPONENT_LIT;
|
||||
|
@ -145,9 +145,9 @@ public class PlayerSystem extends EntitySystem implements EntityListener, CharDa
|
||||
cof.wclass = CofComponent.WEAPON_HTH;
|
||||
}
|
||||
|
||||
cof.component[COF.Component.RH] = RH != null ? TypeComponent.Type.PLR.getComponent(RH.base.alternateGfx) : CofComponent.COMPONENT_NIL;
|
||||
cof.component[COF.Component.LH] = LH != null ? TypeComponent.Type.PLR.getComponent(LH.base.alternateGfx) : CofComponent.COMPONENT_NIL;
|
||||
cof.component[COF.Component.SH] = SH != null ? TypeComponent.Type.PLR.getComponent(SH.base.alternateGfx) : CofComponent.COMPONENT_NIL;
|
||||
cof.setComponent(COF.Component.RH, RH != null ? TypeComponent.Type.PLR.getComponent(RH.base.alternateGfx) : CofComponent.COMPONENT_NIL);
|
||||
cof.setComponent(COF.Component.LH, LH != null ? TypeComponent.Type.PLR.getComponent(LH.base.alternateGfx) : CofComponent.COMPONENT_NIL);
|
||||
cof.setComponent(COF.Component.SH, SH != null ? TypeComponent.Type.PLR.getComponent(SH.base.alternateGfx) : CofComponent.COMPONENT_NIL);
|
||||
|
||||
cof.alpha[COF.Component.RH] = RH != null && RH.isEthereal() ? Item.ETHEREAL_ALPHA : CofComponent.ALPHA_NULL;
|
||||
cof.alpha[COF.Component.LH] = LH != null && LH.isEthereal() ? Item.ETHEREAL_ALPHA : CofComponent.ALPHA_NULL;
|
||||
@ -157,7 +157,7 @@ public class PlayerSystem extends EntitySystem implements EntityListener, CharDa
|
||||
|
||||
private void updateArmorClass(Entity entity, CharData charData, CofComponent cof) {
|
||||
Item head = charData.getEquipped(BodyLoc.HEAD);
|
||||
cof.component[COF.Component.HD] = head != null ? TypeComponent.Type.PLR.getComponent(head.base.alternateGfx) : CofComponent.COMPONENT_LIT;
|
||||
cof.setComponent(COF.Component.HD, head != null ? TypeComponent.Type.PLR.getComponent(head.base.alternateGfx) : CofComponent.COMPONENT_LIT);
|
||||
cof.transform[COF.Component.HD] = head != null ? (byte) ((head.base.Transform << 5) | (head.charColorIndex & 0x1F)) : CofComponent.TRANSFORM_NULL;
|
||||
TransformUpdate transformUpdate = com.riiablo.engine.Engine.getOrCreateComponent(entity, getEngine(), TransformUpdate.class, this.transformUpdate);
|
||||
transformUpdate.flags |= BodyLoc.HEAD.components();
|
||||
@ -165,12 +165,12 @@ public class PlayerSystem extends EntitySystem implements EntityListener, CharDa
|
||||
Item body = charData.getEquipped(BodyLoc.TORS);
|
||||
if (body != null) {
|
||||
Armor.Entry armor = body.getBase();
|
||||
cof.component[COF.Component.TR] = (armor.Torso + 1);
|
||||
cof.component[COF.Component.LG] = (armor.Legs + 1);
|
||||
cof.component[COF.Component.RA] = (armor.rArm + 1);
|
||||
cof.component[COF.Component.LA] = (armor.lArm + 1);
|
||||
cof.component[COF.Component.S1] = (armor.lSPad + 1);
|
||||
cof.component[COF.Component.S2] = (armor.rSPad + 1);
|
||||
cof.setComponent(COF.Component.TR, (armor.Torso + 1));
|
||||
cof.setComponent(COF.Component.LG, (armor.Legs + 1));
|
||||
cof.setComponent(COF.Component.RA, (armor.rArm + 1));
|
||||
cof.setComponent(COF.Component.LA, (armor.lArm + 1));
|
||||
cof.setComponent(COF.Component.S1, (armor.lSPad + 1));
|
||||
cof.setComponent(COF.Component.S2, (armor.rSPad + 1));
|
||||
|
||||
byte packedTransform = (byte) ((body.base.Transform << 5) | (body.charColorIndex & 0x1F));
|
||||
cof.transform[COF.Component.TR] = packedTransform;
|
||||
@ -181,12 +181,12 @@ public class PlayerSystem extends EntitySystem implements EntityListener, CharDa
|
||||
cof.transform[COF.Component.S2] = packedTransform;
|
||||
transformUpdate.flags |= BodyLoc.TORS.components();
|
||||
} else {
|
||||
cof.component[COF.Component.TR] = CofComponent.COMPONENT_LIT;
|
||||
cof.component[COF.Component.LG] = CofComponent.COMPONENT_LIT;
|
||||
cof.component[COF.Component.RA] = CofComponent.COMPONENT_LIT;
|
||||
cof.component[COF.Component.LA] = CofComponent.COMPONENT_LIT;
|
||||
cof.component[COF.Component.S1] = CofComponent.COMPONENT_LIT;
|
||||
cof.component[COF.Component.S2] = CofComponent.COMPONENT_LIT;
|
||||
cof.setComponent(COF.Component.TR, CofComponent.COMPONENT_LIT);
|
||||
cof.setComponent(COF.Component.LG, CofComponent.COMPONENT_LIT);
|
||||
cof.setComponent(COF.Component.RA, CofComponent.COMPONENT_LIT);
|
||||
cof.setComponent(COF.Component.LA, CofComponent.COMPONENT_LIT);
|
||||
cof.setComponent(COF.Component.S1, CofComponent.COMPONENT_LIT);
|
||||
cof.setComponent(COF.Component.S2, CofComponent.COMPONENT_LIT);
|
||||
|
||||
cof.transform[COF.Component.TR] = CofComponent.TRANSFORM_NULL;
|
||||
cof.transform[COF.Component.LG] = CofComponent.TRANSFORM_NULL;
|
||||
@ -202,7 +202,7 @@ public class PlayerSystem extends EntitySystem implements EntityListener, CharDa
|
||||
public void onChanged(CharData client, BodyLoc bodyLoc, Item oldItem, Item item) {
|
||||
Entity entity = charDatas.get(client);
|
||||
CofComponent cofComponent = this.cofComponent.get(entity);
|
||||
cofComponent.dirty |= bodyLoc.components();
|
||||
//cofComponent.dirty |= bodyLoc.components();
|
||||
updateWeaponClass(entity, client, cofComponent);
|
||||
updateArmorClass(entity, client, cofComponent);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user