| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using DCL.Controllers; |
| | 4 | | using DCL.Helpers; |
| | 5 | | using DCL.Models; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | namespace DCL.Components |
| | 9 | | { |
| | 10 | | public class AvatarAttachComponent : IEntityComponent |
| | 11 | | { |
| | 12 | | [Serializable] |
| | 13 | | public class Model : BaseModel |
| | 14 | | { |
| | 15 | | public string avatarId = null; |
| | 16 | | public int anchorPointId = 0; |
| | 17 | |
|
| | 18 | | public override BaseModel GetDataFromJSON(string json) |
| | 19 | | { |
| 0 | 20 | | return Utils.SafeFromJson<Model>(json); |
| | 21 | | } |
| | 22 | | } |
| | 23 | |
|
| 0 | 24 | | IParcelScene IComponent.scene => handler.scene; |
| 0 | 25 | | IDCLEntity IEntityComponent.entity => handler.entity; |
| | 26 | |
|
| 0 | 27 | | string IComponent.componentName => "AvatarAttach"; |
| | 28 | |
|
| 0 | 29 | | private readonly AvatarAttachHandler handler = new AvatarAttachHandler(); |
| | 30 | |
|
| | 31 | | void IEntityComponent.Initialize(IParcelScene scene, IDCLEntity entity) |
| | 32 | | { |
| 0 | 33 | | handler.Initialize(scene, entity, Environment.i.platform.updateEventHandler); |
| 0 | 34 | | } |
| | 35 | |
|
| 0 | 36 | | bool IComponent.IsValid() => true; |
| | 37 | |
|
| 0 | 38 | | BaseModel IComponent.GetModel() => handler.model; |
| | 39 | |
|
| 0 | 40 | | int IComponent.GetClassId() => (int)CLASS_ID_COMPONENT.AVATAR_ATTACH; |
| | 41 | |
|
| | 42 | | void IComponent.UpdateFromJSON(string json) |
| | 43 | | { |
| 0 | 44 | | handler.OnModelUpdated(json); |
| 0 | 45 | | } |
| | 46 | |
|
| | 47 | | void IComponent.UpdateFromModel(BaseModel newModel) |
| | 48 | | { |
| 0 | 49 | | handler.OnModelUpdated(newModel as Model); |
| 0 | 50 | | } |
| | 51 | |
|
| | 52 | | IEnumerator IComponent.ApplyChanges(BaseModel newModel) |
| | 53 | | { |
| 0 | 54 | | yield break; |
| | 55 | | } |
| | 56 | |
|
| 0 | 57 | | void IComponent.RaiseOnAppliedChanges() { } |
| | 58 | |
|
| 0 | 59 | | Transform IMonoBehaviour.GetTransform() => handler.entity?.gameObject.transform; |
| | 60 | |
|
| 0 | 61 | | void ICleanable.Cleanup() => handler.Dispose(); |
| | 62 | | } |
| | 63 | | } |