public void TestBoltEffect() { IEntity entity = new Entity(0x1000, new Point3D(1000, 100, -10), Map.Felucca); var hue = 0x1024; var data = new BoltEffect(entity, hue).Compile(); Span <byte> expectedData = stackalloc byte[36]; var pos = 0; expectedData.Write(ref pos, (byte)0xC0); // Packet ID expectedData.Write(ref pos, (byte)0x01); // Effect expectedData.Write(ref pos, entity.Serial); #if NO_LOCAL_INIT expectedData.Write(ref pos, 0); expectedData.Write(ref pos, (ushort)0); #else pos += 6; #endif expectedData.Write(ref pos, entity.Location); expectedData.Write(ref pos, entity.Location); #if NO_LOCAL_INIT expectedData.Write(ref pos, 0); expectedData.Write(ref pos, (ushort)0); #else pos += 6; #endif expectedData.Write(ref pos, hue); AssertThat.Equal(data, expectedData); }
public static void SendBoltEffect(IEntity e, bool sound, int hue) { Map map = e.Map; if (map == null) { return; } if (e is Item) { ((Item)e).ProcessDelta(); } else if (e is Mobile) { ((Mobile)e).ProcessDelta(); } Packet preEffect = null, boltEffect = null, playSound = null; IPooledEnumerable eable = map.GetClientsInRange(e.Location); foreach (NetState state in eable) { if (state.Mobile.CanSee(e)) { if (SendParticlesTo(state)) { if (preEffect == null) { preEffect = new TargetParticleEffect(e, 0, 10, 5, 0, 0, 5031, 3, 0); } state.Send(preEffect); } if (boltEffect == null) { boltEffect = new BoltEffect(e, hue); } state.Send(boltEffect); if (sound) { if (playSound == null) { playSound = new PlaySound(0x29, e); } state.Send(playSound); } } } eable.Free(); }
public void TestBoltEffect() { IEntity entity = new Entity((Serial)0x1000, new Point3D(1000, 100, -10), Map.Felucca); var hue = 0x1024; var expected = new BoltEffect(entity, hue).Compile(); Span <byte> actual = stackalloc byte[OutgoingEffectPackets.BoltEffectLength]; OutgoingEffectPackets.CreateBoltEffect(actual, entity, hue); AssertThat.Equal(actual, expected); }
public static void SendBoltEffect(IEntity e, bool sound, int hue) { Map map1 = e.Map; if (map1 == null) { return; } if ((e is Item)) { ((Item)e).ProcessDelta(); } else if ((e is Mobile)) { ((Mobile)e).ProcessDelta(); } Packet packet1 = null; Packet packet2 = null; Packet packet3 = null; IPooledEnumerable enumerable1 = map1.GetClientsInRange(e.Location); foreach (NetState state1 in enumerable1) { if (state1.Mobile.CanSee(e)) { if (Effects.SendParticlesTo(state1)) { if (packet1 == null) { packet1 = new TargetParticleEffect(e, 0, 10, 5, 0, 0, 5031, 3, 0); } state1.Send(packet1); } if (packet2 == null) { packet2 = new BoltEffect(e, hue); } state1.Send(packet2); if (sound) { if (packet3 == null) { packet3 = new PlaySound(41, e); } state1.Send(packet3); } } } enumerable1.Free(); }