public void OnWorldLoadFinished() { sLoading = false; sChecked.Clear(); ObjectLookup.StartListener(); foreach (ObjectGuid guid in new List <ObjectGuid>(sAllRunning.Keys)) { IScriptProxy proxy = Simulator.GetProxy(guid); if (proxy != null && proxy.Target != null) { OneShotFunction oneShot = proxy.Target as OneShotFunction; if (oneShot != null && oneShot.mFunction != null) { IGameObject obj = oneShot.mFunction.Target as IGameObject; if (obj != null && obj.HasBeenDestroyed) { Simulator.DestroyObject(guid); LogCorrection("Removed Orphan OneShotFunction"); LogCorrection(" " + oneShot.mFunction.Method.DeclaringType.ToString()); LogCorrection(" " + oneShot.mFunction.Target.GetType()); continue; } } } } new Common.AlarmTask(1, TimeUnit.Minutes, OnDelayedWorldLoadFinished); }
private bool CustomProcessClick(ScenePickArgs eventArgs) { switch (eventArgs.mObjectType) { case ScenePickObjectType.Terrain: case ScenePickObjectType.Floor: case ScenePickObjectType.RoadStreet: case ScenePickObjectType.RoadSidewalk: case ScenePickObjectType.WaterPond: case ScenePickObjectType.WaterSea: case ScenePickObjectType.WaterPool: case ScenePickObjectType.WaterFountain: if ((Bin.PlacementHousehold == null) && (Bin.PlacementLot == null)) { return(GameObjectEx.OnPick(Terrain.Singleton, eventArgs.mMouseEvent, eventArgs.AsGameObjectHit())); } break; case ScenePickObjectType.Object: case ScenePickObjectType.Sim: case ScenePickObjectType.Wall: ObjectGuid guid = ObjectGuid.InvalidObjectGuid; if ((eventArgs.mObjectType == ScenePickObjectType.Object) || (eventArgs.mObjectType == ScenePickObjectType.Sim)) { guid = new ObjectGuid(eventArgs.mObjectId); } else if (eventArgs.mObjectType == ScenePickObjectType.Wall) { guid = LotManager.GetLotObjectGuid(eventArgs.mObjectId); } IScriptProxy proxy = Simulator.GetProxy(guid); if (proxy != null) { IObjectUI target = proxy.Target as IObjectUI; if (target != null) { Lot lot = target as Lot; if (lot != null) { return(OnPickLot(lot, eventArgs.mMouseEvent, eventArgs.AsGameObjectHit())); } else { GameObject obj = target as GameObject; if (obj != null) { return(GameObjectEx.OnPick(obj, eventArgs.mMouseEvent, eventArgs.AsGameObjectHit())); } } } } break; } return(false); }
public void RegisterScriptProxy(IScriptProxy scriptProxy) { if (scriptProxy == null) { throw new ArgumentNullException(nameof(scriptProxy)); } _script.Globals[scriptProxy.Name] = UserData.Create(scriptProxy); Proxies.Add(scriptProxy); }
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 override void ProcessClick(ScenePickArgs eventArgs) { try { if (((eventArgs.mObjectType != ScenePickObjectType.None) && !WasMouseDragged(eventArgs)) && ((eventArgs.mMouseEvent.MouseKey != MouseKeys.kMouseRight) || ((eventArgs.mMouseEvent.Modifiers & Modifiers.kModifierMaskControl) == Modifiers.kModifierMaskNone))) { bool flag = false; if ((eventArgs.mObjectType == ScenePickObjectType.Object) || (eventArgs.mObjectType == ScenePickObjectType.Sim)) { ObjectGuid objectId = new ObjectGuid(eventArgs.mObjectId); IScriptProxy proxy = Simulator.GetProxy(objectId); if (proxy != null) { IObjectUI target = proxy.Target as IObjectUI; if (target != null) { Vehicle vehicle = target as Vehicle; if (vehicle != null) { flag = OnSelect(vehicle, eventArgs.mMouseEvent); } else if (target is Sim) { flag = OnSelect(target as Sim, eventArgs.mMouseEvent); } else { flag = target.OnSelect(eventArgs.mMouseEvent); } } } } if (!flag) { CameraController.RequestLerpToTarget(eventArgs.mDisplayPos, 1.5f, false); } } } catch (Exception e) { Common.Exception("ProcessClick", e); } }
protected override void PreProcess(FollowRouteAction obj, object parent, FieldInfo field) { IScriptProxy proxy = Simulator.GetProxy(obj.mRoutingObjectId); if (proxy == null) { return; } Sim sim = proxy.Target as Sim; if (sim == null) { return; } SimRoutingComponent component = sim.RoutingComponent as SimRoutingComponent; if (component == null) { return; } if (component.mRouteActions.Contains(obj)) { return; } if (sSims == null) { sSims = new Dictionary <Sim, InteractionInstance>(); } if (!sSims.ContainsKey(sim)) { sSims.Add(sim, sim.CurrentInteraction); ErrorTrap.DebugLogCorrection("Potential Follow Route Action Reset: " + sim.FullName); } }
protected static string GetTaskName(ITask task) { string name = null; IScriptProxy proxy = task as IScriptProxy; if (proxy != null) { IScriptLogic logic = proxy.Target; if (logic != null) { if (logic is Sim) { name = "Sim: " + (logic as Sim).FullName; } else if (logic is SimUpdate) { name = "SimUpdate: " + (logic as SimUpdate).mSim.FullName; } } } string type = task.GetType().ToString(); if (string.IsNullOrEmpty(name)) { name = task.ToString(); } if ((!string.IsNullOrEmpty(name)) && (name != type)) { type += " (" + name + ")"; } return(type); }
protected override void Perform(GameObject obj, object referenceParent, FieldInfo field) { if (obj is Ocean) { if (LotManager.sOceanObject == obj) { return; } } else if (obj is Terrain) { if (Terrain.sTerrain == obj) { return; } } if (DereferenceManager.HasBeenDestroyed(obj)) { if (obj is Sim) { LotManager.sActorList.Remove(obj as Sim); DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), true, false); } else { GameObjectReference refObj = ObjectLookup.GetReference(new ReferenceWrapper(obj)); if (DereferenceManager.Perform(obj, refObj, false, false)) { DereferenceManager.Perform(obj, refObj, true, false); ErrorTrap.LogCorrection("Destroyed Object Found: " + obj.GetType()); } } return; } if (kShowFullReferencing) { DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), false, true); } if (obj.InWorld) { return; } if (obj.InInventory) { if (Inventories.ParentInventory(obj) == null) { if ((obj.Parent != null) || (Consignment.ContainsKey(obj))) { obj.SetFlags(GameObject.FlagField.InInventory, false); ErrorTrap.LogCorrection("Invalid Inventory Object Unflagged: " + obj.GetType()); } else { ErrorTrap.LogCorrection("Invalid Inventory Object Found: " + obj.GetType()); ErrorTrap.AddToBeDeleted(obj, true); } } return; } else { if (SharedInventories.ContainsKey(obj.ObjectId)) { obj.SetFlags(GameObject.FlagField.InInventory, true); ErrorTrap.LogCorrection("Inventory Object Flagged: " + obj.GetType()); return; } } if (EventItems.ContainsKey(obj.ObjectId)) { return; } bool hasParent = false; IGameObject parent = obj.Parent; while (parent != null) { hasParent = true; if (DereferenceManager.HasBeenDestroyed(parent)) { ErrorTrap.LogCorrection("Destroyed Parent Object Found: " + parent.GetType()); ErrorTrap.AddToBeDeleted(obj, true); hasParent = false; break; } parent = parent.Parent; } if (!hasParent) { ReferenceWrapper refObj = new ReferenceWrapper(obj); GameObjectReference reference = ObjectLookup.GetReference(refObj); if ((reference != null) && (reference.HasReferences)) { if (DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), false, false)) { IScriptProxy proxy = Simulator.GetProxy(obj.ObjectId); if (proxy != null) { IScriptLogic logic = proxy.Target; if (object.ReferenceEquals(logic, obj)) { bool log = !sSilentDestroy.ContainsKey(obj.GetType()); if (log) { ErrorTrap.LogCorrection("Out of World Object Found 2: " + obj.GetType()); } else { ErrorTrap.DebugLogCorrection("Out of World Object Found 3: " + obj.GetType()); } ErrorTrap.AddToBeDeleted(obj, log); } else { ErrorTrap.DebugLogCorrection("Out of World Object Found 4: " + obj.GetType()); ErrorTrap.DebugLogCorrection("Out of World Object Found 5: " + logic.GetType()); } } else { DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), true, false); } } } else { ErrorTrap.LogCorrection("Out of World Object Found 1: " + obj.GetType()); ErrorTrap.AddToBeDeleted(obj, true); } } }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("RepairImaginaryFriends"); Trait trait; if (TraitManager.sDictionary.TryGetValue((ulong)TraitNames.ImaginaryFriendHiddenTrait, out trait)) { trait.mNonPersistableData.mCanBeLearnedRandomly = false; } foreach (ImaginaryDoll doll in Sims3.Gameplay.Queries.GetObjects<ImaginaryDoll>()) { if (doll.mLiveStateSimDescId == 0) continue; if (doll.GetLiveFormSimDescription() != null) continue; doll.CreateLiveStateForm(); Overwatch.Log("Missing Imaginary Doll Repaired"); } foreach (SimDescription sim in Households.All(Household.NpcHousehold)) { if (sim.OccultManager == null) continue; OccultImaginaryFriend occult = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend; if (occult == null) continue; Overwatch.Log(sim.FullName); if (occult.IsReal) continue; SimDescription owner = SimDescription.Find(occult.OwnerSimDescriptionId); if (owner == null) continue; if (owner.LotHome == null) continue; IScriptProxy proxy = Simulator.GetProxy(occult.mDollId); if (proxy == null) { IGameObject obj = GlobalFunctions.CreateObjectOutOfWorld("ImaginaryFriendDoll", ProductVersion.EP4); if (obj != null) { ImaginaryDoll doll = obj as ImaginaryDoll; if (doll == null) { obj.Destroy(); } else { occult.UpdateDollGuid(obj.ObjectId); doll.SetOwner(owner); doll.mLiveStateSimDescId = sim.SimDescriptionId; doll.mIsFemale = sim.IsFemale; doll.mGenderSet = true; doll.EstablishState(ImaginaryDoll.OwnershipState.Live); Sim ownerSim = owner.CreatedSim; if (ownerSim != null) { if (Inventories.TryToMove(obj, ownerSim)) { Overwatch.Log("Imaginary Friend Doll Added To Sim Inventory"); } else { obj.Destroy(); } } else { if (Inventories.TryToMove(obj, ownerSim.Household.SharedFamilyInventory.Inventory)) { Overwatch.Log("Imaginary Friend Doll Added To Family Inventory"); } else { obj.Destroy(); } } } } } } }
public static bool SceneWindow_Hover(WindowBase w, ref ScenePickArgs args) { if (Sims3.Gameplay.Gameflow.CurrentGameSpeed == Sims3.Gameplay.Gameflow.GameSpeed.Pause && !Sims3.Gameplay.GameStates.IsBuildBuyLikeState) { return(false); } if (!UIUtils.IsOkayToStartModalDialog(true)) { return(false); } if (args.mObjectType == ScenePickObjectType.Object) { if (args.mObjectId == sLastObjectId && sCurrentTip != null) { RestartAlarm(); return(true); } else { sLastObjectId = args.mObjectId; HideCurrentTooltip(); } if (sCurrentTip != null) { return(false); } IScriptProxy proxy = Simulator.GetProxy(new ObjectGuid(args.mObjectId)); if (proxy != null && proxy.Target != null) { Type type = proxy.Target.GetType(); if (type == null) { return(false); } Type lastType = null; int loop = 0; while (type != typeof(GameObject)) { if (loop > 6) { break; } lastType = type; type = type.BaseType; if (type == typeof(CommonDoor)) { break; } loop++; } type = lastType; if (!sListeners.ContainsKey(type)) { return(false); } Vector2 vector = UIManager.GetCursorPosition(); WindowBase baseWin = UIManager.GetWindowFromPoint(vector); string content = string.Empty; foreach (MethodInfo info in sListeners[type]) { object[] parameters = new object[] { proxy, args }; content += (string)info.Invoke(null, parameters); } if (content.Length > 3) { Vector2 mousePosition = new Vector2(0f, 0f); mousePosition = baseWin.Parent != null?baseWin.Parent.ScreenToWindow(vector) : baseWin.ScreenToWindow(vector); SetAlarm(); sCurrentTip = CreateTooltip(content, mousePosition, baseWin); sTipObject = args.mObjectId; } } } return(true); }
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(); } return tooltip; }
public static bool OnPrepareObject(ObjectGuid templateId, ObjectGuid targetId, int index, uint uintVal1, uint uintVal2, ThumbnailSize size, uint prepareType, uint uintVal3) { try { switch (((PrepareType)prepareType)) { case PrepareType.kPrepareHousehold: try { return(ThumbnailHelper.PrepareHouseholdForThumbnail(templateId.Value)); } catch (Exception e) { Common.DebugException("PrepareHouseholdForThumbnail", e); return(false); } case PrepareType.kPrepareSimWithoutTemplate: { ResourceKey outfitKey = new ResourceKey(targetId.Value, (uint)templateId.Value, uintVal1); bool useCasSimBuilder = uintVal2 != 0x0; int num = index; int ghostIndex = -1; if ((outfitKey.TypeId != 0xdea2951c) && ((index < 0x100) || (index > 0x300))) { if (num > -4) { num = -1; } if ((index >= 6) && (index < 0x20)) { ghostIndex = index - 0x5; } } return(ThumbnailHelper.SetupForSimThumbnailUsingSimBuilder(outfitKey, num, ghostIndex, useCasSimBuilder, size)); } case PrepareType.kPrepareLot: return(ThumbnailHelper.PrepareLotForThumbnail(templateId.Value)); case PrepareType.kPreparePromSims: { Sim sim = GameObject.GetObject(new ObjectGuid(templateId.Value)) as Sim; if ((sim == null) || !sim.IsHorse) { // Custom return(PreparePromSimsForThumbnail(templateId.Value, targetId.Value)); } return(ThumbnailHelper.PrepareEquestrianRaceSimsForThumbnail(templateId.Value, targetId.Value)); } case PrepareType.kPreparePhotoBoothSims: return(ThumbnailHelper.PreparePhotoBoothSimsForThumbnail(templateId.Value, targetId.Value)); case PrepareType.kPrepareSimsUsingObject: return(ThumbnailHelper.PrepareThumbnailForSimsUsingObject(templateId.Value)); case PrepareType.kPrepareSimsForSelfPhoto: return(ThumbnailHelper.PrepareSelfPhotoSimsForThumbnail(templateId.Value, targetId.Value)); case PrepareType.kPrepareSculptureSim: return(ThumbnailHelper.PrepareSculptureSimForThumbnail(targetId.Value)); case PrepareType.kPrepareSimsForServoBotArenaPic: return(ThumbnailHelper.PrepareServoBotArenaSimsForThumbnail(templateId.Value)); } if ((((templateId.Value == 0x34aeecbL) || (templateId.Value == 0x358b08aL)) || ((templateId.Value == 0x93d84841L) || (templateId.Value == 0x51df2ddL))) || ((templateId.Value == 0x72683c15L) || (templateId.Value == 0x3555ba8L))) { CASAgeGenderFlags ageGender = (CASAgeGenderFlags)uintVal1; bool flag2 = uintVal2 != 0x0; ResourceKey partKey = new ResourceKey(targetId.Value, (uint)templateId.Value, uintVal3); if (flag2) { return(ThumbnailHelper.SetupForCASThumbnailUsingCASSimbuilder(partKey, index, ageGender, size)); } return(ThumbnailHelper.SetupForCASThumbnailUsingSeparateSimbuilder(partKey, index, ageGender, size)); } IScriptProxy proxyPreInit = Simulator.GetProxyPreInit(templateId); if (proxyPreInit != null) { object target = proxyPreInit.Target; if (target == null) { return(false); } Sim sim2 = target as Sim; if (sim2 != null) { if ((index >= 6) && (index < 0x20)) { if (!sim2.SimDescription.IsEP11Bot) { uint deathTypeFromMoodID = (uint)SimDescription.GetDeathTypeFromMoodID((MoodID)index); World.ObjectSetGhostState(targetId, deathTypeFromMoodID, (uint)sim2.SimDescription.AgeGenderSpecies); } else { World.ObjectSetGhostState(targetId, 0x17, (uint)sim2.SimDescription.AgeGenderSpecies); } } if (sim2.SimDescription.IsVampire) { World.ObjectSetVisualOverride(targetId, eVisualOverrideTypes.Vampire, null); } else if (sim2.SimDescription.IsWerewolf) { World.ObjectSetVisualOverride(targetId, eVisualOverrideTypes.Werewolf, null); } else if (sim2.SimDescription.IsGenie) { World.ObjectSetVisualOverride(targetId, eVisualOverrideTypes.Genie, null); } if (sim2.SimDescription.IsAlien) { World.ObjectSetVisualOverride(targetId, eVisualOverrideTypes.Alien, null); } SimOutfit outfit = (sim2.Service == null) ? sim2.SimDescription.GetOutfit(OutfitCategories.Everyday, 0x0) : sim2.SimDescription.GetOutfit(OutfitCategories.Career, 0x0); if ((outfit != null) && ((outfit.AgeGenderSpecies & (CASAgeGenderFlags.Child | CASAgeGenderFlags.Teen | CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Toddler | CASAgeGenderFlags.Baby | CASAgeGenderFlags.Adult | CASAgeGenderFlags.Elder)) == sim2.SimDescription.Age)) { CASUtils.SetOutfitInGameObject(outfit.Key, targetId); ThumbnailHelper.SelectSimPose(index, outfit.AgeGenderSpecies & (CASAgeGenderFlags.Child | CASAgeGenderFlags.Teen | CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Toddler | CASAgeGenderFlags.Baby | CASAgeGenderFlags.Adult | CASAgeGenderFlags.Elder), outfit.AgeGenderSpecies & ((CASAgeGenderFlags)0xcf00), 0x0, false); return(true); } } } } catch (Exception e) { Common.Exception("OnPrepareObject", e); } return(false); }