| | 1 | | using System; |
| | 2 | | using DCL; |
| | 3 | | using UnityEngine.Assertions; |
| | 4 | |
|
| | 5 | | namespace AvatarSystem |
| | 6 | | { |
| | 7 | | public class WearableLoaderFactory : IWearableLoaderFactory |
| | 8 | | { |
| | 9 | | public IWearableLoader GetWearableLoader(WearableItem item) |
| | 10 | | { |
| 0 | 11 | | if (item == null) |
| 0 | 12 | | throw new Exception("Requested a WearableLoader with a null WearableItem"); |
| | 13 | |
|
| 0 | 14 | | if (item.data.category |
| | 15 | | is WearableLiterals.Categories.BODY_SHAPE |
| | 16 | | or WearableLiterals.Categories.EYES |
| | 17 | | or WearableLiterals.Categories.EYEBROWS |
| | 18 | | or WearableLiterals.Categories.MOUTH) |
| 0 | 19 | | throw new Exception("Requested a WearableLoader with a bodyshape or facial feature"); |
| | 20 | |
|
| 0 | 21 | | return new WearableLoader(new WearableRetriever(), item); |
| | 22 | | } |
| | 23 | |
|
| | 24 | | public IBodyshapeLoader GetBodyShapeLoader(BodyWearables bodyWearables) |
| | 25 | | { |
| 0 | 26 | | if (bodyWearables.BodyShape == null) |
| 0 | 27 | | throw new Exception("Requested a BodyshapeLoader with a null Bodyshape"); |
| | 28 | |
|
| 0 | 29 | | if (bodyWearables.BodyShape.data.category != WearableLiterals.Categories.BODY_SHAPE) |
| 0 | 30 | | throw new Exception($"Bodyshape's category is not {WearableLiterals.Categories.BODY_SHAPE}"); |
| | 31 | |
|
| 0 | 32 | | if (bodyWearables.Eyes != null && bodyWearables.Eyes.data.category != WearableLiterals.Categories.EYES) |
| 0 | 33 | | throw new Exception($"Eye's category is not {WearableLiterals.Categories.EYES}"); |
| | 34 | |
|
| 0 | 35 | | if (bodyWearables.Eyebrows != null && bodyWearables.Eyebrows.data.category != WearableLiterals.Categories.EY |
| 0 | 36 | | throw new Exception($"Eyebrows's category is not {WearableLiterals.Categories.EYEBROWS}"); |
| | 37 | |
|
| 0 | 38 | | if (bodyWearables.Mouth != null && bodyWearables.Mouth.data.category != WearableLiterals.Categories.MOUTH) |
| 0 | 39 | | throw new Exception($"Mouth's category is not {WearableLiterals.Categories.MOUTH}"); |
| | 40 | |
|
| 0 | 41 | | return new BodyShapeLoader(new RetrieverFactory(), bodyWearables); |
| | 42 | | } |
| | 43 | | } |
| | 44 | | } |