public static SimDescription UnpackSim(MiniSimDescription ths, bool updateGenealogy) { try { if (ths == null) { return(null); } // Calling ImportSimDescription prior to the Aging Manager being available is invalid, don't allow it if (AgingManager.Singleton == null) { return(null); } SimDescription desc = new SimDescription(); ResourceKeyContentCategory installed = ResourceKeyContentCategory.kInstalled; DownloadContent.ImportSimDescription(ths.mTravelKey, desc, ref installed); desc.SimDescriptionId = ths.mSimDescriptionId; if (desc.CareerManager != null) { // Fixup for careers require a household, which is not set until later in this process desc.CareerManager.mJob = null; desc.CareerManager.mSchool = null; } desc.Fixup(); if (updateGenealogy && !GameStates.IsTravelling) { if (desc.DefaultOutfitKey == ResourceKey.kInvalidResourceKey) { SimOutfit outfit = desc.GetOutfit(OutfitCategories.Everyday, 0x0); if ((outfit == null) || (!outfit.IsValid)) { desc.Dispose(false, false); return(null); } desc.UpdateFromOutfit(OutfitCategories.Everyday); } desc.CASGenealogy = ths.CASGenealogy; } Corrections.CleanupBrokenSkills(desc, null); OccultTypeHelper.ValidateOccult(desc, null); return(desc); } catch (Exception e) { Common.Exception(ths.FullName, e); return(null); } }
public static string GetLocalizedName(SimType type) { switch (type) { case SimType.Vampire: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Vampire)); case SimType.Mummy: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Mummy)); case SimType.SimBot: case SimType.Frankenstein: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Frankenstein)); case SimType.ImaginaryFriend: return(OccultTypeHelper.GetLocalizedName(OccultTypes.ImaginaryFriend)); case SimType.Unicorn: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Unicorn)); case SimType.Genie: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Genie)); case SimType.Werewolf: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Werewolf)); case SimType.Fairy: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Fairy)); case SimType.Witch: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Witch)); case SimType.Mermaid: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Mermaid)); case SimType.Plantsim: return(OccultTypeHelper.GetLocalizedName(OccultTypes.PlantSim)); case SimType.Plumbot: return(OccultTypeHelper.GetLocalizedName(OccultTypes.Robot)); case SimType.TimeTraveler: return(OccultTypeHelper.GetLocalizedName(OccultTypes.TimeTraveler)); default: return(Common.Localize("SimType:" + type)); } }
public static bool Add(SimDescription sim, OccultTypes type, bool isReward, bool applyOutfit) { try { if (sim.IsPregnant) { return(false); } if (!OccultTypeHelper.IsInstalled(type)) { return(false); } if (sim.OccultManager.HasOccultType(type)) { bool found = false; if (sim.OccultManager.mOccultList != null) { foreach (OccultBaseClass occult in sim.OccultManager.mOccultList) { if (occult.ClassOccultType == type) { found = true; break; } } } if (found) { return(false); } } return(AddOccultType(sim.OccultManager, type, applyOutfit, isReward, false, null)); } catch (Exception e) { Common.Exception(sim, e); return(false); } }
// From SimDescription.Instantiate private static Sim Perform(SimDescription ths, Vector3 position, ResourceKey outfitKey, bool forceAlwaysAnimate, OnReset reset) { Household.HouseholdSimsChangedCallback changedCallback = null; Household changedHousehold = null; bool isChangingWorlds = GameStates.sIsChangingWorlds; bool isLifeEventManagerEnabled = LifeEventManager.sIsLifeEventManagerEnabled; Corrections.RemoveFreeStuffAlarm(ths); using (SafeStore store = new SafeStore(ths, SafeStore.Flag.LoadFixup | SafeStore.Flag.Selectable | SafeStore.Flag.Unselectable)) { try { // Stops the memories system from interfering LifeEventManager.sIsLifeEventManagerEnabled = false; // Stops UpdateInformationKnownAboutRelationships() GameStates.sIsChangingWorlds = true; if (ths.Household != null) { changedCallback = ths.Household.HouseholdSimsChanged; changedHousehold = ths.Household; ths.Household.HouseholdSimsChanged = null; } if (ths.CreatedSim != null) { AttemptToPutInSafeLocation(ths.CreatedSim, false); if (reset != null) { ths.CreatedSim.SetObjectToReset(); reset(ths.CreatedSim, false); } return(ths.CreatedSim); } if (ths.AgingState != null) { bool flag = outfitKey == ths.mDefaultOutfitKey; ths.AgingState.SimBuilderTaskDeferred = false; ths.AgingState.PreInstantiateSim(ref outfitKey); if (flag) { ths.mDefaultOutfitKey = outfitKey; } } int capacity = forceAlwaysAnimate ? 0x4 : 0x2; Hashtable overrides = new Hashtable(capacity); overrides["simOutfitKey"] = outfitKey; overrides["rigKey"] = CASUtils.GetRigKeyForAgeGenderSpecies((ths.Age | ths.Gender) | ths.Species); if (forceAlwaysAnimate) { overrides["enableSimPoseProcessing"] = 0x1; overrides["animationRunsInRealtime"] = 0x1; } string instanceName = "GameSim"; ProductVersion version = ProductVersion.BaseGame; if (ths.Species != CASAgeGenderFlags.Human) { instanceName = "Game" + ths.Species; version = ProductVersion.EP5; } SimInitParameters initData = new SimInitParameters(ths); Sim target = GlobalFunctions.CreateObjectWithOverrides(instanceName, version, position, 0x0, Vector3.UnitZ, overrides, initData) as Sim; if (target != null) { if (target.SimRoutingComponent == null) { // Performed to ensure that a useful error message is produced when the Sim construction fails target.OnCreation(); target.OnStartup(); } target.SimRoutingComponent.EnableDynamicFootprint(); target.SimRoutingComponent.ForceUpdateDynamicFootprint(); ths.PushAgingEnabledToAgingManager(); /* This code is idiotic * if ((ths.Teen) && (target.SkillManager != null)) * { * Skill skill = target.SkillManager.AddElement(SkillNames.Homework); * while (skill.SkillLevel < SimDescription.kTeenHomeworkSkillStartLevel) * { * skill.ForceGainPointsForLevelUp(); * } * } */ // Custom OccultTypeHelper.SetupForInstantiatedSim(ths.OccultManager); if (ths.IsAlien) { World.ObjectSetVisualOverride(target.ObjectId, eVisualOverrideTypes.Alien, null); } AttemptToPutInSafeLocation(target, false); EventTracker.SendEvent(EventTypeId.kSimInstantiated, null, target); /* * MiniSimDescription description = MiniSimDescription.Find(ths.SimDescriptionId); * if ((description == null) || (!GameStates.IsTravelling && (ths.mHomeWorld == GameUtils.GetCurrentWorld()))) * { * return target; * } * description.UpdateInWorldRelationships(ths); */ if (ths.HealthManager != null) { ths.HealthManager.Startup(); } if (((ths.SkinToneKey.InstanceId == 15475186560318337848L) && !ths.OccultManager.HasOccultType(OccultTypes.Vampire)) && (!ths.OccultManager.HasOccultType(OccultTypes.Werewolf) && !ths.IsGhost)) { World.ObjectSetVisualOverride(ths.CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null); } if (ths.Household.IsAlienHousehold) { (Sims3.UI.Responder.Instance.HudModel as HudModel).OnSimCurrentWorldChanged(true, ths); } if (Household.RoommateManager.IsNPCRoommate(ths.SimDescriptionId)) { Household.RoommateManager.AddRoommateInteractions(target); } } return(target); } finally { LifeEventManager.sIsLifeEventManagerEnabled = isLifeEventManagerEnabled; GameStates.sIsChangingWorlds = isChangingWorlds; if ((changedHousehold != null) && (changedCallback != null)) { changedHousehold.HouseholdSimsChanged = changedCallback; if (changedHousehold.HouseholdSimsChanged != null) { changedHousehold.HouseholdSimsChanged(Sims3.Gameplay.CAS.HouseholdEvent.kSimAdded, ths.CreatedSim, null); } } } } }
public static Results UpdateThumbnailKey(MiniSimDescription ths, ref SimDescription sim) { try { if (ths == null) { return(Results.Unnecessary); } if (ThumbnailManager.KeyExistsInDB(ths.mThumbKey)) { return(Results.Unnecessary); } sim = SimDescription.Find(ths.SimDescriptionId); if (sim != null) { return(Results.Unnecessary); } sim = UnpackSim(ths, false); if (sim == null) { return(Results.Failure); } // There is an error creating thumbnails for foreign imaginary friends if (sim.OccultManager != null) { if (sim.OccultManager.mOccultList != null) { OccultTypeHelper.Remove(sim, OccultTypes.ImaginaryFriend, true); } else if (sim.OccultManager.HasOccultType(OccultTypes.ImaginaryFriend)) { sim.OccultManager.mCurrentOccultTypes &= ~OccultTypes.ImaginaryFriend; } } if (ths.mTravelKey == ResourceKey.kInvalidResourceKey) { return(Results.Failure); } ths.mThumbKey = new ThumbnailKey(ths.mTravelKey, 0x0, 0x0, 0x0, ThumbnailSize.Large); ths.mThumbKey.mDescKey.GroupId = 0x0; GenerateCrossWorldThumbnail(ths, sim, true); if (!ThumbnailManager.KeyExistsInDB(ths.mThumbKey)) { ths.mThumbKey = new ThumbnailKey(sim.DefaultOutfitKey, ThumbnailSize.Large); } if (ThumbnailManager.KeyExistsInDB(ths.mThumbKey)) { return(Results.Success); } else { return(Results.Failure); } } catch (Exception e) { Common.Exception(ths.FullName, e); return(Results.Failure); } }