Skip to content
This repository has been archived by the owner on Jul 18, 2020. It is now read-only.

Commit

Permalink
Implement UMAClothingContainer.RemoveClothing
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticfall committed Dec 17, 2017
1 parent 80c8d25 commit 908149f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Assets/Alensia/Core/Item/ClothingContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void Remove(string key)
{
var cloth = CheckItem(item);

RemoveClothing(slot, cloth);
RemoveClothing(cloth);

_mappings.Remove(slot);

Expand All @@ -86,7 +86,7 @@ public void Remove(string key)

protected abstract void ApplyClothing(TItem item);

protected abstract void RemoveClothing(string key, TItem item);
protected abstract void RemoveClothing(TItem item);

private string CheckSlot(string key)
{
Expand Down
26 changes: 15 additions & 11 deletions Assets/Alensia/Integrations/UMA/UMAClothingContainer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using System.Linq;
using Alensia.Core.Character;
using Alensia.Core.Item;
using UMA;
using UMA.CharacterSystem;
using Zenject;

namespace Alensia.Integrations.UMA
Expand All @@ -12,23 +15,24 @@ public class UMAClothingContainer : ClothingContainer<UMAClothing, UMAClothingLi

protected override IRace Race => MorphSet.Race;

protected override void ApplyClothing(UMAClothing item)
protected override void ApplyClothing(UMAClothing item) =>
ProcessSlot(item, (avatar, recipe) => avatar.SetSlot(recipe));

protected override void RemoveClothing(UMAClothing item) =>
ProcessSlot(item, (avatar, recipe) => avatar.ClearSlot(recipe.wardrobeSlot));

protected void ProcessSlot(UMAClothing item, Action<DynamicCharacterAvatar, UMATextRecipe> process)
{
var umaRace = MorphSet.RaceData.raceName;
var recipe = item.Form.Recipes.FirstOrDefault(r => r.compatibleRaces.Contains(umaRace));

if (recipe != null)
{
var avatar = MorphSet.Avatar;
if (recipe == null) return;

avatar.SetSlot(recipe);
avatar.BuildCharacter();
}
}
var avatar = MorphSet.Avatar;

protected override void RemoveClothing(string key, UMAClothing item)
{
throw new System.NotImplementedException();
process(avatar, recipe);

avatar.BuildCharacter();
}
}
}

0 comments on commit 908149f

Please sign in to comment.