initial commit
This commit is contained in:
31
Shared/Behaviours/RotatorToggler.cs
Normal file
31
Shared/Behaviours/RotatorToggler.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using Engine.Core;
|
||||
using Engine.Integration.MonoGame;
|
||||
using Engine.Systems.Input;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
||||
namespace MyUniverse.Shared.Behaviours;
|
||||
|
||||
public class RotatorToggler : Behaviour2D, IFirstFrameUpdate, ILastFrameUpdate
|
||||
{
|
||||
private IRotator rotator = null!;
|
||||
private KeyboardInputs inputs = null!;
|
||||
|
||||
public void FirstActiveFrame()
|
||||
{
|
||||
rotator = BehaviourController.GetRequiredBehaviour<IRotator>();
|
||||
inputs = Universe.FindRequiredBehaviour<KeyboardInputs>();
|
||||
|
||||
inputs.RegisterOnPress(Keys.Space, ToggleRotator);
|
||||
}
|
||||
|
||||
private void ToggleRotator(IButtonInputs<Keys> sender, IButtonInputs<Keys>.ButtonCallbackArguments args)
|
||||
{
|
||||
rotator.StateEnable.Enabled = !rotator.StateEnable.Enabled;
|
||||
}
|
||||
|
||||
public void LastActiveFrame()
|
||||
{
|
||||
inputs.UnregisterOnPress(Keys.Space, ToggleRotator);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user