public void PaintBomb(Location pos, byte bcol, double rad = 5f) { foreach (Location loc in GetBlocksInRadius(pos, 5)) { // TODO: Ray-trace the block? BlockInternal bi = GetBlockInternal(loc); SetBlockMaterial(loc, (Material)bi.BlockMaterial, bi.BlockData, bcol, (byte)(bi.BlockLocalData | (byte)BlockFlags.EDITED), bi.Damage); } System.Drawing.Color ccol = Colors.ForByte(bcol); ParticleEffectPacketOut pepo = new ParticleEffectPacketOut(ParticleEffectNetType.PAINT_BOMB, rad + 15, pos, new Location(ccol.R / 255f, ccol.G / 255f, ccol.B / 255f)); foreach (PlayerEntity pe in GetPlayersInRadius(pos, rad + 30)) // TODO: Better particle view dist { pe.Network.SendPacket(pepo); } // TODO: Sound effect? }
public void Explode(Location pos, double rad = 5f, bool effect = true, bool breakblock = true, bool applyforce = true, bool doDamage = true) { if (doDamage) { // TODO: DO DAMAGE! } double expDamage = 5 * rad; CheckThreadValidity(); if (breakblock) { int min = (int)Math.Floor(-rad); int max = (int)Math.Ceiling(rad); for (int x = min; x < max; x++) { for (int y = min; y < max; y++) { for (int z = min; z < max; z++) { Location post = new Location(pos.X + x, pos.Y + y, pos.Z + z); // TODO: Defensive wall structuring - trace lines and break as appropriate. if ((post - pos).LengthSquared() <= rad * rad && GetBlockMaterial(post).GetHardness() <= expDamage / (post - pos).Length()) { BreakNaturally(post, true); } } } } } if (effect) { ParticleEffectPacketOut pepo = new ParticleEffectPacketOut(ParticleEffectNetType.EXPLOSION, rad, pos); foreach (PlayerEntity pe in GetPlayersInRadius(pos, rad + 30)) // TODO: Better particle view dist { pe.Network.SendPacket(pepo); } // TODO: Sound effect? } if (applyforce) { foreach (Entity e in GetEntitiesInRadius(pos, rad * 5)) // TODO: Physent-specific search method? { // TODO: Generic entity 'ApplyForce' method if (e is PhysicsEntity) { Location offs = e.GetPosition() - pos; double dpower = (double)((rad * 5) - offs.Length()); // TODO: Efficiency? Location force = new Location(1, 1, 3) * dpower; ((PhysicsEntity)e).ApplyForce(force); } } } }