From e0f1f18998c5608bbe3e77206eaa9ab1696d6346 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Mon, 18 Jan 2021 15:07:39 +0100 Subject: [PATCH] Move Actor static flags helper methods to be manually implemented (less bindings) --- Source/Engine/Level/Actor.cs | 60 ++++++++++++++++++++++++++++++++++++ Source/Engine/Level/Actor.h | 10 +++--- 2 files changed, 65 insertions(+), 5 deletions(-) diff --git a/Source/Engine/Level/Actor.cs b/Source/Engine/Level/Actor.cs index 674842a65..260fef44e 100644 --- a/Source/Engine/Level/Actor.cs +++ b/Source/Engine/Level/Actor.cs @@ -6,6 +6,66 @@ namespace FlaxEngine { partial class Actor : ITransformable, ISceneObject { + /// + /// Returns true if object is fully static on the scene, otherwise false. + /// + [Unmanaged] + [Tooltip("Returns true if object is fully static on the scene, otherwise false.")] + public bool IsStatic => StaticFlags == FlaxEngine.StaticFlags.FullyStatic; + + /// + /// Returns true if object has static transform. + /// + [Unmanaged] + [Tooltip("Returns true if object has static transform.")] + public bool IsTransformStatic => (StaticFlags & StaticFlags.Transform) == StaticFlags.Transform; + + /// + /// Adds the actor static flags. + /// + /// The flags to add. + [Unmanaged] + [Tooltip("Adds the actor static flags.")] + public void AddStaticFlags(StaticFlags flags) + { + StaticFlags |= flags; + } + + /// + /// Removes the actor static flags. + /// + /// The flags to remove. + [Unmanaged] + [Tooltip("Removes the actor static flags.")] + public void RemoveStaticFlags(StaticFlags flags) + { + StaticFlags &= ~flags; + } + + /// + /// Sets a single static flag to the desire value. + /// + /// The flag to change. + /// The target value of the flag. + [Unmanaged] + [Tooltip("Sets a single static flag to the desire value.")] + public void SetStaticFlag(StaticFlags flag, bool value) + { + StaticFlags = StaticFlags & ~flag | (value ? flag : StaticFlags.None); + } + + /// + /// Returns true if object has given flag(s) set. + /// + /// The flag(s) to check. + /// True if has flag(s) set, otherwise false. + [Unmanaged] + [Tooltip("Returns true if object has given flag(s) set..")] + public bool HasStaticFlag(StaticFlags flag) + { + return (StaticFlags & flag) == flag; + } + /// /// The rotation as Euler angles in degrees. /// diff --git a/Source/Engine/Level/Actor.h b/Source/Engine/Level/Actor.h index 53f8fe163..da08bc498 100644 --- a/Source/Engine/Level/Actor.h +++ b/Source/Engine/Level/Actor.h @@ -339,7 +339,7 @@ public: /// /// Returns true if object is fully static on the scene, otherwise false. /// - API_PROPERTY() FORCE_INLINE bool IsStatic() const + FORCE_INLINE bool IsStatic() const { return _staticFlags == StaticFlags::FullyStatic; } @@ -347,7 +347,7 @@ public: /// /// Returns true if object has static transform. /// - API_PROPERTY() FORCE_INLINE bool IsTransformStatic() const + FORCE_INLINE bool IsTransformStatic() const { return (_staticFlags & StaticFlags::Transform) != 0; } @@ -379,7 +379,7 @@ public: /// Adds the actor static flags. /// /// The flags to add. - API_FUNCTION() FORCE_INLINE void AddStaticFlags(StaticFlags flags) + FORCE_INLINE void AddStaticFlags(StaticFlags flags) { SetStaticFlags(_staticFlags | flags); } @@ -388,7 +388,7 @@ public: /// Removes the actor static flags. /// /// The flags to remove. - API_FUNCTION() FORCE_INLINE void RemoveStaticFlags(StaticFlags flags) + FORCE_INLINE void RemoveStaticFlags(StaticFlags flags) { SetStaticFlags(static_cast(_staticFlags & ~flags)); } @@ -398,7 +398,7 @@ public: /// /// The flag to change. /// The target value of the flag. - API_FUNCTION() FORCE_INLINE void SetStaticFlag(StaticFlags flag, bool value) + FORCE_INLINE void SetStaticFlag(StaticFlags flag, bool value) { SetStaticFlags(static_cast(_staticFlags & ~flag) | (value ? flag : StaticFlags::None)); }