| | 1 | | using DCL.Controllers; |
| | 2 | | using Decentraland.Common; |
| | 3 | | using UnityEngine; |
| | 4 | | using Texture = Decentraland.Common.Texture; |
| | 5 | | using TextureWrapMode = UnityEngine.TextureWrapMode; |
| | 6 | |
|
| | 7 | | namespace DCL.ECSComponents |
| | 8 | | { |
| | 9 | | public static class Texture_Defaults |
| | 10 | | { |
| | 11 | | public static string GetTextureUrl(this TextureUnion self, IParcelScene scene) |
| | 12 | | { |
| 13 | 13 | | switch (self.TexCase) |
| | 14 | | { |
| | 15 | | case TextureUnion.TexOneofCase.AvatarTexture: |
| 1 | 16 | | return self.AvatarTexture.GetTextureUrl(); |
| | 17 | | case TextureUnion.TexOneofCase.VideoTexture: |
| 0 | 18 | | return $"{scene.sceneData.sceneNumber}{self.VideoTexture.VideoPlayerEntity}"; |
| | 19 | | case TextureUnion.TexOneofCase.Texture: |
| | 20 | | default: |
| 12 | 21 | | return self.Texture.GetTextureUrl(scene); |
| | 22 | | } |
| | 23 | | } |
| | 24 | |
|
| | 25 | | public static long GetVideoTextureId(this TextureUnion self) |
| | 26 | | { |
| 0 | 27 | | switch (self.TexCase) |
| | 28 | | { |
| | 29 | | case TextureUnion.TexOneofCase.VideoTexture: |
| 0 | 30 | | return self.VideoTexture.VideoPlayerEntity; |
| | 31 | | default: |
| 0 | 32 | | return 0; |
| | 33 | | } |
| | 34 | | } |
| | 35 | |
|
| | 36 | | public static bool IsVideoTexture(this TextureUnion self) => |
| 22 | 37 | | self.TexCase == TextureUnion.TexOneofCase.VideoTexture; |
| | 38 | |
|
| | 39 | | public static TextureWrapMode GetWrapMode(this TextureUnion self) |
| | 40 | | { |
| 13 | 41 | | switch (self.TexCase) |
| | 42 | | { |
| | 43 | | case TextureUnion.TexOneofCase.AvatarTexture: |
| 1 | 44 | | return self.AvatarTexture.GetWrapMode(); |
| | 45 | | case TextureUnion.TexOneofCase.VideoTexture: |
| 0 | 46 | | return self.VideoTexture.GetWrapMode(); |
| | 47 | | case TextureUnion.TexOneofCase.Texture: |
| | 48 | | default: |
| 12 | 49 | | return self.Texture.GetWrapMode(); |
| | 50 | | } |
| | 51 | | } |
| | 52 | |
|
| | 53 | | public static FilterMode GetFilterMode(this TextureUnion self) |
| | 54 | | { |
| 13 | 55 | | switch (self.TexCase) |
| | 56 | | { |
| | 57 | | case TextureUnion.TexOneofCase.AvatarTexture: |
| 1 | 58 | | return self.AvatarTexture.GetFilterMode(); |
| | 59 | | case TextureUnion.TexOneofCase.VideoTexture: |
| 0 | 60 | | return self.VideoTexture.GetFilterMode(); |
| | 61 | | case TextureUnion.TexOneofCase.Texture: |
| | 62 | | default: |
| 12 | 63 | | return self.Texture.GetFilterMode(); |
| | 64 | | } |
| | 65 | | } |
| | 66 | |
|
| | 67 | | public static string GetTextureUrl(this Texture self, IParcelScene scene) |
| | 68 | | { |
| 12 | 69 | | UtilsScene.TryGetMediaUrl(self.Src, scene.contentProvider, |
| | 70 | | scene.sceneData.requiredPermissions, scene.sceneData.allowedMediaHostnames, out string url); |
| | 71 | |
|
| 12 | 72 | | return url; |
| | 73 | | } |
| | 74 | |
|
| | 75 | | public static string GetTextureUrl(this AvatarTexture self) |
| | 76 | | { |
| 1 | 77 | | return KernelConfig.i.Get().avatarTextureAPIBaseUrl + self.UserId; |
| | 78 | | } |
| | 79 | |
|
| | 80 | | public static TextureWrapMode GetWrapMode(this Texture self) |
| | 81 | | { |
| 12 | 82 | | return (TextureWrapMode)(self.HasWrapMode ? self.WrapMode : Decentraland.Common.TextureWrapMode.TwmClamp); |
| | 83 | | } |
| | 84 | |
|
| | 85 | | public static TextureWrapMode GetWrapMode(this AvatarTexture self) |
| | 86 | | { |
| 1 | 87 | | return (TextureWrapMode)(self.HasWrapMode ? self.WrapMode : Decentraland.Common.TextureWrapMode.TwmClamp); |
| | 88 | | } |
| | 89 | |
|
| | 90 | | public static TextureWrapMode GetWrapMode(this VideoTexture self) |
| | 91 | | { |
| 0 | 92 | | return (TextureWrapMode)(self.HasWrapMode ? self.WrapMode : Decentraland.Common.TextureWrapMode.TwmClamp); |
| | 93 | | } |
| | 94 | |
|
| | 95 | | public static FilterMode GetFilterMode(this Texture self) |
| | 96 | | { |
| 12 | 97 | | return (FilterMode)(self.HasFilterMode ? self.FilterMode : TextureFilterMode.TfmBilinear); |
| | 98 | | } |
| | 99 | |
|
| | 100 | | public static FilterMode GetFilterMode(this AvatarTexture self) |
| | 101 | | { |
| 1 | 102 | | return (FilterMode)(self.HasFilterMode ? self.FilterMode : TextureFilterMode.TfmBilinear); |
| | 103 | | } |
| | 104 | |
|
| | 105 | | public static FilterMode GetFilterMode(this VideoTexture self) |
| | 106 | | { |
| 0 | 107 | | return (FilterMode)(self.HasFilterMode ? self.FilterMode : TextureFilterMode.TfmBilinear); |
| | 108 | | } |
| | 109 | | } |
| | 110 | | } |