コード例 #1
0
        private void OnFirebombTimerTick()
        {
            if (Deleted)
            {
                m_Timer.Stop();
                return;
            }

            if (Map == Map.Internal && HeldBy == null)
            {
                return;
            }

            switch (m_Ticks)
            {
            case 0:
            case 1:
            case 2:
            {
                ++m_Ticks;

                if (HeldBy != null)
                {
                    HeldBy.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent == null)
                {
                    PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }
                else if (RootParent is Mobile mobile)
                {
                    mobile.PublicOverheadMessage(MessageType.Regular, 957, false, m_Ticks.ToString());
                }

                break;
            }

            default:
            {
                HeldBy?.DropHolding();

                if (m_Users != null)
                {
                    foreach (Mobile m in m_Users)
                    {
                        if (m.Target is ThrowTarget targ && targ.Bomb == this)
                        {
                            Target.Cancel(m);
                        }
                    }

                    m_Users.Clear();
                    m_Users = null;
                }

                if (RootParent is Mobile parent)
                {
                    parent.SendLocalizedMessage(1060583); // The firebomb explodes in your hand!
                    AOS.Damage(parent, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                }
                else if (RootParent == null)
                {
                    IPooledEnumerable <Mobile> eable = Map.GetMobilesInRange(Location, 1);
                    List <Mobile> toDamage           = eable.ToList();

                    eable.Free();

                    for (int i = 0; i < toDamage.Count; ++i)
                    {
                        Mobile victim = toDamage[i];

                        if (m_LitBy == null || (SpellHelper.ValidIndirectTarget(m_LitBy, victim) &&
                                                m_LitBy.CanBeHarmful(victim, false)))
                        {
                            m_LitBy?.DoHarmful(victim);

                            AOS.Damage(victim, m_LitBy, Utility.Random(3) + 4, 0, 100, 0, 0, 0);
                        }
                    }

                    new FirebombField(m_LitBy, toDamage).MoveToWorld(Location, Map);
                }

                m_Timer.Stop();
                Delete();
                break;
            }
            }
        }