// MIT License - Copyright (c) 2025 wallstop
// Full license text: https://github.com/wallstop/unity-helpers/blob/main/LICENSE
#if VCONTAINER_PRESENT
namespace WallstopStudios.UnityHelpers.Integrations.VContainer
{
using System;
using WallstopStudios.UnityHelpers.Core.Helper;
///
/// Controls how the VContainer integration applies relational component assignment.
///
///
///
/// // Register integration and scan only active objects
/// builder.RegisterRelationalComponents(
/// new RelationalSceneAssignmentOptions(includeInactive: false)
/// );
///
///
public readonly struct RelationalSceneAssignmentOptions
: IEquatable
{
///
/// Initializes a new set of options.
///
///
/// When true the entry point will scan inactive scene objects so that relational fields are
/// populated even for disabled hierarchies. Defaults to true.
///
///
/// When true uses a single-pass scene scan for performance (recommended). Defaults to
/// true.
///
public RelationalSceneAssignmentOptions(bool includeInactive, bool useSinglePassScan = true)
{
IncludeInactive = includeInactive;
UseSinglePassScan = useSinglePassScan;
}
///
/// Options used when no explicit configuration is supplied.
///
public static RelationalSceneAssignmentOptions Default => new(true, true);
///
/// Gets whether inactive GameObjects should be included when scanning the scene.
///
public bool IncludeInactive { get; }
///
/// Gets whether to use a single-pass scene scan to locate relational components.
///
public bool UseSinglePassScan { get; }
///
public bool Equals(RelationalSceneAssignmentOptions other)
{
return IncludeInactive == other.IncludeInactive
&& UseSinglePassScan == other.UseSinglePassScan;
}
///
public override bool Equals(object obj)
{
return obj is RelationalSceneAssignmentOptions other && Equals(other);
}
///
public override int GetHashCode()
{
return Objects.HashCode(IncludeInactive, UseSinglePassScan);
}
///
/// Equality operator.
///
public static bool operator ==(
RelationalSceneAssignmentOptions left,
RelationalSceneAssignmentOptions right
)
{
return left.Equals(right);
}
///
/// Inequality operator.
///
public static bool operator !=(
RelationalSceneAssignmentOptions left,
RelationalSceneAssignmentOptions right
)
{
return !left.Equals(right);
}
}
}
#endif