void ChangeElement(int index, int newType) { var p = powders[index]; PowderSystemUtils.SchdeduleRemovePowder(ref toDeleteEntities, index); PowderGame.Spawn(ref cmdBuffer, p.coord.x, p.coord.y, newType); }
void Lava(ref Powder p, ref Neighbors n) { if (!n.BottomEmpty() && powders[n.Bottom()].type != PowderTypes.Fire && powders[n.Bottom()].type != PowderTypes.Lava && powders[n.Bottom()].type != PowderTypes.Stone ) { PowderSystemUtils.SchdeduleRemovePowder(ref toDeleteEntities, n.Bottom()); } }
void AcidTouch(int index) { if (powders[index].type != PowderTypes.Acid && powders[index].type != PowderTypes.Fire && powders[index].type != PowderTypes.Water && powders[index].type != PowderTypes.Glass && powders[index].type != PowderTypes.Lava ) { PowderSystemUtils.SchdeduleRemovePowder(ref toDeleteEntities, index); } }
void Water(ref Powder p, ref Neighbors n) { if (!n.BottomEmpty()) { if (powders[n.Bottom()].type == PowderTypes.Fire || powders[n.Bottom()].type == PowderTypes.Steam) { PowderSystemUtils.SchdeduleRemovePowder(ref toDeleteEntities, n.Bottom()); } else if (powders[n.Bottom()].type == PowderTypes.Lava) { ChangeElement(n.index, PowderTypes.Steam); } } }
Powder Simulate(Powder p, int index) { if (p.life == 0 || p.coord.x < 0 || p.coord.x > PowderGame.width || p.coord.y < 0 || p.coord.y > PowderGame.height) { PowderSystemUtils.SchdeduleRemovePowder(ref toDeleteEntities, index); return(p); } if (p.life != -1) { p.life--; } var n = new Neighbors(ref hashMap, p, index); SimulateState(ref p, ref n); switch (p.type) { case PowderTypes.Acid: Acid(ref p, ref n); break; case PowderTypes.Fire: Fire(ref p, ref n); break; case PowderTypes.Steam: Steam(ref p, ref n); break; case PowderTypes.Water: Water(ref p, ref n); break; case PowderTypes.Lava: Lava(ref p, ref n); break; default: if (PowderTypes.values[p.type].IsGenerator()) { Generate(ref p, ref n); } break; } return(p); }