diff --git a/Explorer/Assets/AddressableAssetsData/AddressableAssetSettings.asset b/Explorer/Assets/AddressableAssetsData/AddressableAssetSettings.asset index 4f2d5b3d4e..32e9258862 100644 --- a/Explorer/Assets/AddressableAssetsData/AddressableAssetSettings.asset +++ b/Explorer/Assets/AddressableAssetsData/AddressableAssetSettings.asset @@ -15,7 +15,7 @@ MonoBehaviour: m_DefaultGroup: 47f803e1e9c5079449bd106df98a0b7d m_currentHash: serializedVersion: 2 - Hash: 929bc0a851082190651830d8f45eaaca + Hash: c5b9b16724d7315a9b37da69c2735fae m_OptimizeCatalogSize: 0 m_BuildRemoteCatalog: 0 m_BundleLocalCatalog: 0 @@ -50,6 +50,7 @@ MonoBehaviour: - {fileID: 11400000, guid: dfcf8d697a676564cba6e67051b21967, type: 2} - {fileID: 11400000, guid: 16f521477e6564a958075901ccb95f7e, type: 2} - {fileID: 11400000, guid: 87f4a5efef76fa14488910f4e8acdd53, type: 2} + - {fileID: 11400000, guid: c78cdb3c90e791745af8cc89892b1a81, type: 2} - {fileID: 11400000, guid: cbb0d807e72e1ce45af9fa353aed05ba, type: 2} - {fileID: 11400000, guid: e0f0f2d4ff3471c44953d71c1c51b7b7, type: 2} - {fileID: 11400000, guid: 908e3bc21ce6079428d027b3d8b69cd0, type: 2} @@ -63,6 +64,7 @@ MonoBehaviour: - {fileID: 11400000, guid: 65ec81046e8d04372a28e44540e14a9d, type: 2} - {fileID: 11400000, guid: f230ff8ddb68e6342a84ce4b5bf941a5, type: 2} - {fileID: 11400000, guid: a979db80e679cae4da503a3cfd0a3a11, type: 2} + - {fileID: 11400000, guid: 74b57aba17f2b264bb568f41300fc460, type: 2} m_BuildSettings: m_CompileScriptsInVirtualMode: 0 m_CleanupStreamingAssetsAfterBuilds: 1 diff --git a/Explorer/Assets/AddressableAssetsData/AssetGroups/Essentials.asset b/Explorer/Assets/AddressableAssetsData/AssetGroups/Essentials.asset index a607a39bc4..896a8104c4 100644 --- a/Explorer/Assets/AddressableAssetsData/AssetGroups/Essentials.asset +++ b/Explorer/Assets/AddressableAssetsData/AssetGroups/Essentials.asset @@ -147,6 +147,11 @@ MonoBehaviour: m_ReadOnly: 0 m_SerializedLabels: [] FlaggedDuringContentUpdateRestriction: 0 + - m_GUID: 52c856180dc5d6447b902f06d38f4161 + m_Address: LightSourceDefaults + m_ReadOnly: 0 + m_SerializedLabels: [] + FlaggedDuringContentUpdateRestriction: 0 - m_GUID: 53b70d09c4a814878a30c68582ad4523 m_Address: Assets/DCL/MapRenderer/Addressables/HotUserMarkerObject.prefab m_ReadOnly: 0 @@ -277,6 +282,11 @@ MonoBehaviour: m_ReadOnly: 0 m_SerializedLabels: [] FlaggedDuringContentUpdateRestriction: 0 + - m_GUID: 7f09a2d0d9adc4e43b67879ab9cdf360 + m_Address: LightSourcePrefab + m_ReadOnly: 0 + m_SerializedLabels: [] + FlaggedDuringContentUpdateRestriction: 0 - m_GUID: 86bf0204cf3bb75429342452a2a460af m_Address: Assets/DCL/Landscape/Data/ParcelData.asset m_ReadOnly: 0 diff --git a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs index 0cfc19d7d4..cfc4c7f553 100644 --- a/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs +++ b/Explorer/Assets/DCL/PerformanceAndDiagnostics/Diagnostics/ReportsHandling/ReportCategory.cs @@ -301,5 +301,7 @@ public static class ReportCategory public const string FRIENDS = nameof(FRIENDS); public const string DISK_CACHE = nameof(DISK_CACHE); + + public const string LIGHT_SOURCE = nameof(LIGHT_SOURCE); } } diff --git a/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef b/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef index 3771d3ae81..d2c86ac3d8 100644 --- a/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef +++ b/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef @@ -154,7 +154,8 @@ "GUID:e9db755bba99425db4ca5d30e48b7429", "GUID:5462d37de7d4344df8aade58a45b403e", "GUID:f3634757d00dab2429c6c11e69404e97", - "GUID:09c5cab4669b047398fa5d42a2f64f5b" + "GUID:09c5cab4669b047398fa5d42a2f64f5b", + "GUID:07fae1aaf8481a840a6165058ced43aa" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs b/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs new file mode 100644 index 0000000000..18b82efbec --- /dev/null +++ b/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs @@ -0,0 +1,100 @@ +using Arch.SystemGroups; +using CrdtEcsBridge.Components.Conversion; +using Cysharp.Threading.Tasks; +using DCL.AssetsProvision; +using DCL.ECSComponents; +using DCL.Optimization.Pools; +using DCL.PluginSystem.World.Dependencies; +using DCL.ResourcesUnloading; +using DCL.SDKComponents.LightSource; +using DCL.SDKComponents.LightSource.Systems; +using ECS.LifeCycle; +using ECS.LifeCycle.Systems; +using System; +using System.Collections.Generic; +using System.Threading; +using Unity.Mathematics; +using UnityEngine; +using UnityEngine.AddressableAssets; +using Object = UnityEngine.Object; + +namespace DCL.PluginSystem.World +{ + public class LightSourcePlugin : IDCLWorldPlugin + { + private static LightSourceDefaults lightSourceDefaults; + private readonly IComponentPoolsRegistry poolsRegistry; + private readonly IAssetsProvisioner assetsProvisioner; + private readonly CacheCleaner cacheCleaner; + private IComponentPool? lightPoolRegistry; + + public LightSourcePlugin( + IComponentPoolsRegistry poolsRegistry, + IAssetsProvisioner assetsProvisioner, + CacheCleaner cacheCleaner) + { + this.assetsProvisioner = assetsProvisioner; + this.poolsRegistry = poolsRegistry; + this.cacheCleaner = cacheCleaner; + } + + public void Dispose() { } + + public void InjectToWorld(ref ArchSystemsWorldBuilder builder, in ECSWorldInstanceSharedDependencies sharedDependencies, in PersistentEntities persistentEntities, List finalizeWorldSystems, List sceneIsCurrentListeners) + { + finalizeWorldSystems.Add(LightSourceSystem.InjectToWorld( + ref builder, + sharedDependencies.SceneData, + sharedDependencies.SceneStateProvider, + sharedDependencies.ScenePartition, + lightPoolRegistry + )); + + ResetDirtyFlagSystem.InjectToWorld(ref builder); + } + + public async UniTask InitializeAsync(LightSourceSettings settings, CancellationToken ct) => + await CreateLightSourcePoolAsync(settings, ct); + + private async UniTask CreateLightSourcePoolAsync(LightSourceSettings settings, CancellationToken ct) + { + lightSourceDefaults = (await assetsProvisioner.ProvideMainAssetAsync(settings.LightSourceDefaultValues, ct: ct)).Value; + Light light = (await assetsProvisioner.ProvideMainAssetAsync(settings.LightSourcePrefab, ct: ct)).Value.GetComponent(); + lightPoolRegistry = poolsRegistry.AddGameObjectPool(() => Object.Instantiate(light, Vector3.zero, quaternion.identity), onRelease: OnPoolRelease, onGet: OnPoolGet); + cacheCleaner.Register(lightPoolRegistry); + } + + private static void OnPoolRelease(Light light) => + light.enabled = false; + + private static void OnPoolGet(Light light) + { + light.enabled = lightSourceDefaults.active; + light.transform.SetParent(null); + light.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); + light.color = lightSourceDefaults.color; + light.intensity = PrimitivesConversionExtensions.PBBrightnessInLumensToUnityCandels(lightSourceDefaults.brightness); + light.range = lightSourceDefaults.range; + light.type = LightType.Spot; + light.shadows = LightShadows.None; + light.innerSpotAngle = lightSourceDefaults.innerAngle; + light.spotAngle = lightSourceDefaults.outerAngle; + light.cookie = null; + } + + public struct LightSourceSettings : IDCLPluginSettings + { + [field: SerializeField] + public AssetReferenceGameObject LightSourcePrefab; + + [field: SerializeField] + public LightDefaultsRef LightSourceDefaultValues; + + [Serializable] + public class LightDefaultsRef : AssetReferenceT + { + public LightDefaultsRef(string guid) : base(guid) { } + } + } + } +} diff --git a/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs.meta b/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs.meta new file mode 100644 index 0000000000..4c86888a09 --- /dev/null +++ b/Explorer/Assets/DCL/PluginSystem/World/LightSourcePlugin.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 775c934fa7d449e3943275225b77eeff +timeCreated: 1736944314 \ No newline at end of file diff --git a/Explorer/Assets/DCL/PluginSystem/World/World Plugins Container.asset b/Explorer/Assets/DCL/PluginSystem/World/World Plugins Container.asset index dd07abfe97..384a9358db 100644 --- a/Explorer/Assets/DCL/PluginSystem/World/World Plugins Container.asset +++ b/Explorer/Assets/DCL/PluginSystem/World/World Plugins Container.asset @@ -27,7 +27,8 @@ MonoBehaviour: - rid: 7615904969758605314 - rid: 634089542387236867 - rid: 1970080267461197826 - - rid: 5734404086669770757 + - rid: 3414978285727645698 + - rid: 3414978285727645699 references: version: 2 RefIds: @@ -154,14 +155,30 @@ MonoBehaviour: m_SubObjectName: m_SubObjectType: m_EditorAssetChanged: 0 - - rid: 4753057106328551424 - type: {class: SceneUIPlugin/Settings, ns: DCL.PluginSystem.World, asm: DCL.Plugins} + - rid: 3414978285727645698 + type: {class: PointerInputAudioPlugin/Settings, ns: DCL.PluginSystem.Global, asm: DCL.Plugins} data: - k__BackingField: - m_AssetGUID: e0f5a4ab5d8f74640ae94adb6824bd45 + k__BackingField: + m_AssetGUID: cbb820cf51b7a714e88a7c873eb5de9c + m_SubObjectName: + m_SubObjectType: + m_EditorAssetChanged: 0 + - rid: 3414978285727645699 + type: {class: LightSourcePlugin/LightSourceSettings, ns: DCL.PluginSystem.World, asm: DCL.Plugins} + data: + LightSourcePrefab: + m_AssetGUID: 7f09a2d0d9adc4e43b67879ab9cdf360 + m_SubObjectName: + m_SubObjectType: + m_EditorAssetChanged: 0 + LightSourceDefaultValues: + m_AssetGUID: 52c856180dc5d6447b902f06d38f4161 m_SubObjectName: m_SubObjectType: m_EditorAssetChanged: 0 + - rid: 4753057106328551424 + type: {class: SceneUIPlugin/Settings, ns: DCL.PluginSystem.World, asm: DCL.Plugins} + data: k__BackingField: m_AssetGUID: 295cf8ad8d171d849863eccaf581c9e7 m_SubObjectName: @@ -180,14 +197,6 @@ MonoBehaviour: m_SubObjectName: m_SubObjectType: m_EditorAssetChanged: 0 - - rid: 5734404086669770757 - type: {class: PointerInputAudioPlugin/Settings, ns: DCL.PluginSystem.Global, asm: DCL.Plugins} - data: - k__BackingField: - m_AssetGUID: cbb820cf51b7a714e88a7c873eb5de9c - m_SubObjectName: - m_SubObjectType: - m_EditorAssetChanged: 0 - rid: 6784895267130048515 type: {class: MaterialsPlugin/Settings, ns: DCL.PluginSystem.World, asm: DCL.Plugins} data: diff --git a/Explorer/Assets/DCL/RealmNavigation/Container/RealmNavigationContainer.cs.meta b/Explorer/Assets/DCL/RealmNavigation/Container/RealmNavigationContainer.cs.meta index 2401086b6f..08634b5749 100644 --- a/Explorer/Assets/DCL/RealmNavigation/Container/RealmNavigationContainer.cs.meta +++ b/Explorer/Assets/DCL/RealmNavigation/Container/RealmNavigationContainer.cs.meta @@ -1,5 +1,9 @@ fileFormatVersion: 2 +<<<<<<<< HEAD:Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs.meta +guid: 9368a24dda5bef84b8569eef12eba119 +======== guid: 2b43bac7a50418643bfe4c92df43201d +>>>>>>>> dev:Explorer/Assets/DCL/RealmNavigation/Container/RealmNavigationContainer.cs.meta MonoImporter: externalObjects: {} serializedVersion: 2 diff --git a/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef b/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef index 5773e70fba..0523aaa05b 100644 --- a/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef +++ b/Explorer/Assets/DCL/SDKComponents/DCL.SDKComponents.asmdef @@ -27,7 +27,8 @@ "GUID:1300820cd310d4584b09afde765bdd16", "GUID:5ab29fa8ae5769b49ab29e390caca7a4", "GUID:ca4e81cdd6a34d1aa54c32ad41fc5b3b", - "GUID:5eabe9a3d4dd19d42a16208ea5411062" + "GUID:5eabe9a3d4dd19d42a16208ea5411062", + "GUID:0d87731a01a547bd97421cb01c596850" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource.meta b/Explorer/Assets/DCL/SDKComponents/LightSource.meta new file mode 100644 index 0000000000..fa77c49818 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: ae9c0e7273354104afc114a1e374004a +timeCreated: 1736802896 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Components.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Components.meta new file mode 100644 index 0000000000..ec8c1f2cb1 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Components.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 0eec56155fdb425f93bd5a56f64993a2 +timeCreated: 1736804365 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceComponent.cs b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceComponent.cs new file mode 100644 index 0000000000..553e57cd37 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceComponent.cs @@ -0,0 +1,17 @@ +using UnityEngine; +using Promise = ECS.StreamableLoading.Common.AssetPromise; + +namespace DCL.SDKComponents.LightSource +{ + public struct LightSourceComponent + { + public readonly Light lightSourceInstance; + public Promise? TextureMaskPromise; + + public LightSourceComponent(Light lightSourceInstance) + { + this.lightSourceInstance = lightSourceInstance; + TextureMaskPromise = null; + } + } +} diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceComponent.cs.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceComponent.cs.meta new file mode 100644 index 0000000000..df3ad1a83b --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceComponent.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 419ed356a4ed42eab142bb108498f88a +timeCreated: 1736802929 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceDefaults.cs b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceDefaults.cs new file mode 100644 index 0000000000..b0806398bc --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceDefaults.cs @@ -0,0 +1,26 @@ +using DCL.ECSComponents; +using System; +using UnityEngine; + +namespace DCL.SDKComponents.LightSource +{ + [CreateAssetMenu(fileName = "LightSourceDefaults", menuName = "DCL/LightSource/LightSource Default Settings", order = 1)] + [Serializable] + public class LightSourceDefaults : ScriptableObject + { + // I'll update the url when the protocol PR is merged + [Header("These values come from the protocol definition \nfound here: https://github.com/decentraland/protocol/pull/234")] + public bool active; + public Color color; + public float brightness; + public float range; + + [Header("Point Settings")] + public PBLightSource.Types.ShadowType pointShadowType; + + [Header("Spot Settings")] + public PBLightSource.Types.ShadowType spotShadowType; + public float innerAngle; + public float outerAngle; + } +} diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceDefaults.cs.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceDefaults.cs.meta new file mode 100644 index 0000000000..3a6e3108ca --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Components/LightSourceDefaults.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3f88d85d4a404487b6d1d67e6a3b6a09 +timeCreated: 1738353664 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/LightSource.asmdef b/Explorer/Assets/DCL/SDKComponents/LightSource/LightSource.asmdef new file mode 100644 index 0000000000..c6eafeaf01 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/LightSource.asmdef @@ -0,0 +1,23 @@ +{ + "name": "LightSource", + "rootNamespace": "", + "references": [ + "GUID:1b8e1e1bd01505f478f0369c04a4fb2f", + "GUID:4794e238ed0f65142a4aea5848b513e5", + "GUID:3640f3c0b42946b0b8794a1ed8e06ca5", + "GUID:286980af24684da6acc1caa413039811", + "GUID:3c7b57a14671040bd8c549056adc04f5", + "GUID:d414ef88f3b15f746a4b97636b50dfb4", + "GUID:0d87731a01a547bd97421cb01c596850", + "GUID:275e22790c04e9b47a5085d7b0c4432a" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/LightSource.asmdef.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/LightSource.asmdef.meta new file mode 100644 index 0000000000..dd92363c41 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/LightSource.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 07fae1aaf8481a840a6165058ced43aa +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab.meta new file mode 100644 index 0000000000..24143f21ae --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7097847187ff25f41a4c2faf3928b8f2 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourceDefaults.asset b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourceDefaults.asset new file mode 100644 index 0000000000..06e995831b --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourceDefaults.asset @@ -0,0 +1,22 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3f88d85d4a404487b6d1d67e6a3b6a09, type: 3} + m_Name: LightSourceDefaults + m_EditorClassIdentifier: + active: 1 + color: {r: 1, g: 1, b: 1, a: 1} + brightness: 250 + range: 10 + pointShadowType: 0 + spotShadowType: 0 + innerAngle: 21.8 + outerAngle: 30 diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourceDefaults.asset.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourceDefaults.asset.meta new file mode 100644 index 0000000000..56d6e4efcd --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourceDefaults.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 52c856180dc5d6447b902f06d38f4161 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 11400000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourcePrefab.prefab b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourcePrefab.prefab new file mode 100644 index 0000000000..c4fcefcc1e --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourcePrefab.prefab @@ -0,0 +1,120 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &6702869395793157098 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5232691481928228032} + - component: {fileID: 3601112764250369252} + - component: {fileID: 9216909418390168617} + m_Layer: 0 + m_Name: LightSourcePrefab + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5232691481928228032 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6702869395793157098} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!108 &3601112764250369252 +Light: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6702869395793157098} + m_Enabled: 1 + serializedVersion: 10 + m_Type: 0 + m_Shape: 0 + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_Intensity: 1 + m_Range: 10 + m_SpotAngle: 30 + m_InnerSpotAngle: 21.80208 + m_CookieSize: 10 + m_Shadows: + m_Type: 0 + m_Resolution: -1 + m_CustomResolution: -1 + m_Strength: 1 + m_Bias: 0.05 + m_NormalBias: 0.4 + m_NearPlane: 0.2 + m_CullingMatrixOverride: + e00: 1 + e01: 0 + e02: 0 + e03: 0 + e10: 0 + e11: 1 + e12: 0 + e13: 0 + e20: 0 + e21: 0 + e22: 1 + e23: 0 + e30: 0 + e31: 0 + e32: 0 + e33: 1 + m_UseCullingMatrixOverride: 0 + m_Cookie: {fileID: 0} + m_DrawHalo: 0 + m_Flare: {fileID: 0} + m_RenderMode: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingLayerMask: 1 + m_Lightmapping: 4 + m_LightShadowCasterMode: 0 + m_AreaSize: {x: 1, y: 1} + m_BounceIntensity: 1 + m_ColorTemperature: 6570 + m_UseColorTemperature: 0 + m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0} + m_UseBoundingSphereOverride: 0 + m_UseViewFrustumForShadowCasterCull: 1 + m_ShadowRadius: 0 + m_ShadowAngle: 0 +--- !u!114 &9216909418390168617 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6702869395793157098} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 474bcb49853aa07438625e644c072ee6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Version: 3 + m_UsePipelineSettings: 1 + m_AdditionalLightsShadowResolutionTier: 2 + m_LightLayerMask: 1 + m_RenderingLayers: 1 + m_CustomShadowLayers: 0 + m_ShadowLayerMask: 1 + m_ShadowRenderingLayers: 1 + m_LightCookieSize: {x: 1, y: 1} + m_LightCookieOffset: {x: 0, y: 0} + m_SoftShadowQuality: 0 diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourcePrefab.prefab.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourcePrefab.prefab.meta new file mode 100644 index 0000000000..8def03a8fc --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Prefab/LightSourcePrefab.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 7f09a2d0d9adc4e43b67879ab9cdf360 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Systems.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Systems.meta new file mode 100644 index 0000000000..bbcab04ae4 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Systems.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 8a30e9c692374384a68988d4ffd69440 +timeCreated: 1736804530 \ No newline at end of file diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Systems/LightSourceSystem.cs b/Explorer/Assets/DCL/SDKComponents/LightSource/Systems/LightSourceSystem.cs new file mode 100644 index 0000000000..b80d3c03cd --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Systems/LightSourceSystem.cs @@ -0,0 +1,194 @@ +using Arch.Core; +using Arch.System; +using Arch.SystemGroups; +using CrdtEcsBridge.Components.Conversion; +using DCL.Diagnostics; +using DCL.ECSComponents; +using DCL.Optimization.Pools; +using DCL.SDKComponents.Utils; +using ECS.Abstract; +using ECS.LifeCycle; +using ECS.Prioritization.Components; +using ECS.StreamableLoading.Cache; +using ECS.StreamableLoading.Common.Components; +using ECS.StreamableLoading.Textures; +using ECS.Unity.ColorComponent; +using ECS.Unity.Groups; +using ECS.Unity.Textures.Components; +using ECS.Unity.Textures.Components.Extensions; +using ECS.Unity.Transforms.Components; +using SceneRunner.Scene; +using UnityEngine; +using Promise = ECS.StreamableLoading.Common.AssetPromise; + +namespace DCL.SDKComponents.LightSource.Systems +{ + [UpdateInGroup(typeof(ComponentInstantiationGroup))] + [LogCategory(ReportCategory.LIGHT_SOURCE)] + public partial class LightSourceSystem : BaseUnityLoopSystem, IFinalizeWorldSystem + { + private const int ATTEMPTS_COUNT = 6; + + private readonly IPartitionComponent partitionComponent; + private readonly IComponentPool poolRegistry; + private readonly ISceneStateProvider sceneStateProvider; + private readonly ISceneData sceneData; + + public LightSourceSystem(World world, + ISceneData sceneData, + ISceneStateProvider sceneStateProvider, + IPartitionComponent partitionComponent, + IComponentPool poolRegistry + ) : base(world) + { + this.partitionComponent = partitionComponent; + this.sceneData = sceneData; + this.poolRegistry = poolRegistry; + this.sceneStateProvider = sceneStateProvider; + } + + protected override void Update(float t) + { + CreateLightSourceComponentQuery(World); + UpdateLightSourceQuery(World); + ResolveTexturePromiseQuery(World); + } + + [Query] + [All(typeof(PBLightSource))] + [None(typeof(LightSourceComponent))] + private void CreateLightSourceComponent(in Entity entity, ref PBLightSource pbLightSource, in TransformComponent transform) + { + if (!sceneStateProvider.IsCurrent) return; + if (pbLightSource.TypeCase == PBLightSource.TypeOneofCase.None) return; + + Light lightSourceInstance = poolRegistry.Get(); + + lightSourceInstance.transform.SetParent(transform.Transform, false); + lightSourceInstance.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity); + lightSourceInstance.transform.localScale = Vector3.one; + + var lightSourceComponent = new LightSourceComponent(lightSourceInstance); + pbLightSource.IsDirty = true; + World.Add(entity, lightSourceComponent); + } + + [Query] + private void UpdateLightSource(ref LightSourceComponent lightSourceComponent, in PBLightSource pbLightSource) + { + if (!sceneStateProvider.IsCurrent) return; + if (!pbLightSource.IsDirty) return; + if (pbLightSource.TypeCase == PBLightSource.TypeOneofCase.None) return; + + Light lightSourceInstance = lightSourceComponent.lightSourceInstance; + + bool isActive = !pbLightSource.HasActive || pbLightSource.Active; + + // No need to set anything if the component is not active + if (!isActive) + { + lightSourceInstance.enabled = false; + return; + } + + bool isSpot = pbLightSource.TypeCase == PBLightSource.TypeOneofCase.Spot; + + lightSourceInstance.type = isSpot ? LightType.Spot : LightType.Point; + + lightSourceInstance.color = pbLightSource.Color.ToUnityColor(); + + if (pbLightSource.HasBrightness) + lightSourceInstance.intensity = PrimitivesConversionExtensions.PBBrightnessInLumensToUnityCandels(pbLightSource.Brightness); + + if (pbLightSource.HasRange) + lightSourceInstance.range = pbLightSource.Range; + + if (isSpot) + { + if (pbLightSource.Spot.HasShadow) + lightSourceInstance.shadows = PrimitivesConversionExtensions.PBLightSourceShadowToUnityLightShadow(pbLightSource.Spot.Shadow); + + if (pbLightSource.Spot.HasInnerAngle) + lightSourceInstance.innerSpotAngle = pbLightSource.Spot.InnerAngle; + + if (pbLightSource.Spot.HasOuterAngle) + lightSourceInstance.spotAngle = pbLightSource.Spot.OuterAngle; + + bool usesShadowMask = pbLightSource.Spot.ShadowMaskTexture is { Texture: { Src: var s } } && !string.IsNullOrWhiteSpace(s); + + if (usesShadowMask) + { + TextureComponent? shadowTexture = pbLightSource.Spot.ShadowMaskTexture.CreateTextureComponent(sceneData); + TryCreateGetTexturePromise(in shadowTexture, ref lightSourceComponent.TextureMaskPromise); + } + else + { + lightSourceInstance.cookie = null; + } + } + else { lightSourceInstance.shadows = PrimitivesConversionExtensions.PBLightSourceShadowToUnityLightShadow(pbLightSource.Point.Shadow); } + + lightSourceInstance.enabled = true; + } + + private bool TryCreateGetTexturePromise(in TextureComponent? textureComponent, ref Promise? promise) + { + if (textureComponent == null) + return false; + + TextureComponent textureComponentValue = textureComponent.Value; + + if (TextureComponentUtils.Equals(ref textureComponentValue, ref promise)) + return false; + + DereferenceTexture(ref promise); + + promise = Promise.Create( + World, + new GetTextureIntention( + textureComponentValue.Src, + textureComponentValue.FileHash, + textureComponentValue.WrapMode, + textureComponentValue.FilterMode, + textureComponentValue.TextureType, + attemptsCount: ATTEMPTS_COUNT + ), + partitionComponent + ); + + return true; + } + + [Query] + private void ResolveTexturePromise(in Entity entity, ref LightSourceComponent lightSourceComponent) + { + if (lightSourceComponent.TextureMaskPromise is null || lightSourceComponent.TextureMaskPromise.Value.IsConsumed) return; + + if (lightSourceComponent.TextureMaskPromise.Value.TryConsume(World, out StreamableLoadingResult texture)) + { + lightSourceComponent.TextureMaskPromise = null; + lightSourceComponent.lightSourceInstance.cookie = texture.Asset; + } + } + + private void DereferenceTexture(ref Promise? promise) + { + if (promise == null) + return; + + Promise promiseValue = promise.Value; + promiseValue.TryDereference(World); + } + + [Query] + private void FinalizeLightSourceComponents(in LightSourceComponent lightSourceComponent) + { + poolRegistry.Release(lightSourceComponent.lightSourceInstance); + } + + public void FinalizeComponents(in Query query) + { + FinalizeLightSourceComponentsQuery(World); + } + } +} diff --git a/Explorer/Assets/DCL/SDKComponents/LightSource/Systems/LightSourceSystem.cs.meta b/Explorer/Assets/DCL/SDKComponents/LightSource/Systems/LightSourceSystem.cs.meta new file mode 100644 index 0000000000..62ff42aa31 --- /dev/null +++ b/Explorer/Assets/DCL/SDKComponents/LightSource/Systems/LightSourceSystem.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6fbfe8657dde4cae8c7b834f90117538 +timeCreated: 1736804543 \ No newline at end of file diff --git a/Explorer/Assets/Protocol/DecentralandProtocol/ComponentID.gen.cs b/Explorer/Assets/Protocol/DecentralandProtocol/ComponentID.gen.cs index 8c7156f386..af61cb79e0 100644 --- a/Explorer/Assets/Protocol/DecentralandProtocol/ComponentID.gen.cs +++ b/Explorer/Assets/Protocol/DecentralandProtocol/ComponentID.gen.cs @@ -33,6 +33,7 @@ public static class ComponentID public const int MAIN_CAMERA = 1075; public const int VIRTUAL_CAMERA = 1076; public const int INPUT_MODIFIER = 1078; + public const int LIGHT_SOURCE = 1079; public const int AVATAR_SHAPE = 1080; public const int VISIBILITY_COMPONENT = 1081; public const int AVATAR_BASE = 1087; diff --git a/Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs b/Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs new file mode 100644 index 0000000000..0595d667fd --- /dev/null +++ b/Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs @@ -0,0 +1,1150 @@ +// +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: decentraland/sdk/components/light_source.proto +// +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace DCL.ECSComponents { + + /// Holder for reflection information generated from decentraland/sdk/components/light_source.proto + public static partial class LightSourceReflection { + + #region Descriptor + /// File descriptor for decentraland/sdk/components/light_source.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static LightSourceReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ci5kZWNlbnRyYWxhbmQvc2RrL2NvbXBvbmVudHMvbGlnaHRfc291cmNlLnBy", + "b3RvEhtkZWNlbnRyYWxhbmQuc2RrLmNvbXBvbmVudHMaIGRlY2VudHJhbGFu", + "ZC9jb21tb24vY29sb3JzLnByb3RvGiFkZWNlbnRyYWxhbmQvY29tbW9uL3Rl", + "eHR1cmUucHJvdG8i4gUKDVBCTGlnaHRTb3VyY2USEwoGYWN0aXZlGAQgASgI", + "SAGIAQESLwoFY29sb3IYASABKAsyGy5kZWNlbnRyYWxhbmQuY29tbW9uLkNv", + "bG9yM0gCiAEBEhcKCmJyaWdodG5lc3MYAiABKAJIA4gBARISCgVyYW5nZRgD", + "IAEoAkgEiAEBEkEKBXBvaW50GAYgASgLMjAuZGVjZW50cmFsYW5kLnNkay5j", + "b21wb25lbnRzLlBCTGlnaHRTb3VyY2UuUG9pbnRIABI/CgRzcG90GAcgASgL", + "Mi8uZGVjZW50cmFsYW5kLnNkay5jb21wb25lbnRzLlBCTGlnaHRTb3VyY2Uu", + "U3BvdEgAGl4KBVBvaW50EkoKBnNoYWRvdxgFIAEoDjI1LmRlY2VudHJhbGFu", + "ZC5zZGsuY29tcG9uZW50cy5QQkxpZ2h0U291cmNlLlNoYWRvd1R5cGVIAIgB", + "AUIJCgdfc2hhZG93Go4CCgRTcG90EhgKC2lubmVyX2FuZ2xlGAEgASgCSACI", + "AQESGAoLb3V0ZXJfYW5nbGUYAiABKAJIAYgBARJKCgZzaGFkb3cYBSABKA4y", + "NS5kZWNlbnRyYWxhbmQuc2RrLmNvbXBvbmVudHMuUEJMaWdodFNvdXJjZS5T", + "aGFkb3dUeXBlSAKIAQESQwoTc2hhZG93X21hc2tfdGV4dHVyZRgIIAEoCzIh", + "LmRlY2VudHJhbGFuZC5jb21tb24uVGV4dHVyZVVuaW9uSAOIAQFCDgoMX2lu", + "bmVyX2FuZ2xlQg4KDF9vdXRlcl9hbmdsZUIJCgdfc2hhZG93QhYKFF9zaGFk", + "b3dfbWFza190ZXh0dXJlIjMKClNoYWRvd1R5cGUSCwoHU1RfTk9ORRAAEgsK", + "B1NUX1NPRlQQARILCgdTVF9IQVJEEAJCBgoEdHlwZUIJCgdfYWN0aXZlQggK", + "Bl9jb2xvckINCgtfYnJpZ2h0bmVzc0IICgZfcmFuZ2VCFKoCEURDTC5FQ1ND", + "b21wb25lbnRzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Decentraland.Common.ColorsReflection.Descriptor, global::Decentraland.Common.TextureReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBLightSource), global::DCL.ECSComponents.PBLightSource.Parser, new[]{ "Active", "Color", "Brightness", "Range", "Point", "Spot" }, new[]{ "Type", "Active", "Color", "Brightness", "Range" }, new[]{ typeof(global::DCL.ECSComponents.PBLightSource.Types.ShadowType) }, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBLightSource.Types.Point), global::DCL.ECSComponents.PBLightSource.Types.Point.Parser, new[]{ "Shadow" }, new[]{ "Shadow" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::DCL.ECSComponents.PBLightSource.Types.Spot), global::DCL.ECSComponents.PBLightSource.Types.Spot.Parser, new[]{ "InnerAngle", "OuterAngle", "Shadow", "ShadowMaskTexture" }, new[]{ "InnerAngle", "OuterAngle", "Shadow", "ShadowMaskTexture" }, null, null, null)}) + })); + } + #endregion + + } + #region Messages + public sealed partial class PBLightSource : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PBLightSource()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::DCL.ECSComponents.LightSourceReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public PBLightSource() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public PBLightSource(PBLightSource other) : this() { + _hasBits0 = other._hasBits0; + active_ = other.active_; + color_ = other.color_ != null ? other.color_.Clone() : null; + brightness_ = other.brightness_; + range_ = other.range_; + switch (other.TypeCase) { + case TypeOneofCase.Point: + Point = other.Point.Clone(); + break; + case TypeOneofCase.Spot: + Spot = other.Spot.Clone(); + break; + } + + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public PBLightSource Clone() { + return new PBLightSource(this); + } + + /// Field number for the "active" field. + public const int ActiveFieldNumber = 4; + private bool active_; + /// + /// default = true, whether the lightSource is active or not. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Active { + get { if ((_hasBits0 & 4) != 0) { return active_; } else { return false; } } + set { + _hasBits0 |= 4; + active_ = value; + } + } + /// Gets whether the "active" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasActive { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "active" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearActive() { + _hasBits0 &= ~4; + } + + /// Field number for the "color" field. + public const int ColorFieldNumber = 1; + private global::Decentraland.Common.Color3 color_; + /// + /// default = Color.white, the tint of the light, in RGB format where each component is a floating point value with a range from 0 to 1. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Decentraland.Common.Color3 Color { + get { return color_; } + set { + color_ = value; + } + } + + /// Field number for the "brightness" field. + public const int BrightnessFieldNumber = 2; + private float brightness_; + /// + /// default = 250, ranges from 1 (dim) to 100,000 (very bright), expressed in Lumens for Point and Spot. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public float Brightness { + get { if ((_hasBits0 & 1) != 0) { return brightness_; } else { return 0F; } } + set { + _hasBits0 |= 1; + brightness_ = value; + } + } + /// Gets whether the "brightness" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasBrightness { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "brightness" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearBrightness() { + _hasBits0 &= ~1; + } + + /// Field number for the "range" field. + public const int RangeFieldNumber = 3; + private float range_; + /// + /// default = 10, how far the light travels, expressed in meters. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public float Range { + get { if ((_hasBits0 & 2) != 0) { return range_; } else { return 0F; } } + set { + _hasBits0 |= 2; + range_ = value; + } + } + /// Gets whether the "range" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasRange { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "range" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearRange() { + _hasBits0 &= ~2; + } + + /// Field number for the "point" field. + public const int PointFieldNumber = 6; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::DCL.ECSComponents.PBLightSource.Types.Point Point { + get { return typeCase_ == TypeOneofCase.Point ? (global::DCL.ECSComponents.PBLightSource.Types.Point) type_ : null; } + set { + type_ = value; + typeCase_ = value == null ? TypeOneofCase.None : TypeOneofCase.Point; + } + } + + /// Field number for the "spot" field. + public const int SpotFieldNumber = 7; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::DCL.ECSComponents.PBLightSource.Types.Spot Spot { + get { return typeCase_ == TypeOneofCase.Spot ? (global::DCL.ECSComponents.PBLightSource.Types.Spot) type_ : null; } + set { + type_ = value; + typeCase_ = value == null ? TypeOneofCase.None : TypeOneofCase.Spot; + } + } + + private object type_; + /// Enum of possible cases for the "type" oneof. + public enum TypeOneofCase { + None = 0, + Point = 6, + Spot = 7, + } + private TypeOneofCase typeCase_ = TypeOneofCase.None; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public TypeOneofCase TypeCase { + get { return typeCase_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearType() { + typeCase_ = TypeOneofCase.None; + type_ = null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as PBLightSource); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(PBLightSource other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Active != other.Active) return false; + if (!object.Equals(Color, other.Color)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(Brightness, other.Brightness)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(Range, other.Range)) return false; + if (!object.Equals(Point, other.Point)) return false; + if (!object.Equals(Spot, other.Spot)) return false; + if (TypeCase != other.TypeCase) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (HasActive) hash ^= Active.GetHashCode(); + if (color_ != null) hash ^= Color.GetHashCode(); + if (HasBrightness) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Brightness); + if (HasRange) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Range); + if (typeCase_ == TypeOneofCase.Point) hash ^= Point.GetHashCode(); + if (typeCase_ == TypeOneofCase.Spot) hash ^= Spot.GetHashCode(); + hash ^= (int) typeCase_; + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (color_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Color); + } + if (HasBrightness) { + output.WriteRawTag(21); + output.WriteFloat(Brightness); + } + if (HasRange) { + output.WriteRawTag(29); + output.WriteFloat(Range); + } + if (HasActive) { + output.WriteRawTag(32); + output.WriteBool(Active); + } + if (typeCase_ == TypeOneofCase.Point) { + output.WriteRawTag(50); + output.WriteMessage(Point); + } + if (typeCase_ == TypeOneofCase.Spot) { + output.WriteRawTag(58); + output.WriteMessage(Spot); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (color_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Color); + } + if (HasBrightness) { + output.WriteRawTag(21); + output.WriteFloat(Brightness); + } + if (HasRange) { + output.WriteRawTag(29); + output.WriteFloat(Range); + } + if (HasActive) { + output.WriteRawTag(32); + output.WriteBool(Active); + } + if (typeCase_ == TypeOneofCase.Point) { + output.WriteRawTag(50); + output.WriteMessage(Point); + } + if (typeCase_ == TypeOneofCase.Spot) { + output.WriteRawTag(58); + output.WriteMessage(Spot); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (HasActive) { + size += 1 + 1; + } + if (color_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Color); + } + if (HasBrightness) { + size += 1 + 4; + } + if (HasRange) { + size += 1 + 4; + } + if (typeCase_ == TypeOneofCase.Point) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Point); + } + if (typeCase_ == TypeOneofCase.Spot) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Spot); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(PBLightSource other) { + if (other == null) { + return; + } + if (other.HasActive) { + Active = other.Active; + } + if (other.color_ != null) { + if (color_ == null) { + Color = new global::Decentraland.Common.Color3(); + } + Color.MergeFrom(other.Color); + } + if (other.HasBrightness) { + Brightness = other.Brightness; + } + if (other.HasRange) { + Range = other.Range; + } + switch (other.TypeCase) { + case TypeOneofCase.Point: + if (Point == null) { + Point = new global::DCL.ECSComponents.PBLightSource.Types.Point(); + } + Point.MergeFrom(other.Point); + break; + case TypeOneofCase.Spot: + if (Spot == null) { + Spot = new global::DCL.ECSComponents.PBLightSource.Types.Spot(); + } + Spot.MergeFrom(other.Spot); + break; + } + + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 10: { + if (color_ == null) { + Color = new global::Decentraland.Common.Color3(); + } + input.ReadMessage(Color); + break; + } + case 21: { + Brightness = input.ReadFloat(); + break; + } + case 29: { + Range = input.ReadFloat(); + break; + } + case 32: { + Active = input.ReadBool(); + break; + } + case 50: { + global::DCL.ECSComponents.PBLightSource.Types.Point subBuilder = new global::DCL.ECSComponents.PBLightSource.Types.Point(); + if (typeCase_ == TypeOneofCase.Point) { + subBuilder.MergeFrom(Point); + } + input.ReadMessage(subBuilder); + Point = subBuilder; + break; + } + case 58: { + global::DCL.ECSComponents.PBLightSource.Types.Spot subBuilder = new global::DCL.ECSComponents.PBLightSource.Types.Spot(); + if (typeCase_ == TypeOneofCase.Spot) { + subBuilder.MergeFrom(Spot); + } + input.ReadMessage(subBuilder); + Spot = subBuilder; + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 10: { + if (color_ == null) { + Color = new global::Decentraland.Common.Color3(); + } + input.ReadMessage(Color); + break; + } + case 21: { + Brightness = input.ReadFloat(); + break; + } + case 29: { + Range = input.ReadFloat(); + break; + } + case 32: { + Active = input.ReadBool(); + break; + } + case 50: { + global::DCL.ECSComponents.PBLightSource.Types.Point subBuilder = new global::DCL.ECSComponents.PBLightSource.Types.Point(); + if (typeCase_ == TypeOneofCase.Point) { + subBuilder.MergeFrom(Point); + } + input.ReadMessage(subBuilder); + Point = subBuilder; + break; + } + case 58: { + global::DCL.ECSComponents.PBLightSource.Types.Spot subBuilder = new global::DCL.ECSComponents.PBLightSource.Types.Spot(); + if (typeCase_ == TypeOneofCase.Spot) { + subBuilder.MergeFrom(Spot); + } + input.ReadMessage(subBuilder); + Spot = subBuilder; + break; + } + } + } + } + #endif + + #region Nested types + /// Container for nested types declared in the PBLightSource message type. + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static partial class Types { + public enum ShadowType { + /// + /// No shadows are cast from this LightSource. + /// + [pbr::OriginalName("ST_NONE")] StNone = 0, + /// + /// More realistic type of shadow that reduces block artifacts, noise or pixelation, but requires more processing. + /// + [pbr::OriginalName("ST_SOFT")] StSoft = 1, + /// + /// Less realistic type of shadow but more performant, uses hard edges. + /// + [pbr::OriginalName("ST_HARD")] StHard = 2, + } + + public sealed partial class Point : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::DCL.ECSComponents.PBLightSource.Descriptor.NestedTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Point() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Point(Point other) : this() { + _hasBits0 = other._hasBits0; + shadow_ = other.shadow_; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Point Clone() { + return new Point(this); + } + + /// Field number for the "shadow" field. + public const int ShadowFieldNumber = 5; + private global::DCL.ECSComponents.PBLightSource.Types.ShadowType shadow_; + /// + /// default = ShadowType.ST_NONE The type of shadow the light source supports. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::DCL.ECSComponents.PBLightSource.Types.ShadowType Shadow { + get { if ((_hasBits0 & 1) != 0) { return shadow_; } else { return global::DCL.ECSComponents.PBLightSource.Types.ShadowType.StNone; } } + set { + _hasBits0 |= 1; + shadow_ = value; + } + } + /// Gets whether the "shadow" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasShadow { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "shadow" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearShadow() { + _hasBits0 &= ~1; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Point); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Point other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Shadow != other.Shadow) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (HasShadow) hash ^= Shadow.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (HasShadow) { + output.WriteRawTag(40); + output.WriteEnum((int) Shadow); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (HasShadow) { + output.WriteRawTag(40); + output.WriteEnum((int) Shadow); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (HasShadow) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Shadow); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Point other) { + if (other == null) { + return; + } + if (other.HasShadow) { + Shadow = other.Shadow; + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 40: { + Shadow = (global::DCL.ECSComponents.PBLightSource.Types.ShadowType) input.ReadEnum(); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 40: { + Shadow = (global::DCL.ECSComponents.PBLightSource.Types.ShadowType) input.ReadEnum(); + break; + } + } + } + } + #endif + + } + + public sealed partial class Spot : pb::IMessage + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + , pb::IBufferMessage + #endif + { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Spot()); + private pb::UnknownFieldSet _unknownFields; + private int _hasBits0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public static pbr::MessageDescriptor Descriptor { + get { return global::DCL.ECSComponents.PBLightSource.Descriptor.NestedTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Spot() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Spot(Spot other) : this() { + _hasBits0 = other._hasBits0; + innerAngle_ = other.innerAngle_; + outerAngle_ = other.outerAngle_; + shadow_ = other.shadow_; + shadowMaskTexture_ = other.shadowMaskTexture_ != null ? other.shadowMaskTexture_.Clone() : null; + _unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public Spot Clone() { + return new Spot(this); + } + + /// Field number for the "inner_angle" field. + public const int InnerAngleFieldNumber = 1; + private float innerAngle_; + /// + /// default = 21.8. Inner angle can't be higher than outer angle, otherwise will default to same value. Min value is 0. Max value is 179. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public float InnerAngle { + get { if ((_hasBits0 & 1) != 0) { return innerAngle_; } else { return 0F; } } + set { + _hasBits0 |= 1; + innerAngle_ = value; + } + } + /// Gets whether the "inner_angle" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasInnerAngle { + get { return (_hasBits0 & 1) != 0; } + } + /// Clears the value of the "inner_angle" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearInnerAngle() { + _hasBits0 &= ~1; + } + + /// Field number for the "outer_angle" field. + public const int OuterAngleFieldNumber = 2; + private float outerAngle_; + /// + /// default = 30. Outer angle can't be lower than inner angle, otherwise will inner angle will be set to same value. Max value is 179. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public float OuterAngle { + get { if ((_hasBits0 & 2) != 0) { return outerAngle_; } else { return 0F; } } + set { + _hasBits0 |= 2; + outerAngle_ = value; + } + } + /// Gets whether the "outer_angle" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasOuterAngle { + get { return (_hasBits0 & 2) != 0; } + } + /// Clears the value of the "outer_angle" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearOuterAngle() { + _hasBits0 &= ~2; + } + + /// Field number for the "shadow" field. + public const int ShadowFieldNumber = 5; + private global::DCL.ECSComponents.PBLightSource.Types.ShadowType shadow_; + /// + /// default = ShadowType.ST_NONE The type of shadow the light source supports. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::DCL.ECSComponents.PBLightSource.Types.ShadowType Shadow { + get { if ((_hasBits0 & 4) != 0) { return shadow_; } else { return global::DCL.ECSComponents.PBLightSource.Types.ShadowType.StNone; } } + set { + _hasBits0 |= 4; + shadow_ = value; + } + } + /// Gets whether the "shadow" field is set + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool HasShadow { + get { return (_hasBits0 & 4) != 0; } + } + /// Clears the value of the "shadow" field + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void ClearShadow() { + _hasBits0 &= ~4; + } + + /// Field number for the "shadow_mask_texture" field. + public const int ShadowMaskTextureFieldNumber = 8; + private global::Decentraland.Common.TextureUnion shadowMaskTexture_; + /// + /// Texture mask through which shadows are cast to simulate caustics, soft shadows, and light shapes such as light entering from a window. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public global::Decentraland.Common.TextureUnion ShadowMaskTexture { + get { return shadowMaskTexture_; } + set { + shadowMaskTexture_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override bool Equals(object other) { + return Equals(other as Spot); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public bool Equals(Spot other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(InnerAngle, other.InnerAngle)) return false; + if (!pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.Equals(OuterAngle, other.OuterAngle)) return false; + if (Shadow != other.Shadow) return false; + if (!object.Equals(ShadowMaskTexture, other.ShadowMaskTexture)) return false; + return Equals(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override int GetHashCode() { + int hash = 1; + if (HasInnerAngle) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(InnerAngle); + if (HasOuterAngle) hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(OuterAngle); + if (HasShadow) hash ^= Shadow.GetHashCode(); + if (shadowMaskTexture_ != null) hash ^= ShadowMaskTexture.GetHashCode(); + if (_unknownFields != null) { + hash ^= _unknownFields.GetHashCode(); + } + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void WriteTo(pb::CodedOutputStream output) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + output.WriteRawMessage(this); + #else + if (HasInnerAngle) { + output.WriteRawTag(13); + output.WriteFloat(InnerAngle); + } + if (HasOuterAngle) { + output.WriteRawTag(21); + output.WriteFloat(OuterAngle); + } + if (HasShadow) { + output.WriteRawTag(40); + output.WriteEnum((int) Shadow); + } + if (shadowMaskTexture_ != null) { + output.WriteRawTag(66); + output.WriteMessage(ShadowMaskTexture); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(output); + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) { + if (HasInnerAngle) { + output.WriteRawTag(13); + output.WriteFloat(InnerAngle); + } + if (HasOuterAngle) { + output.WriteRawTag(21); + output.WriteFloat(OuterAngle); + } + if (HasShadow) { + output.WriteRawTag(40); + output.WriteEnum((int) Shadow); + } + if (shadowMaskTexture_ != null) { + output.WriteRawTag(66); + output.WriteMessage(ShadowMaskTexture); + } + if (_unknownFields != null) { + _unknownFields.WriteTo(ref output); + } + } + #endif + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public int CalculateSize() { + int size = 0; + if (HasInnerAngle) { + size += 1 + 4; + } + if (HasOuterAngle) { + size += 1 + 4; + } + if (HasShadow) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Shadow); + } + if (shadowMaskTexture_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ShadowMaskTexture); + } + if (_unknownFields != null) { + size += _unknownFields.CalculateSize(); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(Spot other) { + if (other == null) { + return; + } + if (other.HasInnerAngle) { + InnerAngle = other.InnerAngle; + } + if (other.HasOuterAngle) { + OuterAngle = other.OuterAngle; + } + if (other.HasShadow) { + Shadow = other.Shadow; + } + if (other.shadowMaskTexture_ != null) { + if (shadowMaskTexture_ == null) { + ShadowMaskTexture = new global::Decentraland.Common.TextureUnion(); + } + ShadowMaskTexture.MergeFrom(other.ShadowMaskTexture); + } + _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + public void MergeFrom(pb::CodedInputStream input) { + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + input.ReadRawMessage(this); + #else + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input); + break; + case 13: { + InnerAngle = input.ReadFloat(); + break; + } + case 21: { + OuterAngle = input.ReadFloat(); + break; + } + case 40: { + Shadow = (global::DCL.ECSComponents.PBLightSource.Types.ShadowType) input.ReadEnum(); + break; + } + case 66: { + if (shadowMaskTexture_ == null) { + ShadowMaskTexture = new global::Decentraland.Common.TextureUnion(); + } + input.ReadMessage(ShadowMaskTexture); + break; + } + } + } + #endif + } + + #if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + [global::System.CodeDom.Compiler.GeneratedCode("protoc", null)] + void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + _unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input); + break; + case 13: { + InnerAngle = input.ReadFloat(); + break; + } + case 21: { + OuterAngle = input.ReadFloat(); + break; + } + case 40: { + Shadow = (global::DCL.ECSComponents.PBLightSource.Types.ShadowType) input.ReadEnum(); + break; + } + case 66: { + if (shadowMaskTexture_ == null) { + ShadowMaskTexture = new global::Decentraland.Common.TextureUnion(); + } + input.ReadMessage(ShadowMaskTexture); + break; + } + } + } + } + #endif + + } + + } + #endregion + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs.meta b/Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs.meta new file mode 100644 index 0000000000..5d8e795cdc --- /dev/null +++ b/Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs.meta @@ -0,0 +1,15 @@ +fileFormatVersion: 2 +<<<<<<<< HEAD:Explorer/Assets/Protocol/DecentralandProtocol/LightSource.gen.cs.meta +guid: 9e26a21b67f3ba449b4d60d2cd740df8 +======== +guid: 2b43bac7a50418643bfe4c92df43201d +>>>>>>>> dev:Explorer/Assets/DCL/RealmNavigation/Container/RealmNavigationContainer.cs.meta +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/Scripts/CrdtEcsBridge/Components/ResetExtensions/PrimitivesConversionExtensions.cs b/Explorer/Assets/Scripts/CrdtEcsBridge/Components/ResetExtensions/PrimitivesConversionExtensions.cs index dc9f619e2e..e405a427bd 100644 --- a/Explorer/Assets/Scripts/CrdtEcsBridge/Components/ResetExtensions/PrimitivesConversionExtensions.cs +++ b/Explorer/Assets/Scripts/CrdtEcsBridge/Components/ResetExtensions/PrimitivesConversionExtensions.cs @@ -1,4 +1,10 @@ +using DCL.Diagnostics; +using DCL.ECSComponents; +using Decentraland.Common; +using System; using UnityEngine; +using Quaternion = UnityEngine.Quaternion; +using Vector3 = UnityEngine.Vector3; namespace CrdtEcsBridge.Components.Conversion { @@ -23,5 +29,41 @@ public static Quaternion PBQuaternionToUnityQuaternion(Decentraland.Common.Quate z = protoQuaternion.Z, w = protoQuaternion.W, }; + + public static Color PBColorToUnityColor(Color3 protoColor, float alphaValue = 1) => + new () + { + r = protoColor.R, + g = protoColor.G, + b = protoColor.B, + a = alphaValue, + }; + + public static Color PBColorToUnityColor(Color4 protoColor) => + new () + { + r = protoColor.R, + g = protoColor.G, + b = protoColor.B, + a = protoColor.A, + }; + + public static LightShadows PBLightSourceShadowToUnityLightShadow(PBLightSource.Types.ShadowType shadow) + { + switch (shadow) + { + case PBLightSource.Types.ShadowType.StNone: return LightShadows.None; + case PBLightSource.Types.ShadowType.StSoft: return LightShadows.Soft; + case PBLightSource.Types.ShadowType.StHard: return LightShadows.Hard; + default: + { + ReportHub.LogError(ReportCategory.UNSPECIFIED, "Null shadow type provided, using None instead"); + return LightShadows.None; + } + } + } + + public static float PBBrightnessInLumensToUnityCandels(float lumens) => + lumens / (4f * Mathf.PI); } } diff --git a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs index 678469d3f0..c61719b67c 100644 --- a/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs +++ b/Explorer/Assets/Scripts/ECS/Unity/Materials/Systems/StartMaterialsLoadingSystem.cs @@ -153,14 +153,13 @@ private void CreateGetTexturePromises(Entity entity, ref MaterialComponent mater PartitionComponent partitionComponent) { TryCreateGetTexturePromise(entity, in materialComponent.Data.Textures.AlbedoTexture, oldTexturesData?.AlbedoTexture, ref materialComponent.AlbedoTexPromise, partitionComponent); + TryCreateGetTexturePromise(entity, in materialComponent.Data.Textures.AlphaTexture, oldTexturesData?.AlphaTexture, ref materialComponent.AlphaTexPromise, partitionComponent); if (materialComponent.Data.IsPbrMaterial) { - TryCreateGetTexturePromise(entity, in materialComponent.Data.Textures.AlphaTexture, oldTexturesData?.AlphaTexture, ref materialComponent.AlphaTexPromise, partitionComponent); TryCreateGetTexturePromise(entity, in materialComponent.Data.Textures.EmissiveTexture, oldTexturesData?.EmissiveTexture, ref materialComponent.EmissiveTexPromise, partitionComponent); TryCreateGetTexturePromise(entity, in materialComponent.Data.Textures.BumpTexture, oldTexturesData?.BumpTexture, ref materialComponent.BumpTexPromise, partitionComponent); } - else { TryCreateGetTexturePromise(entity, in materialComponent.Data.Textures.AlphaTexture, oldTexturesData?.AlphaTexture, ref materialComponent.AlphaTexPromise, partitionComponent); } } private static MaterialData CreateBasicMaterialData(in PBMaterial pbMaterial, in TextureComponent? albedoTexture, in TextureComponent? alphaTexture) => diff --git a/Explorer/Assets/Scripts/Global/ComponentsContainer.cs b/Explorer/Assets/Scripts/Global/ComponentsContainer.cs index 2a1d3c2aaf..df5133262c 100644 --- a/Explorer/Assets/Scripts/Global/ComponentsContainer.cs +++ b/Explorer/Assets/Scripts/Global/ComponentsContainer.cs @@ -133,7 +133,8 @@ public static ComponentsContainer Create() .Add(SDKComponentBuilder.Create(ComponentID.MAP_PIN).AsProtobufComponent()) .Add(SDKComponentBuilder.Create(ComponentID.INPUT_MODIFIER).AsProtobufComponent()) .Add(SDKComponentBuilder.Create(ComponentID.MAIN_CAMERA).AsProtobufComponent()) - .Add(SDKComponentBuilder.Create(ComponentID.VIRTUAL_CAMERA).AsProtobufComponent()); + .Add(SDKComponentBuilder.Create(ComponentID.VIRTUAL_CAMERA).AsProtobufComponent()) + .Add(SDKComponentBuilder.Create(ComponentID.LIGHT_SOURCE).AsProtobufComponent()); Transform rootContainer = new GameObject("ROOT_POOL_CONTAINER").transform; diff --git a/Explorer/Assets/Scripts/Global/StaticContainer.cs b/Explorer/Assets/Scripts/Global/StaticContainer.cs index 0d33d2301b..ef2107381d 100644 --- a/Explorer/Assets/Scripts/Global/StaticContainer.cs +++ b/Explorer/Assets/Scripts/Global/StaticContainer.cs @@ -256,6 +256,7 @@ await UniTask.WhenAll( new RealmInfoPlugin(container.RealmData, container.RoomHubProxy), new InputModifierPlugin(globalWorld, container.PlayerEntity, container.SceneRestrictionBusController), new MainCameraPlugin(componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner, container.CacheCleaner, exposedGlobalDataContainer.ExposedCameraData, container.SceneRestrictionBusController, globalWorld), + new LightSourcePlugin(componentsContainer.ComponentPoolsRegistry, container.assetsProvisioner, container.CacheCleaner), #if UNITY_EDITOR new GizmosWorldPlugin(), diff --git a/Explorer/Assets/Scripts/ProtobufPartialClasses/IDirtyMarker.cs b/Explorer/Assets/Scripts/ProtobufPartialClasses/IDirtyMarker.cs index 335e17ec63..fd21af070c 100644 --- a/Explorer/Assets/Scripts/ProtobufPartialClasses/IDirtyMarker.cs +++ b/Explorer/Assets/Scripts/ProtobufPartialClasses/IDirtyMarker.cs @@ -182,6 +182,11 @@ public partial class PBVirtualCamera : IDirtyMarker public bool IsDirty { get; set; } } + public partial class PBLightSource : IDirtyMarker + { + public bool IsDirty { get; set; } + } + public static class DirtyMarkerExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/scripts/package-lock.json b/scripts/package-lock.json index 361bf0c894..fb08ab37f0 100644 --- a/scripts/package-lock.json +++ b/scripts/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "Apache-2.0", "dependencies": { - "@dcl/protocol": "^1.0.0-12891435340.commit-b3fea33", + "@dcl/protocol": "^1.0.0-13143749736.commit-5fbeb3c", "@protobuf-ts/protoc": "^2.8.2", "@types/fs-extra": "^11.0.1", "@types/glob": "^8.0.1", @@ -36,10 +36,9 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-12891435340.commit-b3fea33", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-12891435340.commit-b3fea33.tgz", - "integrity": "sha512-WBiLqh5g8imJNPvihgxBbqLf9cOY7g+rsj98yjkU1wl+WTuIyXKIWJn6XlQ2+h797ZF+aDRm66q9bhTGMmYdsA==", - "license": "Apache-2.0", + "version": "1.0.0-13143749736.commit-5fbeb3c", + "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-13143749736.commit-5fbeb3c.tgz", + "integrity": "sha512-uUptud8RGezZ4ywgVf56cnBp/813bHG73P/GwjHSr5D9pT92nN4KytvyL4D5ATReg8O12UxntObuXbwae8Vlvw==", "dependencies": { "@dcl/ts-proto": "1.154.0" } @@ -570,9 +569,9 @@ } }, "@dcl/protocol": { - "version": "1.0.0-12891435340.commit-b3fea33", - "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-12891435340.commit-b3fea33.tgz", - "integrity": "sha512-WBiLqh5g8imJNPvihgxBbqLf9cOY7g+rsj98yjkU1wl+WTuIyXKIWJn6XlQ2+h797ZF+aDRm66q9bhTGMmYdsA==", + "version": "1.0.0-13143749736.commit-5fbeb3c", + "resolved": "https://registry.npmjs.org/@dcl/protocol/-/protocol-1.0.0-13143749736.commit-5fbeb3c.tgz", + "integrity": "sha512-uUptud8RGezZ4ywgVf56cnBp/813bHG73P/GwjHSr5D9pT92nN4KytvyL4D5ATReg8O12UxntObuXbwae8Vlvw==", "requires": { "@dcl/ts-proto": "1.154.0" } diff --git a/scripts/package.json b/scripts/package.json index cb1c81b9cd..8c03e8cd0a 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -16,7 +16,7 @@ "typescript": "^4.2.3" }, "dependencies": { - "@dcl/protocol": "^1.0.0-12891435340.commit-b3fea33", + "@dcl/protocol": "^1.0.0-13143749736.commit-5fbeb3c", "@protobuf-ts/protoc": "^2.8.2", "@types/fs-extra": "^11.0.1", "@types/glob": "^8.0.1",