/// <summary> /// Commit any outstanding changes /// </summary> /// <param name="sender"></param> void ICommitGumpEntity.CommitChanges() { if (m_State.IsValueDirty <int>("VotedFor")) { string playerName = GetBeneficiaryNames()[m_State.GetValue <int>("VotedFor")]; KinCityData.BeneficiaryData bd = m_Gump.Data.GetBeneficiary(playerName); if (bd != null) { m_Gump.Data.CastVote(bd.Pm, m_Gump.From as PlayerMobile); } } }
/// <summary> /// Commit any outstanding changes /// </summary> /// <param name="sender"></param> void ICommitGumpEntity.CommitChanges() { if (m_State.IsValueDirty <double>("Tax")) { m_Gump.Data.TaxRate = m_State.GetValue <double>("Tax"); m_Gump.From.SendMessage("You have successfully adjusted the tax rate"); } if (m_State.IsValueDirty <bool>("Distribute")) { if (m_Gump.Data.Treasury > 0) { m_Gump.Data.DistributeTreasury(); m_Gump.From.SendMessage("You have successfully distributed the treasury amongst the beneficiaries"); } else { m_Gump.From.SendMessage("There is no gold in the treasury to distribute."); } } }
/// <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(); } }