Neodroid  0.2.0
Machine Learning Environment Prototyping Tool
PlayerMotions.cs
Go to the documentation of this file.
1 using System;
2 using System.Text.RegularExpressions;
4 using UnityEngine;
5 
6 namespace droid.Runtime.Utilities.ScriptableObjects {
10  [CreateAssetMenu(fileName = "PlayerMotions",
11  menuName = ScriptableObjectMenuPath._ScriptableObjectMenuPath + "PlayerMotions",
12  order = 1)]
13  public class PlayerMotions : ScriptableObject {
17 
18  void OnValidate() {
19 /*
20  foreach (var motion in this._Motions) {
21  foreach (var motion2 in this._Motions) {
22  if (motion._Key == motion2._Key) {
23  Debug.LogWarning($"{motion} and {motion2} has the same Key");
24  }
25  }
26  }
27  */
28  var copy = this._Motions;
29  if (copy != null) {
30  for (var i = 0; i < copy.Length; i++) {
31  var actor = copy[i]._Actor;
32  if (actor != null) {
33  copy[i]._Actor = Regex.Replace(actor, "[^\\w\\._]", "");
34  }
35 
36  var actuator = copy[i]._Actuator;
37  if (actuator != null) {
38  copy[i]._Actuator = Regex.Replace(actuator, "[^\\w\\._]", "");
39  }
40  }
41  }
42 
43  this._Motions = copy;
44  }
45  }
46 
49  [Serializable]
50  public struct PlayerMotion {
53  [SearchableEnum]
54  public KeyCode _Key;
55 
58  public string _Actor;
59 
62  public string _Actuator;
63 
66  public float _Strength;
67  }
68 }