Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 8th May 2018 at 10:05 PM Last edited by clang2 : 10th May 2018 at 11:47 AM.
Default (Resolved) How to get current CASoutfit and add a new part without replacing whole outfit?
One more question for the day from me and then I will leave off...
As always, I appreciate your patience and all the help!

I currently use the method below which uses the resourcekey of an outfit I have set up... but it basically replaces the whole outfit in whatever category I have it set up for (in this instance, everyday). It works, so all good there.
What I want to do is get the current outfit the sim is wearing and using the same resourcekey method, somehow, simply have the code add a piece to it and then to the swithwithoutspin thing to make the new piece with already in place 'current' outfit show up in game.
Any suggestions?
Again, thank you for your time and help!

ResourceKey resourceKey = new ResourceKey();
resourceKey = ResourceKey.Parse("0x025ED6F4-0x00000000-0xBA71CE5049BB0759");
SimDescription simDescription = Target.SimDescription;
SimOutfit simOutfit = OutfitUtils.CreateOutfitForSim(simDescription, resourceKey, OutfitCategories.Everyday, true);
this.Target.SimDescription.AddOutfit(simOutfit, OutfitCategories.Everyday, true);
this.Target.SimDescription.RemoveOutfit(OutfitCategories.Everyday, 1, true);
this.Target.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
Advertisement
Test Subject
Original Poster
#2 Old 9th May 2018 at 3:28 PM
The above is close to being resolved.
I am using this method and am having only one problem with it which I am working on fixing.
This method does work, though by getting the current outfit, caching it, adding the new part via resourceKey, then switching the outfit without spin.
The result is the new part shows up in game and during the interaction with out the Sim appearing to have changed anything else but simply adding the part.
Obviously, change YourResourceKeyHere to whatever your resourceKey is, but keep the quotation marks.
Target used here could just as easily be switched to Actor or whatever else you have tagged as Actor/Target etc.

public void OutfitChange()
{

ResourceKey resourceKey = new ResourceKey();
resourceKey = ResourceKey.Parse("YourResourceKeyHere");
SimOutfit currentOutfit = this.Target.CurrentOutfit;
OutfitCategories currentOutfitCategory = this.Target.CurrentOutfitCategory;
int currentOutfitIndex = this.Target.CurrentOutfitIndex;
SimBuilder simBuilder = new SimBuilder();
simBuilder.RemoveParts(new BodyTypes[]
{
BodyTypes.Bracelet
});
OutfitUtils.SetOutfit(simBuilder, currentOutfit, this.Target.SimDescription);
simBuilder.AddPart(resourceKey);
string instanceName = string.Concat(new object[]
{
this.Target.FirstName,
this.Target.LastName,
this.Target.ToString(),
currentOutfitIndex
});
SimOutfit outfit = new SimOutfit(simBuilder.CacheOutfit(instanceName));
this.Target.SimDescription.RemoveOutfit(currentOutfitCategory, currentOutfitIndex, true);
this.Target.SimDescription.AddOutfit(outfit, currentOutfitCategory, currentOutfitIndex);
this.Target.RefreshCurrentOutfit(true);
this.Target.SwitchToOutfitWithoutSpin(currentOutfitCategory);
}
NOTE: in method above the following lines may be currently stopping the newpart (which is also a bracelet) from showing up.

simBuilder.RemoveParts(new BodyTypes[]
{
BodyTypes.Bracelet
});

If you simply remove those lines, the rest works, but may be adding part on top of part every time you do it.
Special thanks to CMAR whose code I ganked in some places.

As soon as I work out the part removal bit, I will include that then mark resolved.
Test Subject
Original Poster
#3 Old 10th May 2018 at 11:52 AM
This is almost exactly the same code as above, I had to adjust a few things that were obvious mistakes above, but it's merely in terms of code placement and not new code.
But, this will work as needed to add a piece to an outfit while removing any other piece that is in that same bodytype position.
You can also use this code to simulate a slow build of pieces onto the Sim...
So, you could add a part...switch outfit without spin...add part...switch outfit without spin again and end up with a final product that looked like it was placed there, one step at a time... for instance: Iron Man's suit construction or smudge/roughed up skin from working on a car and getting progressively dirtier. There are likely ways to handle all this better, but for now, this works
The code:
public void OutfitChange()
{

ResourceKey resourceKey = new ResourceKey();
resourceKey = ResourceKey.Parse("0x034AEECB-0x00000000-0x0FF82676206994B4");
SimOutfit currentOutfit = this.Target.CurrentOutfit;
OutfitCategories currentOutfitCategory = this.Target.CurrentOutfitCategory;
int currentOutfitIndex = this.Target.CurrentOutfitIndex;
SimBuilder simBuilder = new SimBuilder();
OutfitUtils.SetOutfit(simBuilder, currentOutfit, this.Target.SimDescription);
string instanceName = string.Concat(new object[]
{
this.Target.FirstName,
this.Target.LastName,
this.Target.ToString(),
currentOutfitIndex
});
simBuilder.RemoveParts(new BodyTypes[]
{
BodyTypes.Bracelet
});
simBuilder.AddPart(resourceKey);
SimOutfit outfit = new SimOutfit(simBuilder.CacheOutfit(instanceName));
this.Target.SimDescription.RemoveOutfit(currentOutfitCategory, currentOutfitIndex, true);
this.Target.SimDescription.AddOutfit(outfit, currentOutfitCategory, currentOutfitIndex);
this.Target.RefreshCurrentOutfit(true);
this.Target.SwitchToOutfitWithoutSpin(currentOutfitCategory);
}
Back to top