Skip to content

v1.0 Telekinecticon Component

Latest

Choose a tag to compare

@DarkThymes DarkThymes released this 28 Aug 21:41
a5d1a64

This one's a lot of fun with physics - just add the component to an entity in your level :)

using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Game }
using { /Fortnite.com/Items }
using { /UnrealEngine.com/Itemization }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
using { /Verse.org/SpatialMath }

XYZ:= import(/UnrealEngine.com/Temporary/SpatialMath)

round_subscribe := class:
    RoundEvent : event() = event(){}
    StartEvent()<suspends>:void= RoundEvent.Signal()

telekineticon_launcher_component<public> := class<final_super>(component):

    @editable
    Team : team_settings_and_inventory_device = team_settings_and_inventory_device{}

    LaunchSpeed : float = 25.0

    GrabRange : float = 1500.0

    HoldStiffness : float = 10000.0

    BreakDist : float = 600.0

    Granting()<suspends>:void=
        loop:
            Agent := Team.TeamMemberSpawnedEvent.Await()
            if(true?, Inventory := first{Inv : Agent.FindDescendantComponents(inventory_component)}):
                TK := Telekineticon_Creative_V1_Common{}
                Inventory.AddItemDistribute(TK)
                Sleep(0.1)
                if. ItemComp := TK.GetComponent[item_component] then ItemComp.Equip()
                if(TKComp := TK.GetComponent[telekineticon_component]):
                    set TKComp.GrabRange = GrabRange
                    set TKComp.HoldStiffness = HoldStiffness
                    set TKComp.BreakDistance = BreakDist
                    set TKComp.HoldPointType = telekineticon_hold_point.GrabPoint
                    set TKComp.HoldOrientationType = telekineticon_hold_orientation.None
                    spawn. Launching(Agent, TKComp)

    Launching(Agent : agent, TKComp : telekineticon_component)<suspends>:void=
        loop:
            Prop := TKComp.DropPropEvent.Await()
            if(FC := Agent.GetFortCharacter[]):
                Prop.ApplyLinearImpulse(XYZ.FromRotation(FC.GetViewRotation()).GetForwardAxis() * Prop.GetMass() * LaunchSpeed)

    RoundAwait()<suspends>:void=
        if(Rounder := Entity.GetFortRoundManager[]):
            RoundSub := round_subscribe{}
            race:
                RoundSub.RoundEvent.Await()
                block:
                    Rounder.SubscribeRoundStarted(RoundSub.StartEvent)
                    Sleep(Inf)

    OnSimulate<override>()<suspends>:void=
        RoundAwait()
        spawn. Granting()