Ejemplo n.º 1
0
        /// <summary>
        /// Called when [delete].
        /// </summary>
        public override void OnDelete()
        {
            //Give guard post slots back
            KinCityData data = KinCityManager.GetCityData(m_City);

            if (data == null)
            {
                base.OnDelete();
                return;
            }
            KinCityData.BeneficiaryData bd = data.GetBeneficiary(m_Owner);
            if (bd == null)
            {
                base.OnDelete();
                return;
            }
            bd.UnRegisterGuardPost(this);
            base.OnDelete();
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Commit any outstanding changes
            /// </summary>
            /// <param name="sender"></param>
            void ICommitGumpEntity.CommitChanges()
            {
                if (!((ICommitGumpEntity)this).Validate())
                {
                    m_Gump.From.SendMessage("The guard post has been changed since you were modifying it. Please make the changes again.");
                    return;
                }
                if (m_State.IsValueDirty <KinFactionGuardTypes>("Type"))
                {
                    //set guard type

                    //TODO: - check some delay?
                    GuardPost.GuardType = (KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type");
                    m_Gump.From.SendMessage("Guard type changed to {0}.", KinSystem.GetEnumTypeDescription <KinFactionGuardTypes>((KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type")));
                }
                if (m_State.IsValueDirty <KinGuardPost.HireSpeeds>("Speed"))
                {
                    GuardPost.HireSpeed = (KinGuardPost.HireSpeeds)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed");
                    m_Gump.From.SendMessage("Hire rate successfully changed to {0}", KinSystem.GetEnumTypeDescription <KinGuardPost.HireSpeeds>((KinGuardPost.HireSpeeds)m_State.GetValue <KinGuardPost.HireSpeeds>("Speed")));
                    GuardPost.RefreshNextSpawnTime();
                }
                if (m_State.IsValueDirty <int>("Slots"))
                {
                    KinFactionGuardTypes currentType = (KinFactionGuardTypes)m_State.GetOriginalValue <KinFactionGuardTypes>("Type");
                    KinFactionGuardTypes type        = (KinFactionGuardTypes)m_State.GetValue <KinFactionGuardTypes>("Type");
                    int cost        = KinSystem.GetGuardCostType(type);
                    int currentCost = KinSystem.GetGuardCostType(currentType);
                    int slots       = 0;
                    slots += (currentCost - cost);
                    KinCityData data = KinCityManager.GetCityData(GuardPost.City);
                    if (data == null)
                    {
                        return;
                    }
                    KinCityData.BeneficiaryData bd = data.GetBeneficiary(GuardPost.Owner);
                    if (bd == null)
                    {
                        return;
                    }
                    bd.ModifyGuardSlots(slots);
                    m_Gump.From.SendMessage("Unassigned guard slots modified by {0}.", slots);
                }

                /*
                 * if (m_State.StyleChanged)
                 * {
                 *      //Assign new style
                 *      GuardPost.FightStyle = m_State.Style;
                 * }
                 */
                if (m_State.IsValueDirty <FightMode>("Target"))
                {
                    //Dont overwrite this one
                    // 0 the strongest, weakest, closest
                    //NAND out the options so these bits are all 0
                    GuardPost.FightMode &= ~FightMode.Strongest;
                    GuardPost.FightMode &= ~FightMode.Weakest;
                    GuardPost.FightMode &= ~FightMode.Closest;
                    //write new version
                    GuardPost.FightMode |= (FightMode)m_State.GetValue <FightMode>("Target");
                    m_Gump.From.SendMessage("Guard target priority successfully changed.");
                    GuardPost.UpdateExisitngGuards();
                }
            }