public static void RequestRandomPart(bool hat) { List <CASParts.Wrapper> fullList = GetVisibleCASParts(CASLogic.GetSingleton(), BodyTypes.Hair); List <CASParts.Wrapper> list = new List <CASParts.Wrapper>(); foreach (CASParts.Wrapper part in fullList) { if (hat != CASHair.PartIsHat(part.mPart)) { continue; } list.Add(part); } int count = list.Count; if (count > 0) { CASParts.Wrapper part = list[(int)(count * RandomGen.NextDouble())]; Sims3.UI.Responder.Instance.CASModel.RequestAddCASPart(part.mPart, false); } }
protected static bool PartMatches(CASParts.Wrapper part) { if (part.mPart.Key.GroupId != 0x70000000) { return(false); } return(sRippedParts.ContainsKey(part.mPart.Key.InstanceId)); }
public Item(CASParts.Wrapper part) : base(part.mPart.Key, "0x" + part.mPart.Key.InstanceId.ToString("X16"), 0) { CASParts.PartPreset preset = new CASParts.PartPreset(part.mPart); if (!preset.Valid) { uint num2 = CASUtils.PartDataNumPresets(part.mPart.Key); if (num2 > 0) { preset = new CASParts.PartPreset(part.mPart, 0); if (!preset.Valid) { return; } } } mThumbnail = new ThumbnailKey(preset.mPart.Key, (preset.mPresetId != uint.MaxValue) ? ((int)preset.mPresetId) : -1, (uint)preset.mPart.BodyType, (uint)preset.mPart.AgeGenderSpecies, ThumbnailSize.Large); }
public static InvalidPartBase.Reason Allow(CASParts.Wrapper part, CASAgeGenderFlags age, CASAgeGenderFlags gender, CASAgeGenderFlags species, bool maternity, OutfitCategories category) { OutfitCategoriesExtended extended = (OutfitCategoriesExtended)0; if ((part.ExtendedCategory & OutfitCategoriesExtended.IsHat) == OutfitCategoriesExtended.IsHat) { extended |= OutfitCategoriesExtended.IsHat; } if (maternity) { extended |= OutfitCategoriesExtended.ValidForMaternity; } if (species == CASAgeGenderFlags.Human) { switch (part.BodyType) { case BodyTypes.FullBody: case BodyTypes.LowerBody: case BodyTypes.UpperBody: case BodyTypes.Shoes: case BodyTypes.Hair: switch (age) { case CASAgeGenderFlags.Baby: case CASAgeGenderFlags.Toddler: case CASAgeGenderFlags.Child: if (part.Age != age) { return(InvalidPartBase.Reason.ImproperAge); } break; default: if ((part.Age & (CASAgeGenderFlags.Baby | CASAgeGenderFlags.Toddler | CASAgeGenderFlags.Child)) != CASAgeGenderFlags.None) { return(InvalidPartBase.Reason.ImproperAge); } break; } break; } } InvalidPartBase.Reason reason = InvalidPartBase.Reason.None; if ((sValidPartsByKey.Count > 0) || (sValidPartsByType.Count > 0)) { List <InvalidPartBase> tests; if (sValidPartsByKey.TryGetValue(part.Key, out tests)) { foreach (InvalidPartBase test in tests) { if (test.Allow(age, gender, species, category, extended, out reason)) { return(InvalidPartBase.Reason.None); } } } if (sValidPartsByType.TryGetValue(part.BodyType, out tests)) { foreach (InvalidPartBase test in tests) { if (test.Allow(age, gender, species, category, extended, out reason)) { return(InvalidPartBase.Reason.None); } } } return(InvalidPartBase.Reason.ValidFail); } else { List <InvalidPartBase> tests; if (sInvalidPartsByKey.TryGetValue(part.Key, out tests)) { foreach (InvalidPartBase test in tests) { if (!test.Allow(age, gender, species, category, extended, out reason)) { return(reason); } } } if (sInvalidPartsByType.TryGetValue(part.BodyType, out tests)) { foreach (InvalidPartBase test in tests) { if (!test.Allow(age, gender, species, category, extended, out reason)) { return(reason); } } } return(InvalidPartBase.Reason.None); } }
public void OnClothingSelect(WindowBase sender, UIMouseEventArgs args) { try { CASParts.Wrapper part = null; CASClothingRow.ClothingThumbnail tag = sender.Tag as CASClothingRow.ClothingThumbnail; if (!mRow.mTempWindowValid || (tag.mIndex != (mRow.mItems.Count - 0x1))) { if (tag.mData is CASPart) { part = new CASParts.Wrapper((CASPart)tag.mData); if (args.MouseKey != MouseKeys.kMouseRight) { SelectItem(mRow.RowController, part.mPart, null); mRow.mSelectedItem = (part.mPart.Key.InstanceId != 0x0L) ? tag.mIndex : -1; } } else if (tag.mData is CASPartPreset) { CASPartPreset preset = (CASPartPreset)tag.mData; part = new CASParts.Wrapper(preset.mPart); if ((mRow.mRowController.IsAccessoryType(part.mPart.BodyType)) && ((tag.mState & CASClothingRow.WindowState.Active) != CASClothingRow.WindowState.Normal)) { if (args.MouseKey != MouseKeys.kMouseRight) { if (!mAllowMultiple) { mRow.RowController.RemoveItem(part.mPart.BodyType); } else { RemoveItem(mRow.RowController, part.mPart); } mRow.mSelectedItem = -1; } else { if (mRow.mRowController is CASClothingCategory) { (mRow.mRowController as CASClothingCategory).mCurrentPreset = preset; } else if (mRow.mRowController is CASMakeup) { (mRow.mRowController as CASMakeup).mCurrentPreset = preset; } } } else if (args.MouseKey != MouseKeys.kMouseRight) { SelectItem(mRow.RowController, preset.mPart, preset); mRow.mSelectedItem = tag.mIndex; } } else if ((args.MouseKey != MouseKeys.kMouseRight) && (!(tag.mData is IFeaturedStoreItem))) { mRow.RowController.RemoveItem(mRow.CASPart.BodyType); mRow.mSelectedItem = -1; } if (args.MouseKey != MouseKeys.kMouseRight) { mRow.ClearTempItem(); if (mRow.mObjectOfInterest is CASPart) { if (!mAllowMultiple) { mRow.mRowController.OnRowInItemSelected(mRow, mRow.CASPart.BodyType); } UpdateSelectedStates(tag.mIndex); } } } else if ((mRow.mRowController.IsAccessoryType(mRow.CASPart.BodyType)) && (IsWorn(mRow.CASPart))) { if (args.MouseKey != MouseKeys.kMouseRight) { if (!mAllowMultiple) { mRow.RowController.RemoveItem(mRow.CASPart.BodyType); } else { RemoveItem(mRow.RowController, mRow.CASPart); } mRow.mSelectedItem = -1; mRow.ClearTempItem(); if (!mAllowMultiple) { mRow.mRowController.OnRowInItemSelected(mRow, mRow.CASPart.BodyType); } UpdateSelectedStates(tag.mIndex); } } if (args.MouseKey == MouseKeys.kMouseRight) { bool remove = ((args.Modifiers & Modifiers.kModifierMaskControl) == Modifiers.kModifierMaskControl); CASBase.Blacklist(part, remove, null); if (remove) { bool compactCAS = false; if (mRow.mRowController.IsAccessoryType(mRow.CASPart.BodyType)) { compactCAS = MasterController.Settings.mCompactAccessoryCAS; } else { compactCAS = MasterController.Settings.mCompactClothingCAS; } if (!compactCAS) { for (int i = 0; i < mRow.mItems.Count; i++) { CASClothingRow.ClothingThumbnail thumbnail = mRow.mItems[i] as CASClothingRow.ClothingThumbnail; if (thumbnail != null) { if ((i + 1) < mRow.mGridWindows.Length) { mRow.mGridWindows[i + 1].Visible = false; } } } } else { CASClothingRow.ClothingThumbnail thumbnail = mRow.mItems[tag.mIndex] as CASClothingRow.ClothingThumbnail; if (thumbnail != null) { if ((tag.mIndex + 1) < mRow.mGridWindows.Length) { mRow.mGridWindows[tag.mIndex + 1].Visible = false; } } } } args.Handled = true; } } catch (Exception e) { Common.Exception("OnClothingSelect", e); } }