| | 1 | | using System; |
| | 2 | | using System.Collections; |
| | 3 | | using UnityEngine; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | //TODO Rename to IAvatar (not now to avoid conflicts) |
| | 8 | | public interface IAvatarLODController : IDisposable |
| | 9 | | { |
| | 10 | | Player player { get; } |
| | 11 | | void SetLOD0(); |
| | 12 | | void SetLOD1(); |
| | 13 | | void SetLOD2(); |
| | 14 | | public void SetAnimationThrottling(int framesBetweenUpdates); |
| | 15 | | void SetInvisible(); |
| | 16 | | void UpdateImpostorTint(float distanceToMainPlayer); |
| | 17 | | void SetNameVisible(bool visible); |
| | 18 | | } |
| | 19 | |
|
| | 20 | | public class AvatarLODController : IAvatarLODController |
| | 21 | | { |
| 8 | 22 | | private string VISIBILITY_CONSTRAIN = "behind_camera_or_out_of_limits"; |
| 0 | 23 | | public Player player { get; } |
| | 24 | |
|
| 8 | 25 | | public AvatarLODController(Player player) |
| | 26 | | { |
| 8 | 27 | | this.player = player; |
| 8 | 28 | | if (player?.avatar == null) |
| 0 | 29 | | return; |
| 8 | 30 | | player.avatar.SetLODLevel(0); |
| 8 | 31 | | } |
| | 32 | |
|
| | 33 | | public void SetLOD0() |
| | 34 | | { |
| 3 | 35 | | if (player?.avatar == null) |
| 1 | 36 | | return; |
| | 37 | |
|
| 2 | 38 | | player.onPointerDownCollider.SetColliderEnabled(true); |
| 2 | 39 | | player.avatar.SetLODLevel(0); |
| 2 | 40 | | player.avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAIN); |
| 2 | 41 | | } |
| | 42 | |
|
| | 43 | | public void SetLOD1() |
| | 44 | | { |
| 2 | 45 | | if (player?.avatar == null) |
| 1 | 46 | | return; |
| | 47 | |
|
| 1 | 48 | | player.onPointerDownCollider.SetColliderEnabled(true); |
| 1 | 49 | | player.avatar.SetLODLevel(1); |
| 1 | 50 | | player.avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAIN); |
| 1 | 51 | | } |
| | 52 | |
|
| | 53 | | public void SetLOD2() |
| | 54 | | { |
| 2 | 55 | | if (player?.avatar == null) |
| 1 | 56 | | return; |
| | 57 | |
|
| 1 | 58 | | player.onPointerDownCollider.SetColliderEnabled(false); |
| 1 | 59 | | player.avatar.SetLODLevel(2); |
| 1 | 60 | | player.avatar.RemoveVisibilityConstrain(VISIBILITY_CONSTRAIN); |
| 1 | 61 | | } |
| | 62 | |
|
| | 63 | | public void SetInvisible() |
| | 64 | | { |
| 1 | 65 | | if (player?.avatar == null) |
| 0 | 66 | | return; |
| | 67 | |
|
| 1 | 68 | | player.avatar.AddVisibilityConstrain(VISIBILITY_CONSTRAIN); |
| 1 | 69 | | player.onPointerDownCollider.SetColliderEnabled(false); |
| 1 | 70 | | } |
| | 71 | |
|
| 0 | 72 | | public void SetAnimationThrottling(int framesBetweenUpdates) { player.avatar.SetAnimationThrottling(framesBetwee |
| | 73 | |
|
| | 74 | | public void SetNameVisible(bool visible) |
| | 75 | | { |
| 0 | 76 | | if (visible) |
| 0 | 77 | | player?.playerName.Show(); |
| | 78 | | else |
| 0 | 79 | | player?.playerName.Hide(); |
| 0 | 80 | | } |
| 0 | 81 | | public void UpdateImpostorTint(float distanceToMainPlayer) { player.avatar.SetImpostorTint(AvatarRendererHelpers |
| | 82 | |
|
| 0 | 83 | | public void Dispose() { } |
| | 84 | | } |
| | 85 | | } |