<commit_before>﻿// Nu Game Engine.
// Copyright (C) <NAME>, 2013-2018.

namespace Nu
open System
open System.ComponentModel
open System.Reflection
open System.Runtime.CompilerServices
open Prime
open Nu

[<AutoOpen; ModuleBinding>]
module WorldEntityModule =

    type Entity with

        member this.GetId world = World.getEntityId this world
        member this.Id = PropertyTag.makeReadOnly this Property? Id this.GetId
        member this.GetName world = World.getEntityName this world
        member this.Name = PropertyTag.makeReadOnly this Property? Name this.GetName
        member this.GetDispatcher world = World.getEntityDispatcher this world
        member this.Dispatcher = PropertyTag.makeReadOnly this Property? Dispatcher this.GetDispatcher
        member this.GetPersistent world = World.getEntityPersistent this world
        member this.SetPersistent value world = World.setEntityPersistent value this world
        member this.Persistent = PropertyTag.make this Property? Persistent this.GetPersistent this.SetPersistent
        member this.GetCreationTimeStamp world = World.getEntityCreationTimeStamp this world
        member this.CreationTimeStamp = PropertyTag.makeReadOnly this Property? CreationTimeStamp this.GetCreationTimeStamp
        member this.GetCacheable world = World.getEntityCachable this world
        member this.Cacheable = PropertyTag.makeReadOnly this Property? Cacheable this.GetCacheable
        member this.GetImperative world = World.getEntityImperative this world
        member this.Imperative = PropertyTag.makeReadOnly this Property? Imperative this.GetImperative
        member this.GetOverlayNameOpt world = World.getEntityOverlayNameOpt this world
        member this.OverlayNameOpt = PropertyTag.makeReadOnly this Property? OverlayNameOpt this.GetOverlayNameOpt
        member this.GetPosition world = World.getEntityPosition this world
        member this.SetPosition value world = World.setEntityPosition value this world
        member this.Position = PropertyTag.make this Property? Position this.GetPosition this.SetPosition
        member this.GetSize world = World.getEntitySize this world
        member this.SetSize value world = World.setEntitySize value this world
        member this.Size = PropertyTag.make this Property? Size this.GetSize this.SetSize
        member this.GetRotation world = World.getEntityRotation this world
        member this.SetRotation value world = World.setEntityRotation value this world
        member this.Rotation = PropertyTag.make this Property? Rotation this.GetRotation this.SetRotation
        member this.GetDepth world = World.getEntityDepth this world
        member this.SetDepth value world = World.setEntityDepth value this world
        member this.Depth = PropertyTag.make this Property? Depth this.GetDepth this.SetDepth
        member this.GetDepthLayered world = World.getEntityDepth this world + World.getLayerDepth (etol this) world
        member this.DepthLayered = PropertyTag.makeReadOnly this Property? DepthLayered this.GetDepthLayered
        member this.GetOverflow world = World.getEntityOverflow this world
        member this.SetOverflow value world = World.setEntityOverflow value this world
        member this.Overflow = PropertyTag.make this Property? Overflow this.GetOverflow this.SetOverflow
        member this.GetViewType world = World.getEntityViewType this world
        member this.SetViewType value world = World.setEntityViewType value this world
        member this.ViewType = PropertyTag.make this Property? ViewType this.GetViewType this.SetViewType
        member this.GetVisible world = World.getEntityVisible this world
        member this.SetVisible value world = World.setEntityVisible value this world
        member this.Visible = PropertyTag.make this Property? Visible this.GetVisible this.SetVisible
        member this.GetVisibleLayered world = World.getEntityVisible this world && World.getLayerVisible (etol this) world
        member this.VisibleLayered = PropertyTag.makeReadOnly this Property? VisibleLayered this.GetVisibleLayered
        member this.GetEnabled world = World.getEntityEnabled this world
        member this.SetEnabled value world = World.setEntityEnabled value this world
        member this.Enabled = PropertyTag.make this Property? Enabled this.GetEnabled this.SetEnabled
        member this.GetOmnipresent world = World.getEntityOmnipresent this world
        member this.SetOmnipresent value world = World.setEntityOmnipresent value this world
        member this.Omnipresent = PropertyTag.make this Property? Omnipresent this.GetOmnipresent this.SetOmnipresent
        member this.GetAlwaysUpdate world = World.getEntityAlwaysUpdate this world
        member this.SetAlwaysUpdate value world = World.setEntityAlwaysUpdate value this world
        member this.AlwaysUpdate = PropertyTag.make this Property? AlwaysUpdate this.GetAlwaysUpdate this.SetAlwaysUpdate
        member this.GetPublishChanges world = World.getEntityPublishChanges this world
        member this.SetPublishChanges value world = World.setEntityPublishChanges value this world
        member this.PublishChanges = PropertyTag.make this Property? PublishChanges this.GetPublishChanges this.SetPublishChanges
        member this.GetFacetNames world = World.getEntityFacetNames this world
        member this.FacetNames = PropertyTag.makeReadOnly this Property? FacetNames this.GetFacetNames
        member this.GetFacets world = World.getEntityFacets this world
        member this.Facets = PropertyTag.makeReadOnly this Property? Facets this.GetFacets

        /// Try to get a property value and type.
        member this.TryGetProperty propertyName world = World.tryGetEntityProperty propertyName this world

        /// Get a property value and type.
        member this.GetProperty propertyName world = World.getEntityProperty propertyName this world

        /// Get a property value.
        member this.Get<'a> propertyName world : 'a = (World.getEntityProperty propertyName this world).PropertyValue :?> 'a

        /// Try to set a property value with explicit type.
        member this.TrySetProperty propertyName alwaysPublish nonPersistent property world =
            World.trySetEntityProperty propertyName alwaysPublish nonPersistent property this world

        /// Set a property value with explicit type.
        member this.SetProperty propertyName alwaysPublish nonPersistent property world =
            World.setEntityProperty propertyName alwaysPublish nonPersistent property this world

        /// Attach a property.
        member this.AttachProperty propertyName alwaysPublish nonPersistent property world =
            World.attachEntityProperty propertyName alwaysPublish nonPersistent property this world

        /// Detach a property.
        member this.DetachProperty propertyName world =
            World.detachEntityProperty propertyName this world

        /// Set a property value.
        member this.Set<'a> propertyName (value : 'a) world =
            let alwaysPublish = Reflection.isPropertyAlwaysPublishByName propertyName
            let nonPersistent = not (Reflection.isPropertyPersistentByName propertyName)
            this.SetFast propertyName alwaysPublish nonPersistent value world

        /// Set a property value.
        member this.SetFast<'a> propertyName alwaysPublish nonPersistent (value : 'a) world =
            World.setEntityProperty propertyName alwaysPublish nonPersistent { PropertyType = typeof<'a>; PropertyValue = value } this world

        /// Get an entity's transform.
        member this.GetTransform world = World.getEntityTransform this world
        
        /// Set an entity's transform.
        member this.SetTransform value world = World.setEntityTransform value this world

        /// Get an entity's sorting priority.
        member this.GetSortingPriority world = World.getEntitySortingPriority this world

        /// Get an entity's quick size.
        member this.GetQuickSize world = World.getEntityQuickSize this world

        /// Get an entity's bounds, not taking into account its overflow.
        member this.GetBounds world = Math.makeBounds (this.GetPosition world) (this.GetSize world)

        /// Get an entity's bounds, taking into account its overflow.
        member this.GetBoundsOverflow world = Math.makeBoundsOverflow (this.GetPosition world) (this.GetSize world) (this.GetOverflow world)

        /// Get an entity's bounds maximum.
        member this.GetBoundsMax world = World.getEntityBoundsMax this world

        /// Check that an entity is selected.
        member this.GetSelected world =
            match (World.getGameState world).OmniscreenOpt with
            | Some omniscreen when Address.head this.EntityAddress = Address.head omniscreen.ScreenAddress -> true
            | _ ->
                match (World.getGameState world).SelectedScreenOpt with
                | Some screen when Address.head this.EntityAddress = Address.head screen.ScreenAddress -> true
                | _ -> false

        /// Check that an entity is in the camera's view.
        member this.GetInView world =
            if not (this.GetOmnipresent world) then
                World.isBoundsInView
                    (this.GetViewType world)<commit_msg>Created a quick size function.<commit_after>﻿// Nu Game Engine.
// Copyright (C) <NAME>, 2013-2018.

namespace Nu
open System
open System.ComponentModel
open System.Reflection
open System.Runtime.CompilerServices
open Prime
open Nu

[<AutoOpen; ModuleBinding>]
module WorldEntityModule =

    type Entity with

        member this.GetId world = World.getEntityId this world
        member this.Id = PropertyTag.makeReadOnly this Property? Id this.GetId
        member this.GetName world = World.getEntityName this world
        member this.Name = PropertyTag.makeReadOnly this Property? Name this.GetName
        member this.GetDispatcher world = World.getEntityDispatcher this world
        member this.Dispatcher = PropertyTag.makeReadOnly this Property? Dispatcher this.GetDispatcher
        member this.GetPersistent world = World.getEntityPersistent this world
        member this.SetPersistent value world = World.setEntityPersistent value this world
        member this.Persistent = PropertyTag.make this Property? Persistent this.GetPersistent this.SetPersistent
        member this.GetCreationTimeStamp world = World.getEntityCreationTimeStamp this world
        member this.CreationTimeStamp = PropertyTag.makeReadOnly this Property? CreationTimeStamp this.GetCreationTimeStamp
        member this.GetCacheable world = World.getEntityCachable this world
        member this.Cacheable = PropertyTag.makeReadOnly this Property? Cacheable this.GetCacheable
        member this.GetImperative world = World.getEntityImperative this world
        member this.Imperative = PropertyTag.makeReadOnly this Property? Imperative this.GetImperative
        member this.GetOverlayNameOpt world = World.getEntityOverlayNameOpt this world
        member this.OverlayNameOpt = PropertyTag.makeReadOnly this Property? OverlayNameOpt this.GetOverlayNameOpt
        member this.GetPosition world = World.getEntityPosition this world
        member this.SetPosition value world = World.setEntityPosition value this world
        member this.Position = PropertyTag.make this Property? Position this.GetPosition this.SetPosition
        member this.GetSize world = World.getEntitySize this world
        member this.SetSize value world = World.setEntitySize value this world
        member this.Size = PropertyTag.make this Property? Size this.GetSize this.SetSize
        member this.GetRotation world = World.getEntityRotation this world
        member this.SetRotation value world = World.setEntityRotation value this world
        member this.Rotation = PropertyTag.make this Property? Rotation this.GetRotation this.SetRotation
        member this.GetDepth world = World.getEntityDepth this world
        member this.SetDepth value world = World.setEntityDepth value this world
        member this.Depth = PropertyTag.make this Property? Depth this.GetDepth this.SetDepth
        member this.GetDepthLayered world = World.getEntityDepth this world + World.getLayerDepth (etol this) world
        member this.DepthLayered = PropertyTag.makeReadOnly this Property? DepthLayered this.GetDepthLayered
        member this.GetOverflow world = World.getEntityOverflow this world
        member this.SetOverflow value world = World.setEntityOverflow value this world
        member this.Overflow = PropertyTag.make this Property? Overflow this.GetOverflow this.SetOverflow
        member this.GetViewType world = World.getEntityViewType this world
        member this.SetViewType value world = World.setEntityViewType value this world
        member this.ViewType = PropertyTag.make this Property? ViewType this.GetViewType this.SetViewType
        member this.GetVisible world = World.getEntityVisible this world
        member this.SetVisible value world = World.setEntityVisible value this world
        member this.Visible = PropertyTag.make this Property? Visible this.GetVisible this.SetVisible
        member this.GetVisibleLayered world = World.getEntityVisible this world && World.getLayerVisible (etol this) world
        member this.VisibleLayered = PropertyTag.makeReadOnly this Property? VisibleLayered this.GetVisibleLayered
        member this.GetEnabled world = World.getEntityEnabled this world
        member this.SetEnabled value world = World.setEntityEnabled value this world
        member this.Enabled = PropertyTag.make this Property? Enabled this.GetEnabled this.SetEnabled
        member this.GetOmnipresent world = World.getEntityOmnipresent this world
        member this.SetOmnipresent value world = World.setEntityOmnipresent value this world
        member this.Omnipresent = PropertyTag.make this Property? Omnipresent this.GetOmnipresent this.SetOmnipresent
        member this.GetAlwaysUpdate world = World.getEntityAlwaysUpdate this world
        member this.SetAlwaysUpdate value world = World.setEntityAlwaysUpdate value this world
        member this.AlwaysUpdate = PropertyTag.make this Property? AlwaysUpdate this.GetAlwaysUpdate this.SetAlwaysUpdate
        member this.GetPublishChanges world = World.getEntityPublishChanges this world
        member this.SetPublishChanges value world = World.setEntityPublishChanges value this world
        member this.PublishChanges = PropertyTag.make this Property? PublishChanges this.GetPublishChanges this.SetPublishChanges
        member this.GetFacetNames world = World.getEntityFacetNames this world
        member this.FacetNames = PropertyTag.makeReadOnly this Property? FacetNames this.GetFacetNames
        member this.GetFacets world = World.getEntityFacets this world
        member this.Facets = PropertyTag.makeReadOnly this Property? Facets this.GetFacets

        /// Try to get a property value and type.
        member this.TryGetProperty propertyName world = World.tryGetEntityProperty propertyName this world

        /// Get a property value and type.
        member this.GetProperty propertyName world = World.getEntityProperty propertyName this world

        /// Get a property value.
        member this.Get<'a> propertyName world : 'a = (World.getEntityProperty propertyName this world).PropertyValue :?> 'a

        /// Try to set a property value with explicit type.
        member this.TrySetProperty propertyName alwaysPublish nonPersistent property world =
            World.trySetEntityProperty propertyName alwaysPublish nonPersistent property this world

        /// Set a property value with explicit type.
        member this.SetProperty propertyName alwaysPublish nonPersistent property world =
            World.setEntityProperty propertyName alwaysPublish nonPersistent property this world

        /// Attach a property.
        member this.AttachProperty propertyName alwaysPublish nonPersistent property world =
            World.attachEntityProperty propertyName alwaysPublish nonPersistent property this world

        /// Detach a property.
        member this.DetachProperty propertyName world =
            World.detachEntityProperty propertyName this world

        /// Set a property value.
        member this.Set<'a> propertyName (value : 'a) world =
            let alwaysPublish = Reflection.isPropertyAlwaysPublishByName propertyName
            let nonPersistent = not (Reflection.isPropertyPersistentByName propertyName)
            this.SetFast propertyName alwaysPublish nonPersistent value world

        /// Set a property value.
        member this.SetFast<'a> propertyName alwaysPublish nonPersistent (value : 'a) world =
            World.setEntityProperty propertyName alwaysPublish nonPersistent { PropertyType = typeof<'a>; PropertyValue = value } this world

        /// Get an entity's transform.
        member this.GetTransform world = World.getEntityTransform this world
        
        /// Set an entity's transform.
        member this.SetTransform value world = World.setEntityTransform value this world

        /// Get an entity's sorting priority.
        member this.GetSortingPriority world = World.getEntitySortingPriority this world

        /// Get an entity's quick size.
        member this.GetQuickSize world = World.getEntityQuickSize this world

        /// Set an entity's size by its quick size.
        member this.QuickSize world = World.setEntitySize (this.GetQuickSize world) this world

        /// Get an entity's bounds, not taking into account its overflow.
        member this.GetBounds world = Math.makeBounds (this.GetPosition world) (this.GetSize world)

        /// Get an entity's bounds, taking into account its overflow.
        member this.GetBoundsOverflow world = Math.makeBoundsOverflow (this.GetPosition world) (this.GetSize world) (this.GetOverflow world)

        /// Get an entity's bounds maximum.
        member this.GetBoundsMax world = World.getEntityBoundsMax this world

        /// Check that an entity is selected.
        member this.GetSelected world =
            match (World.getGameState world).OmniscreenOpt with
            | Some omniscreen when Address.head this.EntityAddress = Address.head omniscreen.ScreenAddress -> true
            | _ ->
                match (World.getGameState world).SelectedScreenOpt with
                | Some screen when Address.head this.EntityAddress = Address.head screen.ScreenAddress -> true
                | _ -> false

        /// Check that an entity is in the camera's view.
        member this.GetInView world =
            if not (this.GetOmnipresent world) then
                World.isBoundsInView
                    (this.GetViewType world)
{'fraction_non_alphanumeric': 0.0530935787625685, 'fraction_numerical': 0.0008511996595201362, 'mean_word_length': 3.2587222473946533, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5245406', 'n_tokens_mistral': 4472, 'n_tokens_neox': 4410, 'n_words': 1525}