namespace Sandbox;
[Flags]
public enum GameObjectFlags
{
None = 0,
///
/// Hide this object in heirachy/inspector
///
Hidden = 1,
///
/// Don't save this object to disk, or when duplicating
///
NotSaved = 2,
///
/// Auto created - it's a bone, driven by animation
///
Bone = 4,
///
/// Auto created - it's an attachment
///
Attachment = 8,
///
/// There's something wrong with this
///
Error = 16,
///
/// Loading something
///
Loading = 32,
///
/// Is in the process of deserializing
///
Deserializing = 64,
///
/// When loading a new scene, keep this gameobject active
///
DontDestroyOnLoad = 128,
///
/// Keep local - don't network this object as part of the scene snapshot
///
NotNetworked = 256,
///
/// In the process of refreshing from the network
///
[Obsolete]
Refreshing = 512,
///
/// Stops animation stomping the bone, will use the bone's local position
///
ProceduralBone = 1024,
///
/// Only exists in the editor. Don't spawn it in game.
///
EditorOnly = 2048,
///
/// Ignore the parent transform. Basically, position: absolute for gameobjects.
///
Absolute = 4096,
///
/// The position of this object is controlled by by physics - usually via a RigidBody component
///
PhysicsBone = 8192,
///
/// Stops this object being interpolated, either via the network system or the physics system
///
NoInterpolation = 16384,
}
public partial class GameObject
{
public GameObjectFlags Flags { get; set; } = GameObjectFlags.None;
///
/// True if this GameObject is being deserialized right now
///
public bool IsDeserializing => Flags.Contains( GameObjectFlags.Deserializing );
///
/// Do we or our ancestor have this flag
///
internal bool HasFlagOrParent( GameObjectFlags f )
{
if ( Flags.Contains( f ) ) return true;
if ( Parent is null ) return false;
return Parent.HasFlagOrParent( f );
}
}