public override void OnLaneLocked(Sim sim, LaneInfo info)
        {
            DoorSettings settings = GoHere.Settings.GetDoorSettings(this.OwnerDoor.ObjectId);
            bool         allowed  = true;

            if (settings != null)
            {
                if (settings.mIsOneWayDoor && (info.mLaneSlots[0] != Door.RoutingSlots.Door1_Rear && info.mLaneSlots[0] != Door.RoutingSlots.Door0_Rear))
                {
                    allowed = false;
                }

                allowed = allowed && settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId);
            }

            if (!allowed)
            {
                if (sim.SimRoutingComponent != null && sim.SimRoutingComponent.IsRouting)
                {
                    sim.SimRoutingComponent.GetCurrentRoute().DoRouteFail = false;
                }
                return;
            }

            if ((info.mLaneSlots[0] == Door.RoutingSlots.Door0_Rear || info.mLaneSlots[0] == Door.RoutingSlots.Door1_Rear) && settings.mDoorCost > 0 && !settings.WasSimRecentlyLetThrough(sim.SimDescription.SimDescriptionId))
            {
                settings.AddRecentSim(sim.SimDescription.SimDescriptionId);
                GoHere.Settings.AddOrUpdateDoorSettings(this.OwnerDoor.ObjectId, settings, false);

                settings.HandleCost(sim);
            }

            base.OnLaneLocked(sim, info);
        }
Beispiel #2
0
        // this is just an extra safety measure
        public override bool OnApproachingPortalObject(Sim sim)
        {
            DoorSettings settings = GoHere.Settings.GetDoorSettings(this.OwnerDoor.ObjectId);
            bool         allowed  = true;

            if (settings != null)
            {
                allowed = settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId);
            }

            return(!allowed ? allowed : base.OnApproachingPortalObject(sim));
        }
Beispiel #3
0
        public static string SceneWindow_Hover(IScriptProxy o, ScenePickArgs args)
        {
            DoorSettings settings = GoHere.Settings.GetDoorSettings(o.ObjectId, false);

            if (settings == null)
            {
                return(string.Empty);
            }

            string tooltip = string.Empty;

            if (settings.ActiveFilters.Count > 0)
            {
                string critera = FilterHelper.GetFilterAsLocalizedCriteria(settings.ActiveFilters);
                if (critera.Length > 3)
                {
                    tooltip = GoHere.Localize("DoorCriteria:ToolTip") + " (" + GoHere.Localize("DoorFilterType:" + settings.mType.ToString()) + ")" + Common.NewLine + critera;
                }
            }

            if (settings.mDoorOpen > -1 && settings.mDoorClose > -1)
            {
                if (tooltip != string.Empty)
                {
                    tooltip = tooltip + Common.NewLine;
                }

                tooltip = tooltip + GoHere.Localize("OpenCloseTime:MenuName") + ": " + settings.mDoorOpen.ToString() + " - " + settings.mDoorClose.ToString();
            }

            if (settings.mDoorCost > 0)
            {
                if (tooltip != string.Empty)
                {
                    tooltip = tooltip + Common.NewLine;
                }

                tooltip = tooltip + GoHere.Localize("DoorCost:MenuName") + ": " + settings.mDoorCost.ToString();
            }

            if (settings.mIsOneWayDoor)
            {
                if (tooltip != string.Empty)
                {
                    tooltip = tooltip + Common.NewLine;
                }

                tooltip = tooltip + GoHere.Localize("OneWayDoor:MenuName");
            }

            return(tooltip);
        }
            public static void ValidateAndSetupDoors()
            {
                List <ulong> removeSim = new List <ulong>();

                foreach (ObjectGuid guid in new List <ObjectGuid>(GoHere.Settings.mDoorSettings.Keys))
                {
                    DoorSettings settings = GoHere.Settings.mDoorSettings[guid];

                    if (Simulator.GetProxy(guid) != null && settings.SettingsValid)
                    {
                        foreach (KeyValuePair <ulong, long> sims in settings.mSimsRecentlyLetThrough)
                        {
                            if (!settings.WasSimRecentlyLetThrough(sims.Key))
                            {
                                removeSim.Add(sims.Key);
                            }
                            else if (MiniSimDescription.Find(sims.Key) == null)
                            {
                                removeSim.Add(sims.Key);
                            }
                        }

                        foreach (ulong sim in removeSim)
                        {
                            settings.mSimsRecentlyLetThrough.Remove(sim);
                        }

                        GoHere.Settings.AddOrUpdateDoorSettings(guid, settings, false);

                        Door door = GameObject.GetObject(guid) as Door;

                        if (door != null)
                        {
                            RegisterRoomListeners(door.LotCurrent);
                        }

                        continue;
                    }

                    GoHere.Settings.mDoorSettings.Remove(guid);
                }

                TooltipHelper.AddListener(typeof(Door), Type.GetType("NRaas.GoHereSpace.Helpers.DoorPortalComponentEx,NRaasGoHere").GetMethod("SceneWindow_Hover"));
            }
Beispiel #5
0
            public static void ValidateAndSetupDoors()
            {
                List <ulong> removeSim = new List <ulong>();

                foreach (ObjectGuid guid in new List <ObjectGuid>(GoHere.Settings.mDoorSettings.Keys))
                {
                    DoorSettings settings = GoHere.Settings.mDoorSettings[guid];

                    if (Simulator.GetProxy(guid) != null && settings.SettingsValid)
                    {
                        foreach (KeyValuePair <ulong, long> sims in settings.mSimsRecentlyLetThrough)
                        {
                            if (!settings.WasSimRecentlyLetThrough(sims.Key))
                            {
                                removeSim.Add(sims.Key);
                            }
                            else if (MiniSimDescription.Find(sims.Key) == null)
                            {
                                removeSim.Add(sims.Key);
                            }
                        }

                        foreach (ulong sim in removeSim)
                        {
                            settings.mSimsRecentlyLetThrough.Remove(sim);
                        }

                        GoHere.Settings.AddOrUpdateDoorSettings(guid, settings, false);

                        Door door = GameObject.GetObject(guid) as Door;

                        if (door != null)
                        {
                            RegisterRoomListeners(door.LotCurrent);
                        }

                        continue;
                    }

                    GoHere.Settings.mDoorSettings.Remove(guid);
                }
            }
        public override bool OnApproachingPortalObject(Sim sim)
        {
            DoorSettings settings = GoHere.Settings.GetDoorSettings(this.OwnerDoor.ObjectId, false);
            bool         allowed  = true;

            if (settings != null)
            {
                allowed = settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId);

                if (settings.mIsOneWayDoor)
                {
                    CommonDoor.tSide sideInRoom = CommonDoor.tSide.Front;
                    this.OwnerDoor.GetSideOfDoorInRoom(sim.RoomId, out sideInRoom);
                    if (sideInRoom != CommonDoor.tSide.Back)
                    {
                        return(false);
                    }
                }
            }

            return(!allowed ? allowed : base.OnApproachingPortalObject(sim));
        }
Beispiel #7
0
            public static bool TestPortalObject(Sim sim, int dest, CommonDoor obj)
            {
                if (obj == null || sim == null)
                {
                    return(true);
                }

                CommonDoor.tSide sideInRoom = CommonDoor.tSide.Front;
                obj.GetSideOfDoorInRoom(dest, out sideInRoom);

                DoorSettings settings = GoHere.Settings.GetDoorSettings(obj.ObjectId, false);

                if (settings != null)
                {
                    if (settings.mIsOneWayDoor && sideInRoom != CommonDoor.tSide.Front)
                    {
                        return(false);
                    }

                    return(settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId));
                }

                return(true);
            }
Beispiel #8
0
            public static bool OnAllowedInRoomCheck(int srcRoom, Sim sim)
            {
                if (sim != null && sim.LotCurrent != null)
                {
                    bool allowed = false;
                    foreach (RoomConnectionObject obj in sim.LotCurrent.GetObjectsInRoom <RoomConnectionObject>(srcRoom))
                    {
                        DoorSettings settings = GoHere.Settings.GetDoorSettings(obj.ObjectId);
                        if (settings != null)
                        {
                            allowed = settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId);
                            if (allowed)
                            {
                                break;
                            }
                        }
                    }

                    //Common.Notify(sim.FullName + " allowed: " + allowed.ToString() + " to room " + srcRoom);

                    return(allowed);
                }
                return(true);
            }
            public static bool OnAllowedInRoomCheck(int srcRoom, Sim sim)
            {
                if (sim != null && sim.LotCurrent != null)
                {
                    if (sim.RoomId == srcRoom)
                    {
                        return(true);
                    }

                    bool allowed          = false;
                    bool adjoiningAllowed = false;
                    bool allNull          = true;
                    foreach (CommonDoor obj in sim.LotCurrent.GetObjectsInRoom <CommonDoor>(srcRoom))
                    {
                        if (sim.SimDescription.Gender == Sims3.SimIFace.CAS.CASAgeGenderFlags.Male)
                        {
                            //Common.Notify("Testing " + obj.CatalogName + " in " + srcRoom);
                        }

                        CommonDoor.tSide sideInRoom = CommonDoor.tSide.Front;
                        obj.GetSideOfDoorInRoom(srcRoom, out sideInRoom);

                        DoorSettings settings = GoHere.Settings.GetDoorSettings(obj.ObjectId, false);

                        if (settings != null && settings.mIsOneWayDoor)
                        {
                            // if it's a one way door, you can only pass through the front so a back isn't in room anywhere, you're not allowed in
                            if (sideInRoom != CommonDoor.tSide.Front)
                            {
                                allNull = false;
                                continue;
                            }
                        }

                        // if front of door isn't in room, we don't care about it's filters
                        if (sideInRoom != CommonDoor.tSide.Front)
                        {
                            //Common.Notify("Skipping " + obj.CatalogName + " because front tile is in other room");
                            continue;
                        }

                        if (settings != null)
                        {
                            allNull = false;
                            allowed = settings.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId);
                            if (allowed)
                            {
                                if (sim.SimDescription.Gender == Sims3.SimIFace.CAS.CASAgeGenderFlags.Male)
                                {
                                    //Common.Notify(sim.FullName + " initially allowed in " + srcRoom);
                                }
                            }
                            else
                            {
                                if (sim.SimDescription.Gender == Sims3.SimIFace.CAS.CASAgeGenderFlags.Male)
                                {
                                    //Common.Notify(sim.FullName + " NOT initially allowed in " + srcRoom);
                                }
                            }
                        }

                        if (allowed && !adjoiningAllowed)
                        {
                            //Common.Notify("Testing adjoining");
                            // eh...
                            int adjoining = obj.GetAdjoiningRoom(srcRoom);
                            //Common.Notify("Testing adjoining... adjoining to " + srcRoom + " is " + adjoining);
                            foreach (CommonDoor obj2 in obj.LotCurrent.GetObjectsInRoom <CommonDoor>(adjoining))
                            {
                                if (sim.SimDescription.Gender == Sims3.SimIFace.CAS.CASAgeGenderFlags.Male)
                                {
                                    //Common.Notify("Testing adjoining " + obj2.CatalogName + " in " + adjoining);
                                }

                                sideInRoom = CommonDoor.tSide.Front;
                                obj2.GetSideOfDoorInRoom(adjoining, out sideInRoom);
                                if (sideInRoom != CommonDoor.tSide.Front)
                                {
                                    //Common.Notify("Skipping " + obj2.CatalogName + " because front tile is in other room");
                                    continue;
                                }

                                DoorSettings settings2 = GoHere.Settings.GetDoorSettings(obj.ObjectId, false);
                                if (settings != null)
                                {
                                    allNull          = false;
                                    adjoiningAllowed = settings2.IsSimAllowedThrough(sim.SimDescription.SimDescriptionId);
                                    if (adjoiningAllowed)
                                    {
                                        if (sim.SimDescription.Gender == Sims3.SimIFace.CAS.CASAgeGenderFlags.Male)
                                        {
                                            //Common.Notify(sim.FullName + " allowed in adjoining " + adjoining);
                                        }
                                        break;
                                    }
                                }
                            }
                        }

                        if (allowed && adjoiningAllowed)
                        {
                            break;
                        }
                    }

                    if (allNull)
                    {
                        allowed = true;
                    }

                    if (sim.SimDescription.Gender == Sims3.SimIFace.CAS.CASAgeGenderFlags.Male)
                    {
                        //Common.Notify(sim.FullName + " is in " + sim.RoomId + " allowed: " + allowed.ToString() + " to room " + srcRoom);
                    }

                    return(allowed);
                }
                return(true);
            }
Beispiel #10
0
        public static void AboutToPlanRouteCallback(Route r, string routeType, Vector3 point)
        {
            if (r == null || r.Follower == null)
            {
                return;
            }

            Sim router = r.Follower.Target as Sim;

            if (router == null)
            {
                return;
            }

            Lot lot = router.LotCurrent;

            if (lot == null)
            {
                return;
            }

            InteractionInstance instance = router.CurrentInteraction;

            int destRoom = -1;

            if (instance != null && instance.Target != null)
            {
                destRoom = instance.Target.RoomId;
            }

            if (destRoom == -1)
            {
                return;
            }

            if (instance.Autonomous)
            {
                return;
            }

            //Common.Notify(router.FullName + " trying to route to " + destRoom);

            /*
             * int depth = 5;
             * int currentRoom = 0;
             * while (depth < 5)
             * {
             *  if (currentRoom == 0) currentRoom = destRoom;
             *  bool allow = false;
             *  foreach (CommonDoor door in lot.GetObjectsInRoom<CommonDoor>(currentRoom))
             * {
             *  if (door != null)
             *  {
             *          CommonDoor.tSide side;
             *          door.GetSideOfDoorInRoom(currentRoom, out side);
             *          if (side != CommonDoor.tSide.Front) continue;
             *
             *      DoorSettings settings = GoHere.Settings.GetDoorSettings(door.ObjectId, false);
             *      if (settings != null)
             *      {
             *              if (!DoorSettings.TestPortalObject(router, currentRoom, door))
             *              {
             *                 // r.AddObjectToForbiddenPortalList(door.ObjectId);
             *                  //r.DoRouteFail = false;
             *                  continue;
             *              }
             *          }
             *
             *          allow = true;
             *          break;
             *      }
             *  }
             *
             *  if (!allow) router.AddExitReason(ExitReason.CancelExternal);
             *  depth++;
             * }
             */

            //bool allow = false;
            foreach (CommonDoor door in lot.GetObjects <CommonDoor>()) // lot.GetObjectsInRoom<CommonDoor>(destRoom)
            {
                if (door != null)
                {
                    DoorSettings settings = GoHere.Settings.GetDoorSettings(door.ObjectId, false);
                    if (settings != null)
                    {
                        if (!DoorSettings.TestPortalObject(router, door.RoomId, door))
                        {
                            if (r == null)
                            {
                                return;
                            }

                            r.AddObjectToForbiddenPortalList(door.ObjectId);
                            r.DoRouteFail = false; // this seems to be ignored...

                            // for minor zerbu compatability, stops route fail

                            /*
                             * if (destRoom == door.RoomId)
                             * {
                             *  Common.Notify(router.FullName + ": denied");
                             *  router.AddExitReason(ExitReason.CancelExternal);
                             *  router.InteractionQueue.CancelAllInteractions();
                             * }
                             */
                            //router.AddExitReason(ExitReason.CancelExternal);
                            continue;
                        }
                    }

                    //allow = true;
                    //break;
                }
            }

            //if (allow) { }

            /*
             *
             * if (instance != null && Sims3.SimIFace.Route.IsRouteToObjectUnobstructed(router.ObjectId, instance.Target.Position, router.GetRouteOptions(), instance.Target.ObjectId, router.SimDescription.AgeGenderSpecies) != BlockedStatus.Unobstructed)
             * {
             *  //Common.Notify("Route obstructructed: " + router.SimDescription.FullName + " going to " + instance.Target.GetLocalizedName() + " in " + destRoom);
             *  router.AddExitReason(ExitReason.CanceledByScript);
             *  if (!router.IsInActiveHousehold)
             *  {
             *      router.InteractionQueue.CancelAllInteractions();
             * }
             * }
             */
        }