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

namespace Nu
open System
open System.ComponentModel
open FSharpx.Collections
open OpenTK
open Prime
open TiledSharp
open Prime
open Nu

[<AutoOpen>]
module MountFacetModule =

    type Entity with
    
        member this.GetOptMountRelation world : Entity Relation option = (this.GetXtension world)?OptMountRelation
        member this.SetOptMountRelation (value : Entity Relation option) world = this.UpdateXtension (fun xtension -> xtension?OptMountRelation <- value) world
        member this.GetPositionLocal world : Vector2 = (this.GetXtension world)?PositionLocal
        member this.SetPositionLocal (value : Vector2) world = this.UpdateXtension (fun xtension -> xtension?PositionLocal <- value) world
        member this.GetDepthLocal world : single = (this.GetXtension world)?DepthLocal
        member this.SetDepthLocal (value : single) world = this.UpdateXtension (fun xtension -> xtension?DepthLocal <- value) world
        member private this.GetMountUpdateCountNp world : int64 = (this.GetXtension world)?MountUpdateCountNp
        member private this.SetMountUpdateCountNp (value : int64) world = this.UpdateXtension (fun xtension -> xtension?MountUpdateCountNp <- value) world
        member private this.GetMountUnsubscribeNp world : World -> World = (this.GetXtension world)?MountUnsubscribeNp
        member private this.SetMountUnsubscribeNp (value : World -> World) world = this.UpdateXtension (fun xtension -> xtension?MountUnsubscribeNp <- value) world

    type MountFacet () =
        inherit Facet ()

        static let handleRelationChange evt world =
            let entity = evt.Subscriber : Entity
            let target = evt.Publisher :?> Entity
            let transform = target.GetTransform world
            let updateCount = World.getUpdateCount world
            if  transform <> target.GetTransform evt.Data.OldWorld &&
                updateCount <> entity.GetMountUpdateCountNp world then
                let transform =
                    { transform with
                        Position = transform.Position + entity.GetPositionLocal world
                        Depth = transform.Depth + entity.GetDepthLocal world }
                let world = entity.SetTransform transform world
                let world = entity.SetMountUpdateCountNp updateCount world
                (Cascade, world)
            else (Cascade, world)

        static let rec handleEntityChange evt world =
            let entity = evt.Subscriber : Entity
            if entity.GetOptMountRelation evt.Data.OldWorld <> entity.GetOptMountRelation world then
                let world = (entity.GetMountUnsubscribeNp world) world
                let (unsubscribe, world) = World.monitorPlus handleRelationChange (Events.EntityChange ->- entity) entity world
                let world = entity.SetMountUnsubscribeNp unsubscribe world
                (Cascade, world)
            else (Cascade, world)

        static member PropertyDefinitions =
            [Define? PublishChanges true
             Define? OptMountRelation (None : Entity Relation option)
             Define? PositionLocal Vector2.Zero
             Define? DepthLocal 0.0f
             Define? MountUpdateCountNp Int64.MinValue
             Define? MountUnsubscribeNp (id : World -> World)]

        override facet.Register (entity, world) =
            let world = World.monitor handleEntityChange (Events.EntityChange ->- entity) entity world
            let (unsubscribe, world) =
                match entity.GetOptMountRelation world with
                | Some target ->
                    let address = Relation.resolve entity.EntityAddress target
                    World.monitorPlus handleRelationChange (Events.EntityChange ->>- address) entity world
                | None -> (id, world)
            entity.SetMountUnsubscribeNp unsubscribe world

[<AutoOpen>]
module EffectFacetModule =

    type EffectTags =
        Map<string, Symbol * Slice list>

    type Entity with
    
        member this.GetOptEffects world : AssetTag list option = (this.GetXtension world)?OptEffects
        member this.SetOptEffects (value : AssetTag list option) world = this.UpdateXtension (fun xtension -> xtension?OptEffects <- value) world
        member this.GetOptEffectsLc world : AssetTag list option = (this.GetXtension world)?OptEffectsLc
        member private this.SetOptEffectsLc (value : AssetTag list option) world = this.UpdateXtension (fun xtension -> xtension?OptEffectsLc <- value) world
        member this.GetEffectDefinitions world : Definitions = (this.GetXtension world)?EffectDefinitions
        member this.SetEffectDefinitions (value : Definitions) world = this.UpdateXtension (fun xtension -> xtension?EffectDefinitions <- value) world
        member this.GetEffect world : Effect = (this.GetXtension world)?Effect
        member this.SetEffect (value : Effect) world = this.UpdateXtension (fun xtension -> xtension?Effect <- value) world
        member this.GetEffectOffset world : Vector2 = (this.GetXtension world)?EffectOffset
        member this.SetEffectOffset (value : Vector2) world = this.UpdateXtension (fun xtension -> xtension?EffectOffset <- value) world
        member this.GetEffectTimeOffset world : int64 = (this.GetXtension world)?EffectTimeOffset
        member this.SetEffectTimeOffset (value : int64) world = this.UpdateXtension (fun xtension -> xtension?EffectHistoryMax <- value) world
        member this.GetEffectHistoryMax world : int = (this.GetXtension world)?EffectHistoryMax
        member this.SetEffectHistoryMax (value : int) world = this.UpdateXtension (fun xtension -> xtension?EffectHistoryMax <- value) world
        member this.GetEffectHistoryNp world : Slice Deque = (this.GetXtension world)?EffectHistoryNp
        member private this.SetEffectHistoryNp (value : Slice Deque) world = this.UpdateXtension (fun xtension -> xtension?EffectHistoryNp <- value) world
        member this.GetEffectPhysicsShapesNp world : unit = (this.GetXtension world)?EffectPhysicsShapesNp // NOTE: the default EffectFacet leaves it up to the Dispatcher to do something with the effect's physics output
        member private this.SetEffectPhysicsShapesNp (value : unit) world = this.UpdateXtension (fun xtension -> xtension?EffectPhysicsShapesNp <- value) world
        member this.GetEffectTagsNp world : EffectTags = (this.GetXtension world)?EffectTagsNp
        member private this.SetEffectTagsNp (value : EffectTags) world = this.UpdateXtension (fun xtension -> xtension?EffectTagsNp <- value) world

    type EffectFacet () =
        inherit Facet ()

        static let assetTagsToOptEffects assetTags world =
            let (optSymbols, world) = World.tryFindSymbols assetTags world
            let optEffects =
                List.map
                    (fun optSymbol ->
                        match optSymbol with
                        | Some symbol ->
                            try let effect = valueize<Effect> symbol in Some effect
                            with exn -> Log.info ^ "Failed to convert symbol '" + scstring symbol + "' to Effect due to: " + scstring exn; None
                        | None -> None)
                    optSymbols
            (optEffects, world)

        static member PropertyDefinitions =
            [Define? OptEffects (None : AssetTag list option)
             Define? OptEffectsLc (None : AssetTag list option)
             Define? EffectDefinitions (Map.empty : Definitions)
             Define? Effect Effect.empty
             Define? EffectOffset Vector2.Zero
             Define? EffectTimeOffset 0L // TODO: also implement similar time offset for AnimatedSpriteFacet
             Define? EffectHistoryMax Constants.Effects.DefaultEffectHistoryMax
             Define? EffectHistoryNp Deque.empty<Slice>
             Define? EffectPhysicsShapesNp ()
             Define? EffectTagsNp (Map.empty : EffectTags)]

        override facet.Actualize (entity, world) =
            if entity.InView world then
                let world = entity.SetEffectTagsNp Map.empty world
                let time = World.getTickTime world
                let timeOffset = entity.GetEffectTimeOffset world
                let effect = entity.GetEffect world
                let effectTime = time - timeOffset
                let effectRate = World.getTickRate world
                let effectViewType = entity.GetViewType world
                let effectSlice =
                    { Position = entity.GetPosition world + Vector2.Multiply (entity.GetSize world, entity.GetEffectOffset world)
                      Size = entity.GetSize world
                      Rotation = entity.GetRotation world
                      Depth = entity.GetDepth world
                      Offset = Vector2 0.5f
                      Color = Vector4.One
                      Enabled = true
                      Volume = 1.0f }
                let effectHistory = entity.GetEffectHistoryNp world
                let effectEnv = entity.GetEffectDefinitions world
                let effectSystem = EffectSystem.make effectViewType effectHistory effectRate effectTime effectEnv
                let world =
                    let artifacts = EffectSystem.eval effect effectSlice effectSystem
                    List.fold (fun world artifact ->
                        match artifact with
                        | RenderArtifact renderDescriptors -> World.addRenderMessage (RenderDescriptorsMessage renderDescriptors) world
                        | SoundArtifact (volume, sound) -> World.playSound volume sound world
                        | TagArtifact (name, metadata, slice) ->
                            let effectTags = entity.GetEffectTagsNp world
                            let effectTags =
                                match Map.tryFind name effectTags with
                                | Some (metadata, slices) -> Map.add name (metadata, slice :: slices) effectTags
                                | None -> Map.add name (metadata, [slice]) effectTags
                            // TODO: also raise event for all new effect tags so they can be handled in scripts?
                            entity.SetEffectTagsNp effectTags world)
                        world
                        artifacts
                let effectHistoryMax = entity.GetEffectHistoryMax world
                let effectHistory = effectHistory |> Deque.cons effectSlice 
                let effectHistory = if Deque.length effectHistory > effectHistoryMax then fst ^ Deque.unconj effectHistory else effectHistory
                entity.SetEffectHistoryNp effectHistory world
            else world

        override facet.Update (entity, world) =
            let optEffectsLc = entity.GetOptEffectsLc world
            let optEffects = entity.GetOptEffects world
            if optEffectsLc <> optEffects then
                let world =
                    match optEffects with
                    | Some effectAssetTags ->
                        let (optEffects, world) = assetTagsToOptEffects effectAssetTags world
                        let effects = List.definitize optEffects
                        let effectCombined = EffectSystem.combineEffects effects
                        entity.SetEffect effectCombined world
                    | None -> entity.SetEffect Effect.empty world
                entity.SetOptEffectsLc optEffects world
            else world

[<AutoOpen>]
module RigidBodyFacetModule =

    type Entity with

        member this.GetMinorId world : Guid = (this.GetXtension world)?MinorId
        member this.SetMinorId (value : Guid) world = this.UpdateXtension (fun xtension -> xtension?MinorId <- value) world
        member this.GetBodyType world : BodyType = (this.GetXtension world)?BodyType
        member this.SetBodyType (value : BodyType) world = this.UpdateXtension (fun xtension -> xtension?BodyType <- value) world
        member this.GetAwake world : bool = (this.GetXtension world)?Awake
        member this.SetAwake (value : bool) world = this.UpdateXtension (fun xtension -> xtension?Awake <- value) world
        member this.GetEnabled world : bool = (this.GetXtension world)?Enabled
        member this.SetEnabled (value : bool) world = this.UpdateXtension (fun xtension -> xtension?Enabled <- value) world
        member this.GetDensity world : single = (this.GetXtension world)?Density
        member this.SetDensity (value : single) world = this.UpdateXtension (fun xtension -> xtension?Density <- value) world
        member this.GetFriction world : single = (this.GetXtension world)?Friction
        member this.SetFriction (value : single) world = this.UpdateXtension (fun xtension -> xtension?Friction <- value) world
        member this.GetRestitution world : single = (this.GetXtension world)?Restitution
        member this.SetRestitution (value : single) world = this.UpdateXtension (fun xtension -> xtension?Restitution <- value) world
        member this.GetFixedRotation world : bool = (this.GetXtension world)?FixedRotation
        member this.SetFixedRotation (value : bool) world = this.UpdateXtension (fun xtension -> xtension?FixedRotation <- value) world
        member this.GetAngularVelocity world : single = (this.GetXtension world)?AngularVelocity
        member this.SetAngularVelocity (value : single) world = this.UpdateXtension (fun xtension -> xtension?AngularVelocity <- value) world
        member this.GetAngularDamping world : single = (this.GetXtension world)?AngularDamping
        member this.SetAngularDamping (value : single) world = this.UpdateXtension (fun xtension -> xtension?AngularDamping <- value) world
        member this.GetLinearVelocity world : Vector2 = (this.GetXtension world)?LinearVelocity
        member this.SetLinearVelocity (value : Vector2) world = this.UpdateXtension (fun xtension -> xtension?LinearVelocity <- value) world
        member this.GetLinearDamping world : single = (this.GetXtension world)?LinearDamping
        member this.SetLinearDamping (value : single) world = this.UpdateXtension (fun xtension -> xtension?LinearDamping <- value) world
        member this.GetGravityScale world : single = (this.GetXtension world)?GravityScale<commit_msg>Temporarily removed external effects so I can patch a bug in release.<commit_after>﻿// Nu Game Engine.
// Copyright (C) <NAME>, 2012-2016.

namespace Nu
open System
open System.ComponentModel
open FSharpx.Collections
open OpenTK
open Prime
open TiledSharp
open Prime
open Nu

[<AutoOpen>]
module MountFacetModule =

    type Entity with
    
        member this.GetOptMountRelation world : Entity Relation option = (this.GetXtension world)?OptMountRelation
        member this.SetOptMountRelation (value : Entity Relation option) world = this.UpdateXtension (fun xtension -> xtension?OptMountRelation <- value) world
        member this.GetPositionLocal world : Vector2 = (this.GetXtension world)?PositionLocal
        member this.SetPositionLocal (value : Vector2) world = this.UpdateXtension (fun xtension -> xtension?PositionLocal <- value) world
        member this.GetDepthLocal world : single = (this.GetXtension world)?DepthLocal
        member this.SetDepthLocal (value : single) world = this.UpdateXtension (fun xtension -> xtension?DepthLocal <- value) world
        member private this.GetMountUpdateCountNp world : int64 = (this.GetXtension world)?MountUpdateCountNp
        member private this.SetMountUpdateCountNp (value : int64) world = this.UpdateXtension (fun xtension -> xtension?MountUpdateCountNp <- value) world
        member private this.GetMountUnsubscribeNp world : World -> World = (this.GetXtension world)?MountUnsubscribeNp
        member private this.SetMountUnsubscribeNp (value : World -> World) world = this.UpdateXtension (fun xtension -> xtension?MountUnsubscribeNp <- value) world

    type MountFacet () =
        inherit Facet ()

        static let handleRelationChange evt world =
            let entity = evt.Subscriber : Entity
            let target = evt.Publisher :?> Entity
            let transform = target.GetTransform world
            let updateCount = World.getUpdateCount world
            if  transform <> target.GetTransform evt.Data.OldWorld &&
                updateCount <> entity.GetMountUpdateCountNp world then
                let transform =
                    { transform with
                        Position = transform.Position + entity.GetPositionLocal world
                        Depth = transform.Depth + entity.GetDepthLocal world }
                let world = entity.SetTransform transform world
                let world = entity.SetMountUpdateCountNp updateCount world
                (Cascade, world)
            else (Cascade, world)

        static let rec handleEntityChange evt world =
            let entity = evt.Subscriber : Entity
            if entity.GetOptMountRelation evt.Data.OldWorld <> entity.GetOptMountRelation world then
                let world = (entity.GetMountUnsubscribeNp world) world
                let (unsubscribe, world) = World.monitorPlus handleRelationChange (Events.EntityChange ->- entity) entity world
                let world = entity.SetMountUnsubscribeNp unsubscribe world
                (Cascade, world)
            else (Cascade, world)

        static member PropertyDefinitions =
            [Define? PublishChanges true
             Define? OptMountRelation (None : Entity Relation option)
             Define? PositionLocal Vector2.Zero
             Define? DepthLocal 0.0f
             Define? MountUpdateCountNp Int64.MinValue
             Define? MountUnsubscribeNp (id : World -> World)]

        override facet.Register (entity, world) =
            let world = World.monitor handleEntityChange (Events.EntityChange ->- entity) entity world
            let (unsubscribe, world) =
                match entity.GetOptMountRelation world with
                | Some target ->
                    let address = Relation.resolve entity.EntityAddress target
                    World.monitorPlus handleRelationChange (Events.EntityChange ->>- address) entity world
                | None -> (id, world)
            entity.SetMountUnsubscribeNp unsubscribe world

[<AutoOpen>]
module EffectFacetModule =

    type EffectTags =
        Map<string, Symbol * Slice list>

    type Entity with

//        member this.GetOptEffects world : AssetTag list option = (this.GetXtension world)?OptEffects
//        member this.SetOptEffects (value : AssetTag list option) world = this.UpdateXtension (fun xtension -> xtension?OptEffects <- value) world
//        member this.GetOptEffectsLc world : AssetTag list option = (this.GetXtension world)?OptEffectsLc
//        member private this.SetOptEffectsLc (value : AssetTag list option) world = this.UpdateXtension (fun xtension -> xtension?OptEffectsLc <- value) world
        member this.GetEffectDefinitions world : Definitions = (this.GetXtension world)?EffectDefinitions
        member this.SetEffectDefinitions (value : Definitions) world = this.UpdateXtension (fun xtension -> xtension?EffectDefinitions <- value) world
        member this.GetEffect world : Effect = (this.GetXtension world)?Effect
        member this.SetEffect (value : Effect) world = this.UpdateXtension (fun xtension -> xtension?Effect <- value) world
        member this.GetEffectOffset world : Vector2 = (this.GetXtension world)?EffectOffset
        member this.SetEffectOffset (value : Vector2) world = this.UpdateXtension (fun xtension -> xtension?EffectOffset <- value) world
        member this.GetEffectTimeOffset world : int64 = (this.GetXtension world)?EffectTimeOffset
        member this.SetEffectTimeOffset (value : int64) world = this.UpdateXtension (fun xtension -> xtension?EffectHistoryMax <- value) world
        member this.GetEffectHistoryMax world : int = (this.GetXtension world)?EffectHistoryMax
        member this.SetEffectHistoryMax (value : int) world = this.UpdateXtension (fun xtension -> xtension?EffectHistoryMax <- value) world
        member this.GetEffectHistoryNp world : Slice Deque = (this.GetXtension world)?EffectHistoryNp
        member private this.SetEffectHistoryNp (value : Slice Deque) world = this.UpdateXtension (fun xtension -> xtension?EffectHistoryNp <- value) world
        member this.GetEffectPhysicsShapesNp world : unit = (this.GetXtension world)?EffectPhysicsShapesNp // NOTE: the default EffectFacet leaves it up to the Dispatcher to do something with the effect's physics output
        member private this.SetEffectPhysicsShapesNp (value : unit) world = this.UpdateXtension (fun xtension -> xtension?EffectPhysicsShapesNp <- value) world
        member this.GetEffectTagsNp world : EffectTags = (this.GetXtension world)?EffectTagsNp
        member private this.SetEffectTagsNp (value : EffectTags) world = this.UpdateXtension (fun xtension -> xtension?EffectTagsNp <- value) world

    type EffectFacet () =
        inherit Facet ()

        //static let assetTagsToOptEffects assetTags world =
        //    let (optSymbols, world) = World.tryFindSymbols assetTags world
        //    let optEffects =
        //        List.map
        //            (fun optSymbol ->
        //                match optSymbol with
        //                | Some symbol ->
        //                    try let effect = valueize<Effect> symbol in Some effect
        //                    with exn -> Log.info ^ "Failed to convert symbol '" + scstring symbol + "' to Effect due to: " + scstring exn; None
        //                | None -> None)
        //            optSymbols
        //    (optEffects, world)

        static member PropertyDefinitions =
            [//Define? OptEffects (None : AssetTag list option)
             //Define? OptEffectsLc (None : AssetTag list option)
             Define? EffectDefinitions (Map.empty : Definitions)
             Define? Effect Effect.empty
             Define? EffectOffset Vector2.Zero
             Define? EffectTimeOffset 0L // TODO: also implement similar time offset for AnimatedSpriteFacet
             Define? EffectHistoryMax Constants.Effects.DefaultEffectHistoryMax
             Define? EffectHistoryNp Deque.empty<Slice>
             Define? EffectPhysicsShapesNp ()
             Define? EffectTagsNp (Map.empty : EffectTags)]

        override facet.Actualize (entity, world) =
            if entity.InView world then
                let world = entity.SetEffectTagsNp Map.empty world
                let time = World.getTickTime world
                let timeOffset = entity.GetEffectTimeOffset world
                let effect = entity.GetEffect world
                let effectTime = time - timeOffset
                let effectRate = World.getTickRate world
                let effectViewType = entity.GetViewType world
                let effectSlice =
                    { Position = entity.GetPosition world + Vector2.Multiply (entity.GetSize world, entity.GetEffectOffset world)
                      Size = entity.GetSize world
                      Rotation = entity.GetRotation world
                      Depth = entity.GetDepth world
                      Offset = Vector2 0.5f
                      Color = Vector4.One
                      Enabled = true
                      Volume = 1.0f }
                let effectHistory = entity.GetEffectHistoryNp world
                let effectEnv = entity.GetEffectDefinitions world
                let effectSystem = EffectSystem.make effectViewType effectHistory effectRate effectTime effectEnv
                let world =
                    let artifacts = EffectSystem.eval effect effectSlice effectSystem
                    List.fold (fun world artifact ->
                        match artifact with
                        | RenderArtifact renderDescriptors -> World.addRenderMessage (RenderDescriptorsMessage renderDescriptors) world
                        | SoundArtifact (volume, sound) -> World.playSound volume sound world
                        | TagArtifact (name, metadata, slice) ->
                            let effectTags = entity.GetEffectTagsNp world
                            let effectTags =
                                match Map.tryFind name effectTags with
                                | Some (metadata, slices) -> Map.add name (metadata, slice :: slices) effectTags
                                | None -> Map.add name (metadata, [slice]) effectTags
                            // TODO: also raise event for all new effect tags so they can be handled in scripts?
                            entity.SetEffectTagsNp effectTags world)
                        world
                        artifacts
                let effectHistoryMax = entity.GetEffectHistoryMax world
                let effectHistory = effectHistory |> Deque.cons effectSlice 
                let effectHistory = if Deque.length effectHistory > effectHistoryMax then fst ^ Deque.unconj effectHistory else effectHistory
                entity.SetEffectHistoryNp effectHistory world
            else world

        //override facet.Update (entity, world) =
        //    let optEffectsLc = entity.GetOptEffectsLc world
        //    let optEffects = entity.GetOptEffects world
        //    if optEffectsLc <> optEffects then
        //        let world =
        //            match optEffects with
        //            | Some effectAssetTags ->
        //                let (optEffects, world) = assetTagsToOptEffects effectAssetTags world
        //                let effects = List.definitize optEffects
        //                let effectCombined = EffectSystem.combineEffects effects
        //                entity.SetEffect effectCombined world
        //            | None -> entity.SetEffect Effect.empty world
        //        entity.SetOptEffectsLc optEffects world
        //    else world

[<AutoOpen>]
module RigidBodyFacetModule =

    type Entity with

        member this.GetMinorId world : Guid = (this.GetXtension world)?MinorId
        member this.SetMinorId (value : Guid) world = this.UpdateXtension (fun xtension -> xtension?MinorId <- value) world
        member this.GetBodyType world : BodyType = (this.GetXtension world)?BodyType
        member this.SetBodyType (value : BodyType) world = this.UpdateXtension (fun xtension -> xtension?BodyType <- value) world
        member this.GetAwake world : bool = (this.GetXtension world)?Awake
        member this.SetAwake (value : bool) world = this.UpdateXtension (fun xtension -> xtension?Awake <- value) world
        member this.GetEnabled world : bool = (this.GetXtension world)?Enabled
        member this.SetEnabled (value : bool) world = this.UpdateXtension (fun xtension -> xtension?Enabled <- value) world
        member this.GetDensity world : single = (this.GetXtension world)?Density
        member this.SetDensity (value : single) world = this.UpdateXtension (fun xtension -> xtension?Density <- value) world
        member this.GetFriction world : single = (this.GetXtension world)?Friction
        member this.SetFriction (value : single) world = this.UpdateXtension (fun xtension -> xtension?Friction <- value) world
        member this.GetRestitution world : single = (this.GetXtension world)?Restitution
        member this.SetRestitution (value : single) world = this.UpdateXtension (fun xtension -> xtension?Restitution <- value) world
        member this.GetFixedRotation world : bool = (this.GetXtension world)?FixedRotation
        member this.SetFixedRotation (value : bool) world = this.UpdateXtension (fun xtension -> xtension?FixedRotation <- value) world
        member this.GetAngularVelocity world : single = (this.GetXtension world)?AngularVelocity
        member this.SetAngularVelocity (value : single) world = this.UpdateXtension (fun xtension -> xtension?AngularVelocity <- value) world
        member this.GetAngularDamping world : single = (this.GetXtension world)?AngularDamping
        member this.SetAngularDamping (value : single) world = this.UpdateXtension (fun xtension -> xtension?AngularDamping <- value) world
        member this.GetLinearVelocity world : Vector2 = (this.GetXtension world)?LinearVelocity
        member this.SetLinearVelocity (value : Vector2) world = this.UpdateXtension (fun xtension -> xtension?LinearVelocity <- value) world
        member this.GetLinearDamping world : single = (this.GetXtension world)?LinearDamping
        member this.SetLinearDamping (value : single) world = this.UpdateXtension (fun xtension -> xtension?LinearDamping <- value) world
        member this.GetGravityScale world : single = (this.GetXtension world)?GravityScale
{'fraction_non_alphanumeric': 0.06977149226696391, 'fraction_numerical': 0.002508011704054619, 'mean_word_length': 2.397916913244171, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 127, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7220479', 'n_tokens_mistral': 7386, 'n_tokens_neox': 7066, 'n_words': 2126}