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