クラッシュパッドの状態を切り替え

要件

  1. ボタンの仕掛けを二つ設置する(A, B)
  2. クラッシュパッドの仕掛けを設置する
  3. ボタンAを押すとクラッシュパッドが有効になる
  4. ボタンBを押すとクラッシュパッドが無効になる

使用する仕掛け

  1. ボタンの仕掛け(x2)
  2. クラッシュパッドの仕掛け(x1)

回答

回答を見る
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

change_crashpad_state_device := class(creative_device):
    @editable
    EnableButtonDevice:button_device = button_device{}
    @editable
    DisableButtonDevice:button_device = button_device{}
    @editable
    CrashPadDevice:crash_pad_device = crash_pad_device{}

    OnBegin<override>()<suspends>:void=
        EnableButtonDevice.InteractedWithEvent.Subscribe(OnInteractEnable)
        DisableButtonDevice.InteractedWithEvent.Subscribe(OnInteractDisable)

    OnInteractEnable(Agent:agent):void=
        CrashPadDevice.Enable()

    OnInteractDisable(Agent:agent):void=
        CrashPadDevice.Disable()