Esempio n. 1
0
    /// <summary>
    /// Get the collider enable override. True if entity's colliders are enabled, false otherwise.
    /// </summary>
    public static bool GetColliderEnabledOverride(this Remote.Entity entity)
    {
        if (entity == null || !entity.Valid)
        {
            return(false);
        }

        var component = entity.EnsureComponentOfType <HierarchicalStateOverrideComponent>();

        return(component.DisableCollisionState == HierarchicalEnableState.InheritFromParent);
    }
    /// <summary>
    /// Get the collider enablement override. True if entity's colliders are enabled, false otherwise.
    /// </summary>
    public static bool GetColliderEnabledOverride(this Remote.Entity entity)
    {
        if (entity == null || !entity.Valid)
        {
            return(false);
        }

        var  component = entity.EnsureComponentOfType <HierarchicalStateOverrideComponent>();
        bool disabled  = (component.Flags & HierarchicalStates.DisableCollision) == HierarchicalStates.DisableCollision;

        return(!disabled);
    }
    /// <summary>
    /// Get the visibility override
    /// </summary>
    public static bool GetVisibilityOverride(this Remote.Entity entity)
    {
        if (entity == null || !entity.Valid)
        {
            return(false);
        }

        var  component = entity.EnsureComponentOfType <HierarchicalStateOverrideComponent>();
        bool hidden    = (component.Flags & HierarchicalStates.Hidden) == HierarchicalStates.Hidden;

        return(!hidden);
    }
Esempio n. 4
0
    /// <summary>
    /// Set the visibility override
    /// </summary>
    public static void SetVisibilityOverride(this Remote.Entity entity, bool value)
    {
        if (entity == null || !entity.Valid)
        {
            return;
        }

        var component = entity.EnsureComponentOfType <HierarchicalStateOverrideComponent>();

        component.HiddenState           = value ? HierarchicalEnableState.InheritFromParent : HierarchicalEnableState.ForceOn;
        component.DisableCollisionState = value ? HierarchicalEnableState.InheritFromParent : HierarchicalEnableState.ForceOn;
    }
Esempio n. 5
0
    /// <summary>
    /// Set the collider enable override
    /// </summary>
    public static void SetColliderEnabledOverride(this Remote.Entity entity, bool enable)
    {
        if (entity == null || !entity.Valid)
        {
            return;
        }

        var component = entity.EnsureComponentOfType <HierarchicalStateOverrideComponent>();

        if (enable)
        {
            component.DisableCollisionState = HierarchicalEnableState.InheritFromParent;
        }
        else
        {
            component.DisableCollisionState = HierarchicalEnableState.ForceOn;
        }
    }
    /// <summary>
    /// Set the visibility override
    /// </summary>
    public static void SetVisibilityOverride(this Remote.Entity entity, bool value)
    {
        if (entity == null || !entity.Valid)
        {
            return;
        }

        // Clear the hidden flag, or add it to the overrides
        var component = entity.EnsureComponentOfType <HierarchicalStateOverrideComponent>();
        var newFlags  = component.Flags & ~HierarchicalStates.Hidden & ~HierarchicalStates.DisableCollision;

        if (!value)
        {
            newFlags |= (HierarchicalStates.Hidden | HierarchicalStates.DisableCollision);
        }

        // Ensure remote is up-to-date
        if (component.Flags != newFlags)
        {
            component.Flags = newFlags;
        }
    }