protected override OptionResult Run(GameHitParameters <GameObject> parameters) { if (parameters.mTarget != null) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(parameters.mTarget.ObjectId); string sCost = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":PromptCost"), settings.mDoorCost.ToString()); if (string.IsNullOrEmpty(sCost)) { return(OptionResult.Failure); } int cost = 0; if (!int.TryParse(sCost, out cost)) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error")); return(OptionResult.Failure); } if (cost < 0 || cost > int.MaxValue) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:InvalidInput")); return(OptionResult.Failure); } settings.mDoorCost = cost; GoHere.Settings.AddOrUpdateDoorSettings(parameters.mTarget.ObjectId, settings, false); Common.Notify(Common.Localize("Generic:Success")); return(OptionResult.SuccessClose); } return(OptionResult.Failure); }
public void ClearActiveDoorFilters(ObjectGuid guid) { DoorPortalComponentEx.DoorSettings settings = GetDoorSettings(guid); if (settings != null) { settings.ClearFilters(); AddOrUpdateDoorSettings(guid, settings, false); } }
public static bool ExternalAllowPush(SimDescription sim, Lot lot) { if (lot != null) { bool allowed = false; if (!lot.IsResidentialLot) { List <Door> portals = lot.GetObjectsInRoom <Door>(0); foreach (Door obj in portals) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(obj.ObjectId, false); if (settings != null && settings.IsSimAllowedThrough(sim.SimDescriptionId)) { allowed = true; break; } } } else { Door door = lot.FindFrontDoor(); if (door != null) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(door.ObjectId, false); if (settings != null) { allowed = settings.IsSimAllowedThrough(sim.SimDescriptionId); } } else { allowed = true; } } if (!allowed) { return(allowed); } } if (!sStoryProgressionAllowPushToLot.Valid) { return(true); } return(sStoryProgressionAllowPushToLot.Invoke <bool>(new object[] { sim, lot })); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { if (parameters.mTarget != null) { DoorPortalComponentEx.DoorSettings settings = GoHere.Settings.GetDoorSettings(parameters.mTarget.ObjectId); string open = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":PromptOpen"), settings.mDoorOpen.ToString()); if (string.IsNullOrEmpty(open)) { return(OptionResult.Failure); } string close = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":PromptClose"), settings.mDoorClose.ToString()); if (string.IsNullOrEmpty(close)) { return(OptionResult.Failure); } int openTime = -1; int closeTime = -1; if (!int.TryParse(open, out openTime) || !int.TryParse(close, out closeTime)) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error")); return(OptionResult.Failure); } if ((openTime < 1 || openTime > 23) || (closeTime < 1 || closeTime > 23)) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:InvalidInput")); return(OptionResult.Failure); } settings.mDoorOpen = openTime; settings.mDoorClose = closeTime; GoHere.Settings.AddOrUpdateDoorSettings(parameters.mTarget.ObjectId, settings, false); Common.Notify(Common.Localize("Generic:Success")); return(OptionResult.SuccessClose); } return(OptionResult.Failure); }
public void AddOrUpdateDoorSettings(ObjectGuid door, DoorPortalComponentEx.DoorSettings settings, bool doSimValidation) { if (mDoorSettings.ContainsKey(door)) { mDoorSettings[door] = settings; } else { mDoorSettings.Add(door, settings); } if (doSimValidation) { Door door2 = GameObject.GetObject(door) as Door; if (door2 != null && door2.LotCurrent != null) { foreach (Sim sim in door2.LotCurrent.mSims) { //door2.GetAdjoiningRoom(door2.RoomId) if (sim != null && sim.SimDescription != null && sim.RoomId == door2.RoomId && !LotManager.RoomIdIsOutside(sim.RoomId)) { if (!settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId)) { StyledNotification.Format format = new StyledNotification.Format(Common.Localize("DoorFilter:WarningTrappedSims"), door2.ObjectId, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage); format.mTNSCategory = NotificationManager.TNSCategory.Lessons; StyledNotification.Show(format); } } } foreach (Sim sim in LotManager.Actors) { if (sim == null || sim.mAllowedRooms == null) { continue; } sim.mAllowedRooms.Remove(door2.LotCurrent.LotId); } } } }