using { /Fortnite.com }
using { /Fortnite.com/Devices }
using { /Verse.org }
using { /Verse.org/SceneGraph }
using { /Verse.org/Assets }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/UI }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Verse.org/SpatialMath }
using { /Verse.org/Colors }
XYZ:= import(/UnrealEngine.com/Temporary/SpatialMath)
my_debug_draw := class(debug_draw_channel) {}
raycast_component<public> := class<final_super>(component):
@editable
Trigger: trigger_device = trigger_device{}
@editable
Trigger2 : trigger_device = trigger_device{}
@editable
InputTrig : input_trigger_device = input_trigger_device{}
@editable
Carryable : carryable_spawner_device = carryable_spawner_device{}
DebugDraw:debug_draw = debug_draw{Channel := my_debug_draw}
var Bomb : logic = false
InputAwait()<suspends>:void=
loop:
Agent:=InputTrig.PressedEvent.Await()
if(FC:=Agent.GetFortCharacter[]):
ViewRot := XYZ.FromRotation(FC.GetViewRotation())
ViewXform := transform:
Translation := XYZ.FromVector3(FC.GetViewLocation())
Rotation:= ViewRot
HitsGen := Entity.FindSweepHits(ViewXform.Rotation.GetForwardAxis() * 3000.0, ViewXform, collision_point{})
HitsArray:= for(Hit:HitsGen) do Hit
if(FirstHit := HitsArray[0]):
DebugDraw.DrawLine(ViewXform.Translation, FirstHit.ContactPosition)
if(Box:=Meshes.MaterialBox[FirstHit.TargetComponent]):
Mat:MaterialStuff.MI_Box=MaterialStuff.MI_Box{}
set Box.Material_0 = Mat
set Mat.Colour = NamedColors.Red
if(Bomb?):
Carryable.SetGlobalTransform of transform:
Translation:=FirstHit.ContactPosition
Carryable.Spawn()
Carryable.Explode()
TriggerAwait()<suspends>:void=
mAgent:=Trigger.TriggeredEvent.Await()
if(Agent:=mAgent?):
InputTrig.Register(Agent)
spawn. InputAwait()
SetBomb(mAgent:?agent):void=
set Bomb = true
OnBeginSimulation<override>():void =
(super:)OnBeginSimulation()
OnSimulate<override>()<suspends>:void =
spawn. TriggerAwait()
Trigger2.TriggeredEvent.Subscribe(SetBomb)