RotateActorOnInputScriptElement.cs 999 B

12345678910111213141516171819202122232425262728293031
  1. using fun.Core;
  2. using System;
  3. using Environment = fun.Core.Environment;
  4. namespace fun.Basics.Skripts
  5. {
  6. public sealed class RotateActorOnInputScriptElement : Element
  7. {
  8. private readonly InputElement input;
  9. private readonly TransformElement transform;
  10. public RotateActorOnInputScriptElement(Environment environment, Entity entity)
  11. : base(environment, entity)
  12. {
  13. if (!entity.ContainsElement<InputElement>())
  14. throw new NotSupportedException();
  15. if (!entity.ContainsElement<TransformElement>())
  16. throw new NotSupportedException();
  17. input = entity.GetElement<InputElement>() as InputElement;
  18. transform = entity.GetElement<TransformElement>() as TransformElement;
  19. }
  20. public override void Update(double time)
  21. {
  22. transform.Rotation = input.Content;//new Vector3(input.MouseDelta.Y / 100f, 0f, input.MouseDelta.X / 100f);
  23. }
  24. }
  25. }