public static void SendDamageToAll(this Mobile m, int amount) { if (amount < 0) { return; } Map map = m.Map; if (map == null) { return; } Packet p = Packet.Acquire(new DamagePacket(m, amount)); foreach (GameClient ns in map.GetClientsInRange(m.Location)) { if (ns.Mobile.CanSee(m)) { ns.Send(p); } } Packet.Release(p); }
public static void FreeRemoveItemPacket(IEntity entity) { if (RemoveEntityPackets.TryRemove(entity, out var p)) { Packet.Release(p); } }
private static void Mobile_Animated(Mobile m, AnimatedEventArgs args) { int action = args.Action; int subAction = args.SubAction; Map map = m.Map; if (map != null) { m.ProcessDelta(); Packet p = null; foreach (GameClient state in map.GetClientsInRange(m.Location)) { if (state.Mobile.CanSee(m)) { state.Mobile.ProcessDelta(); if (p == null) { p = Packet.Acquire(new MobileAnimation(m, action, subAction)); } state.Send(p); } } if (p != null) { p.Release(); } } }
public static void Release(Packet p) { if (p != null) { p.Release(); } }
public static OPLInfo FreeOPLInfoPacket(IPropertyListObject obj) { if (OPLInfoPackets.TryRemove(obj, out OPLInfo p)) { Packet.Release(p); } return(p); }
public static void Release(ref Packet p) { if (p != null) { p.Release(); } p = null; }
public static void FreeWorldItemPackets(Item item) { if (WorldItemPackets.TryRemove(item, out WorldItem wi)) { Packet.Release(wi); } if (WorldItemSAPackets.TryRemove(item, out WorldItemSA wisa)) { Packet.Release(wisa); } if (WorldItemHSPackets.TryRemove(item, out WorldItemHS wihs)) { Packet.Release(wihs); } }
private static void Mobile_ItemLifted(Mobile m, ItemLiftedEventArgs args) { var item = args.Item; var amount = args.Amount; var map = m.Map; var root = item.RootParent; if (map != null && (root == null || root is Item)) { Packet p = null; foreach (var ns in map.GetClientsInRange(m.Location)) { if (ns.Mobile != m && ns.Mobile.CanSee(m)) { if (p == null) { IEntity src; if (root == null) { src = new DummyEntity(Serial.Zero, item.Location, map); } else { src = new DummyEntity(((Item)root).Serial, ((Item)root).Location, map); } p = Packet.Acquire(new DragEffect(src, m, item.ItemID, item.Hue, amount)); } ns.Send(p); } } Packet.Release(p); } var liftSound = item.GetLiftSound(m); if (liftSound != -1) { m.Send(GenericPackets.PlaySound(liftSound, m)); } }
private static void Mobile_ItemDropped(Mobile m, ItemDroppedEventArgs args) { var item = args.Item; var bounced = args.Bounced; if (bounced) { return; } var map = m.Map; var root = item.RootParent; if (map != null && (root == null || root is Item)) { Packet p = null; foreach (var ns in map.GetClientsInRange(m.Location)) { if (ns.Mobile != m && ns.Mobile.CanSee(m)) { if (p == null) { IEntity trg; if (root == null) { trg = new DummyEntity(Serial.Zero, item.Location, map); } else { trg = new DummyEntity(((Item)root).Serial, ((Item)root).Location, map); } p = Packet.Acquire(new DragEffect(m, trg, item.ItemID, item.Hue, item.Amount)); } ns.Send(p); } } Packet.Release(p); } }
private static void Mobile_Damaged(Mobile m, DamagedEventArgs args) { int amount = args.Amount; Mobile from = args.From; GameClient ourState = m.Client, theirState = (from == null ? null : from.Client); if (ourState == null) { Mobile master = m.GetDamageMaster(from); if (master != null) { ourState = master.Client; } } if (theirState == null && from != null) { Mobile master = from.GetDamageMaster(m); if (master != null) { theirState = master.Client; } } if (amount > 0 && (ourState != null || theirState != null)) { Packet p = Packet.Acquire(new DamagePacket(m, amount)); if (ourState != null) { ourState.Send(p); } if (theirState != null && theirState != ourState) { theirState.Send(p); } Packet.Release(p); } }
private static void Mobile_Damaged(Mobile m, DamagedEventArgs args) { var amount = args.Amount; var from = args.From; NetState ourState = m.NetState, theirState = from?.NetState; if (ourState == null) { var master = m.GetDamageMaster(from); if (master != null) { ourState = master.NetState; } } if (theirState == null && from != null) { var master = from.GetDamageMaster(m); if (master != null) { theirState = master.NetState; } } if (amount > 0 && (ourState != null || theirState != null)) { var p = Packet.Acquire(new DamagePacket(m, amount)); if (ourState != null) { ourState.Send(p); } if (theirState != null && theirState != ourState) { theirState.Send(p); } Packet.Release(p); } }
private static void Mobile_Dead(Mobile m, DeadEventArgs args) { var c = args.Corpse; var map = m.Map; if (map != null) { Packet animPacket = null; Packet remPacket = null; foreach (var state in map.GetClientsInRange(m.Location)) { if (state != m.NetState) { if (animPacket == null) { animPacket = Packet.Acquire(new DeathAnimation(m, c)); } state.Send(animPacket); if (!state.Mobile.CanSee(m)) { if (remPacket == null) { remPacket = m.RemovePacket; } state.Send(remPacket); } } } Packet.Release(animPacket); } }
public static void Release( ref Packet p ) { if ( p != null ) p.Release(); p = null; }
public void SendToAll( Packet p ) { p.Acquire(); for ( int i = 0; i < m_Members.Count; ++i ) m_Members[i].Mobile.Send( p ); if ( p is MessageLocalized || p is MessageLocalizedAffix || p is UnicodeMessage || p is AsciiMessage ) { for ( int i = 0; i < m_Listeners.Count; ++i ) { Mobile mob = m_Listeners[i]; if ( mob.Party != this ) mob.Send( p ); } } p.Release(); }
public static void SendPacket( IPoint3D origin, IMap map, Packet p ) { if ( map != null ) { p.Acquire(); foreach ( GameClient state in map.GetClientsInRange( origin ) ) { state.Mobile.ProcessDelta(); state.Send( p ); } if ( p != null ) p.Release(); } }
public static void Release( Packet p ) { if ( p != null ) p.Release(); }
public static void Release(Packet p) { p?.Release(); }
public static void SendPacket( IPoint3D origin, Map map, Packet p ) { if ( map != null ) { IPooledEnumerable eable = map.GetClientsInRange( new Point3D( origin ) ); p.Acquire(); foreach ( NetState state in eable ) { state.Mobile.ProcessDelta(); state.Send( p ); } p.Release(); eable.Free(); } }
public static void Release(ref Packet p) { p?.Release(); p = null; }