// // /*===============================================================================
// // Copyright (C) 2025 PhantomsXR Ltd. All Rights Reserved.
// //
// // This file is part of the Phantom.XRMOD.QuestModule.Runtime.
// //
// // The XR-MOD cannot be copied, distributed, or made available to
// // third-parties for commercial purposes without written permission of PhantomsXR Ltd.
// //
// // Contact nswell@phantomsxr.com for licensing requests.
// // ===============================================================================*/
using System.Collections.Generic;
using Phantom.XRMOD.Core.Runtime;
using Phantom.XRMOD.Models.Runtime;
using UnityEngine;
namespace Phantom.XRMOD.QuestModule.Runtime
{
///
/// Base abstract decorator for Meta Quest features.
///
/// Provides common functionality for registering feature decorators at runtime.
/// Implementations should override , , and .
///
///
public abstract class BaseMetaQuestFeatureDecorator : IFeatureDecorator
{
///
/// Determines if the specific feature is supported on the current platform/device.
///
/// True if supported, otherwise false.
public abstract bool SupportThisFeature();
///
/// Starts the feature algorithm.
///
/// By default, it calls to register the decorator.
///
///
public virtual void StartAlgorithm()
{
RuntimeFeatureRegister();
}
///
/// Pauses the feature algorithm.
///
public abstract void PauseAlgorithm();
///
/// Stops the feature algorithm.
///
public abstract void StopAlgorithm();
///
/// Automatically registers the feature decorator to the .
///
/// This ensures the feature is tracked and managed by the runtime context for the current project.
///
///
protected void RuntimeFeatureRegister()
{
var tmp_ExperienceData = IocContainer.GetIoc.Resolve().CurrentConfigures.Value;
var tmp_ContextData = IocContainer.GetIoc.Resolve();
if (tmp_ExperienceData == null || string.IsNullOrEmpty(tmp_ExperienceData.ProjectName))
{
Debug.LogError("Can not read project.");
return;
}
if (tmp_ContextData.FeatureDecoratorsAtRuntime.TryGetValue(tmp_ExperienceData.ProjectName,
out var tmp_Decorators))
{
if (!tmp_Decorators.Contains(this))
{
tmp_Decorators.Add(this);
}
}
else
{
List tmp_NewDecorators = new List {this};
tmp_ContextData.FeatureDecoratorsAtRuntime.Add(tmp_ExperienceData.ProjectName, tmp_NewDecorators);
}
}
}
}