/// <summary> /// Returns the Description File for the passed Sim id /// </summary> /// <param name="simid">id of the Sim</param> /// <returns>The Description file for the Sim</returns> /// <remarks> /// If the Description file does not exist in /// the current Package, it will be added! /// </remarks> /// <exception cref="Exception">Thrown when ProcessData was not called.</exception> public SDesc GetDescriptionFile(uint simid) { if (package == null) { throw new Exception("No package loaded!"); } SDesc sdesc = SDesc.FindForSimId(simid, package); if (sdesc == null) { sdesc = new SDesc(null, null, null); sdesc.SimId = simid; sdesc.CharacterDescription.Age = 28; IPackedFileDescriptor[] files = package.FindFiles(SimPe.Data.MetaData.SIM_DESCRIPTION_FILE); sdesc.Instance = 0; foreach (IPackedFileDescriptor pfd in files) { if (pfd.Instance > sdesc.Instance) { sdesc.Instance = (ushort)pfd.Instance; } } sdesc.Instance++; IPackedFileDescriptor fd = package.Add(SimPe.Data.MetaData.SIM_DESCRIPTION_FILE, 0x0, FileDescriptor.Group, sdesc.Instance); sdesc.Save(fd); } return(sdesc); }
/// <summary> /// returns a List of Parent Sims /// </summary> /// <param name="sdsc"></param> /// <returns></returns> public Wrapper.SDesc[] SiblingSims(Wrapper.SDesc sdsc) { ArrayList list = new ArrayList(); SimPe.PackedFiles.Wrapper.Supporting.FamilyTieSim fts = this.FindTies(sdsc); if (fts != null) { foreach (SimPe.PackedFiles.Wrapper.Supporting.FamilyTieItem fti in fts.Ties) { if (fti.SimDescription == null) { continue; } if (fti.Type == Data.MetaData.FamilyTieTypes.ImMarriedTo || fti.Type == Data.MetaData.FamilyTieTypes.MySiblingIs) { list.Add(fti.SimDescription); } } } Wrapper.SDesc[] ret = new SDesc[list.Count]; list.CopyTo(ret); return(ret); }
protected ExtendedImagePanel CreateItem(Interfaces.Files.IPackedFileDescriptor pfd, int left, int top) { ExtendedImagePanel eip = new ExtendedImagePanel(); eip.BeginUpdate(); eip.SetBounds(left, top, 216, 80); Wrapper.SDesc sdesc = new SDesc(); try { sdesc.ProcessData(pfd, pkg); PrepareItem(eip, sdesc); } catch (Exception ex) { eip.Properties["Error"].Value = ex.Message; } //eip.GotFocus += new EventHandler(eip_GotFocus); //eip.MouseDown += new System.Windows.Forms.MouseEventHandler(eip_MouseDown); //eip.DoubleClick += new EventHandler(eip_DoubleClick); return(eip); }
public void DeleteMemoryEchoes(Collections.NgbhItems items, uint ownerID) { int deletedCount = 0; ExceptionBuilder trace = new ExceptionBuilder(); trace.Append("Memories found:" + Helper.lbr); Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims); foreach (NgbhSlot slot in slots) { // skip my own memories? if (ownerID == slot.SlotID) { continue; } SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[(ushort)slot.SlotID] as SDesc; Collections.NgbhItems simMemories = slot.ItemsB; Collections.NgbhItems memoryToRemove = new SimPe.Plugin.Collections.NgbhItems(null); for (int j = 0; j < simMemories.Length; j++) { for (int i = 0; i < items.Length; i++) { NgbhItem item = items[i]; NgbhItem simMemory = simMemories[j]; if ( simMemory.IsMemory && item.IsMemory && simMemory.Guid == item.Guid && ArrayEquals(simMemory.Data, item.Data) && !simMemory.Flags.IsVisible ) { memoryToRemove.Add(simMemory); // simMemory.RemoveFromParentB(); } } } if (memoryToRemove.Count > 0) { deletedCount += memoryToRemove.Count; trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count); foreach (NgbhItem item in memoryToRemove) { trace.AppendFormat("\t- {0}\r\n", item.ToString()); } trace.Append("\t\r\n\r\n"); slot.ItemsB.Remove(memoryToRemove); } } if (deletedCount > 0) { Message.Show(String.Format("Deleted {0} memories from the sim pool", deletedCount) + Helper.lbr + Helper.lbr + trace.ToString()); } }
/// <summary> /// Init the Plastic Surgery /// </summary> /// <param name="ngbh">The Neighborhood the Sim lives in (needed for DNA)</param> /// <param name="patient">The Sim that should be changed</param> /// <param name="archetype">The Template Sime</param> public PlasticSurgery(Interfaces.Files.IPackageFile ngbh, Interfaces.Files.IPackageFile patient, SDesc spatient, Interfaces.Files.IPackageFile archetype, SDesc sarchetype) { this.patient = patient; this.archetype = archetype; this.ngbh = ngbh; this.spatient = spatient; this.sarchetype = sarchetype; }
/// <summary> /// Returns the available <see cref="FamilyTieSim"/> for the Sim, or creates a new One /// </summary> /// <param name="sdsc"></param> /// <returns>the <see cref="FamilyTieSim"/> for the passed Sim</returns> public FamilyTieSim CreateTie(SDesc sdsc) { FamilyTieSim s = FindTies(sdsc); if (s == null) { s = new FamilyTieSim(sdsc.Instance, new FamilyTieItem[0], this); sims.Add(s); } return(s); }
/// <summary> /// Returns the available <see cref="FamilyTieItem"/> for the Sim, or creates a new One /// </summary> /// <param name="sdsc"></param> /// <returns>the <see cref="FamilyTieItem"/> for the passed Sim</returns> public FamilyTieItem CreateTie(SDesc sdsc, Data.MetaData.FamilyTieTypes type) { FamilyTieItem s = FindTie(sdsc); if (s == null) { s = new FamilyTieItem(type, sdsc.Instance, this.famt); ties = (FamilyTieItem[])Helper.Add(ties, s); } s.Type = type; return(s); }
public static System.Drawing.Color GetImagePanelColor(SDesc sdesc) { if (sdesc.Unlinked != 0) { return(System.Drawing.Color.DarkBlue); } else if (!sdesc.AvailableCharacterData) { return(System.Drawing.Color.DarkRed); } return(System.Drawing.SystemColors.ControlDarkDark); //System.Drawing.Color.Black; }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj is SDesc) { SDesc s = (SDesc)obj; return(s.SimId == SimId); } return(base.Equals(obj)); }
/// <summary> /// Loads the Description File for a Sim /// </summary> protected void LoadSDesc() { if (sdesc == null) { sdesc = new SDesc(famt.NameProvider, null, null); try { SimPe.Interfaces.Files.IPackedFileDescriptor pfd = famt.Package.FindFile(MetaData.SIM_DESCRIPTION_FILE, 0, famt.FileDescriptor.Group, siminstance); sdesc.ProcessData(pfd, famt.Package); } catch (Exception) {} } }
protected ushort GetSecondaryAspirationValue(SDesc sim) { if (!SimPe.Helper.WindowsRegistry.AllowChangeOfSecondaryAspiration) { return(0); } NgbhItem ni = GetSecondaryAspirationToken(sim, false); if (ni == null) { return(0); } return(ni.Value); }
/// <summary> /// Returns the avaqilable <see cref="FamilyTieSim"/> for the passed Sim /// </summary> /// <param name="sdsc"></param> /// <returns>null or the <see cref="FamilyTieSim"/> for that Sim</returns> public FamilyTieSim FindTies(SDesc sdsc) { if (sdsc == null) { return(null); } foreach (FamilyTieSim s in sims) { if (s.Instance == sdsc.Instance) { return(s); } } return(null); }
/// <summary> /// Returns the avaqilable <see cref="FamilyTieItem"/> for the passed Sim /// </summary> /// <param name="sdsc"></param> /// <returns>null or the <see cref="FamilyTieItem"/> for that Sim</returns> public FamilyTieItem FindTie(SDesc sdsc) { if (sdsc == null) { return(null); } foreach (FamilyTieItem s in ties) { if (s.Instance == sdsc.Instance) { return(s); } } return(null); }
protected void LoadMemoryResource(SDesc sim) { if (sim != null && pkg == sim.Package) { return; } if (sim != null) { pkg = sim.Package; } else { pkg = null; } ngbh = null; if (sim == null) { return; } if (sim.Package == null) { return; } if (!SimPe.Helper.WindowsRegistry.AllowChangeOfSecondaryAspiration) { return; } SimPe.Interfaces.Plugin.IFileWrapper wrapper = (SimPe.Interfaces.Plugin.IFileWrapper)FileTable.WrapperRegistry.FindHandler(SimPe.Data.MetaData.MEMORIES); if (wrapper == null) { return; } SimPe.Interfaces.Files.IPackedFileDescriptor[] mems = sim.Package.FindFiles(SimPe.Data.MetaData.MEMORIES); foreach (SimPe.Interfaces.Files.IPackedFileDescriptor pfd in mems) { ngbh = new Ngbh(SimPe.FileTable.ProviderRegistry); ngbh.ProcessData(pfd, pkg, false); return; } }
internal static void CreateItem(ImagePanel eip, SDesc sdesc) { eip.ImagePanelColor = System.Drawing.Color.Black; eip.Fade = 0.5f; eip.FadeColor = System.Drawing.Color.Transparent; eip.Tag = sdesc; try { eip.Text = sdesc.SimName + " " + sdesc.SimFamilyName; System.Drawing.Image img = sdesc.Image; if (img.Width < 8) { img = null; } if (img == null) { img = System.Drawing.Image.FromStream(typeof(SimPoolControl).Assembly.GetManifestResourceStream("SimPe.PackedFiles.Wrapper.noone.png")); } else if (Helper.WindowsRegistry.GraphQuality) { img = Ambertation.Drawing.GraphicRoutines.KnockoutImage(img, new System.Drawing.Point(0, 0), System.Drawing.Color.Magenta); } eip.Image = Ambertation.Drawing.GraphicRoutines.ScaleImage(img, 48, 48, Helper.WindowsRegistry.GraphQuality); eip.ImagePanelColor = GetImagePanelColor(sdesc); } catch { } if (sdesc.CharacterDescription.Gender == Data.MetaData.Gender.Female) { eip.PanelColor = System.Drawing.Color.LightPink; } else { eip.PanelColor = System.Drawing.Color.PowderBlue; } }
ImagePanel AddTieToGraph(SDesc sdsc, int left, int top, Data.MetaData.FamilyTieTypes type, bool isextern) { if (baseip == null) { return(null); } ImagePanel ip = CreateItem(sdsc, left, top); string name = ((Data.LocalizedFamilyTieTypes)type).ToString(); ip.ParentItems.Add(baseip, name); ip.Parent = this; if (isextern) { ip.EndUpdate(); } return(ip); }
public SimPe.Data.MetaData.AspirationTypes[] LoadAspirations(SDesc sim) { if (sim == null) { return(null); } LoadMemoryResource(sim); ushort sval = GetSecondaryAspirationValue(sim); SimPe.Data.MetaData.AspirationTypes[] res = new SimPe.Data.MetaData.AspirationTypes[] { SimPe.Data.MetaData.AspirationTypes.Nothing, SimPe.Data.MetaData.AspirationTypes.Nothing }; ushort a = (ushort)sim.CharacterDescription.Aspiration; if (sval != 0) { res[0] = (SimPe.Data.MetaData.AspirationTypes)(a ^ sval); res[1] = (SimPe.Data.MetaData.AspirationTypes)(a & sval); } else { Array arr = Enum.GetValues(typeof(SimPe.Data.MetaData.AspirationTypes)); foreach (ushort i in arr) { if ((a & i) == i) { if (res[0] == SimPe.Data.MetaData.AspirationTypes.Nothing) { res[0] = (SimPe.Data.MetaData.AspirationTypes)i; } else { res[1] = (SimPe.Data.MetaData.AspirationTypes)i; } } } } return(res); }
internal SdscFreetime(SDesc dsc) { parent = dsc; enthusiasm = new List <ushort>(); decays = new List <ushort>(); for (int i = 0; i < 11; i++) { enthusiasm.Add(0); } for (int i = 0; i < 7; i++) { decays.Add(0); } predestined = 0; ltasp = 0; unlockpts = 0; unlocksspent = 0; bugcollection = 0; }
protected NgbhItem GetSecondaryAspirationToken(SDesc sim, bool create) { if (ngbh == null) { return(null); } NgbhSlot slot = ngbh.Sims.GetInstanceSlot(sim.Instance, true); if (slot != null) { NgbhItem item = slot.FindItem(SEC_ASP_TOKEN_GUID); if (create && item == null) { item = slot.ItemsB.AddNew(SimMemoryType.Token); item.Guid = SEC_ASP_TOKEN_GUID; item.Value = 0; } return(item); } return(null); }
public void FixNeighborhoodMemories() { int deletedCount = 0; int fixedCount = 0; ExceptionBuilder trace = new ExceptionBuilder(); trace.Append("Invalid memories found:" + Helper.lbr); Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims); foreach (NgbhSlot slot in slots) { SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[slot.SlotID] as SDesc; Collections.NgbhItems simMemories = slot.ItemsB; ArrayList memoryToRemove = new ArrayList(); ArrayList memoryToFix = new ArrayList(); NgbhItem lastSpamMemory = null; for (int j = 0; j < simMemories.Length; j++) { NgbhItem simMemory = simMemories[j]; // skip tokens... if (simMemory.IsMemory) { // ...and the lame "Met Unknown" memories if (simMemory.SimInstance != 0) { // fix invalid sim instances ushort inst = FileTable.ProviderRegistry.SimDescriptionProvider.GetInstance(simMemory.SimID); if (simMemory.SimInstance != inst) { simMemory.SimInstance = inst; memoryToFix.Add(simMemory); } if (simDesc == null) { memoryToRemove.Add(simMemory); } } // it could be spam... // collapse duplicate items if (simMemory.IsSpam) { if ( lastSpamMemory != null && lastSpamMemory.Guid == simMemory.Guid && lastSpamMemory.SimInstance == simMemory.SimInstance ) { memoryToRemove.Add(simMemory); } lastSpamMemory = simMemory; } else { lastSpamMemory = null; } } } // for simMemories if (memoryToRemove.Count > 0 || memoryToFix.Count > 0) { deletedCount += memoryToRemove.Count; fixedCount += memoryToFix.Count; trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count + memoryToFix.Count); foreach (NgbhItem item in memoryToFix) { trace.AppendFormat("[FIX]- {0}\r\n", item.ToString()); } NgbhItem[] itemsToRemove = (NgbhItem[])memoryToRemove.ToArray(typeof(NgbhItem)); foreach (NgbhItem item in itemsToRemove) { trace.AppendFormat("[DEL]- {0}\r\n", item.ToString()); } trace.Append("\t\r\n\r\n"); slot.ItemsB.Remove(itemsToRemove); } } if (deletedCount > 0 || fixedCount > 0) { Helper.ExceptionMessage(String.Format("Fixed/Deleted {0} invalid memories.", deletedCount + fixedCount), trace); } }
public ImagePanel AddTieToGraph(SDesc sdsc, int left, int top, Data.MetaData.FamilyTieTypes type) { return(AddTieToGraph(sdsc, left, top, type, true)); }
public void StoreAspirations(SimPe.Data.MetaData.AspirationTypes[] asps, SDesc sim) { if (sim == null) { return; } if (asps == null) { return; } if (asps.Length < 2) { return; } SimPe.Data.MetaData.AspirationTypes[] old = LoadAspirations(sim); bool chg = false; bool chg2 = asps[1] != old[1]; for (int i = 0; i < 2; i++) { if (asps[i] != old[i]) { chg = true; } } if (!chg) { return; } //LoadMemoryResource(sim); ushort a = 0; ushort v = 0; for (int i = 0; i < 2; i++) { if (i == 0) { v = (ushort)asps[i]; } else if (i == 1 && ((ushort)asps[i]) == v) { v = 0; } else if (i == 1) { v = (ushort)asps[i]; } a |= (ushort)asps[i]; } sim.CharacterDescription.Aspiration = (SimPe.Data.MetaData.AspirationTypes)a; if (SimPe.Helper.WindowsRegistry.AllowChangeOfSecondaryAspiration && chg2) { NgbhItem itm = GetSecondaryAspirationToken(sim, true); itm.Value = v; ngbh.SynchronizeUserData(); } }
internal SdscApartment(SDesc dsc) { parent = dsc; }