Skip to content

Commit 2cca120

Browse files
author
Damian_AntWorkshop
committed
Naming of classes is now more consistent. Fixed conventions of some method parameters
1 parent 8d2cf62 commit 2cca120

15 files changed

+63
-142
lines changed

FSM/Entity State Manager.asset

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -39,79 +39,3 @@ MonoBehaviour:
3939
serializedVersion: 2
4040
m_Bits: 0
4141
unityObjectValue: {fileID: 0}
42-
- name: ControllerMoveState
43-
fields:
44-
- name: age
45-
fieldType: 1
46-
intValue: 0
47-
floatValue: 0
48-
boolValue: 0
49-
stringValue:
50-
vector2Value: {x: 0, y: 0}
51-
vector3Value: {x: 0, y: 0, z: 0}
52-
layerMaskValue:
53-
serializedVersion: 2
54-
m_Bits: 0
55-
unityObjectValue: {fileID: 0}
56-
- name: fixedAge
57-
fieldType: 1
58-
intValue: 0
59-
floatValue: 0
60-
boolValue: 0
61-
stringValue:
62-
vector2Value: {x: 0, y: 0}
63-
vector3Value: {x: 0, y: 0, z: 0}
64-
layerMaskValue:
65-
serializedVersion: 2
66-
m_Bits: 0
67-
unityObjectValue: {fileID: 0}
68-
- name: moveSpeed
69-
fieldType: 1
70-
intValue: 0
71-
floatValue: 0
72-
boolValue: 0
73-
stringValue:
74-
vector2Value: {x: 0, y: 0}
75-
vector3Value: {x: 0, y: 0, z: 0}
76-
layerMaskValue:
77-
serializedVersion: 2
78-
m_Bits: 0
79-
unityObjectValue: {fileID: 0}
80-
- name: canJump
81-
fieldType: 3
82-
intValue: 0
83-
floatValue: 0
84-
boolValue: 0
85-
stringValue:
86-
vector2Value: {x: 0, y: 0}
87-
vector3Value: {x: 0, y: 0, z: 0}
88-
layerMaskValue:
89-
serializedVersion: 2
90-
m_Bits: 0
91-
unityObjectValue: {fileID: 0}
92-
- name: BulletHellState
93-
fields:
94-
- name: age
95-
fieldType: 1
96-
intValue: 0
97-
floatValue: 0
98-
boolValue: 0
99-
stringValue:
100-
vector2Value: {x: 0, y: 0}
101-
vector3Value: {x: 0, y: 0, z: 0}
102-
layerMaskValue:
103-
serializedVersion: 2
104-
m_Bits: 0
105-
unityObjectValue: {fileID: 0}
106-
- name: fixedAge
107-
fieldType: 1
108-
intValue: 0
109-
floatValue: 0
110-
boolValue: 0
111-
stringValue:
112-
vector2Value: {x: 0, y: 0}
113-
vector3Value: {x: 0, y: 0, z: 0}
114-
layerMaskValue:
115-
serializedVersion: 2
116-
m_Bits: 0
117-
unityObjectValue: {fileID: 0}

FSM/Scripts/Editor/EditorCatergory.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Collections.Generic;
2-
using System.Linq;
32
using UnityEngine;
43

54
namespace FSM.Editors

FSM/Scripts/Editor/EntityStateMachineEditor.cs renamed to FSM/Scripts/Editor/StateMachineEditor.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
namespace FSM.Editors
1010
{
11-
[CustomEditor (typeof (EntityStateMachine))]
12-
public class EntityStateMachineEditor : Editor
11+
[CustomEditor (typeof (StateMachine))]
12+
public class StateMachineEditor : Editor
1313
{
1414
public struct StateName
1515
{
@@ -41,7 +41,7 @@ public StateName(string fullName, string displayName)
4141
private static string[] StateNames;
4242

4343
// Target
44-
private EntityStateMachine t;
44+
private StateMachine t;
4545

4646
// Cache selection data for easier references
4747
private int stateIndex;
@@ -60,7 +60,7 @@ public StateName(string fullName, string displayName)
6060

6161
private void OnEnable()
6262
{
63-
t = target as EntityStateMachine;
63+
t = target as StateMachine;
6464

6565
SetupCategories ();
6666

@@ -165,9 +165,9 @@ private void DrawCategories()
165165
}
166166
}
167167

168-
private void DrawStates(string[] _states)
168+
private void DrawStates(string[] states)
169169
{
170-
if (_states == null)
170+
if (states == null)
171171
{
172172
EditorGUILayout.HelpBox ("Category has no states", MessageType.Error);
173173
return;
@@ -177,7 +177,7 @@ private void DrawStates(string[] _states)
177177

178178
//int xCount = Mathf.Min (_states.Length, 3);
179179

180-
stateIndex = GUILayout.SelectionGrid (stateIndex, _states, 3);
180+
stateIndex = GUILayout.SelectionGrid (stateIndex, states, 3);
181181

182182
if (EditorGUI.EndChangeCheck())
183183
{
@@ -209,17 +209,17 @@ private void DrawRuntimeInfo()
209209

210210
// State GUI
211211

212-
private void DrawStateData(string _label, State _state, ref bool _toggle)
212+
private void DrawStateData(string label, State state, ref bool toggle)
213213
{
214-
bool isNull = _state == null;
214+
bool isNull = state == null;
215215

216-
string stateName = isNull ? "" : GetStateName(_state.ToString());
217-
float age = isNull ? 0f : _state.age;
218-
float fixedAge = isNull ? 0f : _state.age;
216+
string stateName = isNull ? "" : GetStateName(state.ToString());
217+
float age = isNull ? 0f : state.age;
218+
float fixedAge = isNull ? 0f : state.age;
219219

220-
_toggle = EditorGUILayout.Foldout (_toggle, _label);
220+
toggle = EditorGUILayout.Foldout (toggle, label);
221221

222-
if (_toggle)
222+
if (toggle)
223223
{
224224
EditorGUILayout.TextField ("State Name", stateName);
225225

@@ -269,29 +269,29 @@ private void GetSelectionIndexes()
269269

270270
// Helpers
271271

272-
private string GetStateName(string _stateName)
272+
private string GetStateName(string stateName)
273273
{
274-
int nameIndex = _stateName.LastIndexOf ('.');
274+
int nameIndex = stateName.LastIndexOf ('.');
275275

276-
_stateName = _stateName.Substring (nameIndex + 1, _stateName.Length - nameIndex - 1);
276+
stateName = stateName.Substring (nameIndex + 1, stateName.Length - nameIndex - 1);
277277

278278
// Slight clean up
279-
if (!_stateName.Equals("State"))
279+
if (!stateName.Equals("State"))
280280
{
281-
_stateName = _stateName.Replace ("State", "");
281+
stateName = stateName.Replace ("State", "");
282282
}
283283

284-
return _stateName;
284+
return stateName;
285285
}
286286

287-
private string GetGroupName(string _stateName)
287+
private string GetGroupName(string stateName)
288288
{
289-
int nameIndex = _stateName.LastIndexOf ('.');
289+
int nameIndex = stateName.LastIndexOf ('.');
290290

291-
string category = _stateName.Substring (0, nameIndex);
291+
string category = stateName.Substring (0, nameIndex);
292292
int categoryIndex = category.LastIndexOf ('.');
293293

294-
return _stateName.Substring (categoryIndex + 1, category.Length - categoryIndex - 1);
294+
return stateName.Substring (categoryIndex + 1, category.Length - categoryIndex - 1);
295295
}
296296
}
297297
}
File renamed without changes.

FSM/Scripts/Editor/EntityStateManagerEditor.cs renamed to FSM/Scripts/Editor/StateManagerEditor.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
1+
using System.Collections.Generic;
32
using System.Linq;
43
using UnityEditor;
54
using UnityEditorInternal;
@@ -9,8 +8,8 @@
98
namespace FSM.Editors
109
{
1110
//TODO: Better lookup for states, catergories are setup painfully bad
12-
[CustomEditor (typeof (EntityStateManager))]
13-
public class EntityStateManagerEditor : Editor
11+
[CustomEditor (typeof (StateManager))]
12+
public class StateManagerEditor : Editor
1413
{
1514
// --- Static Data ---
1615
private static StateInfo[] states; //Editor States
@@ -30,11 +29,11 @@ public class EntityStateManagerEditor : Editor
3029
private Dictionary<string, StateInfo> stateCollection;
3130

3231
// --- Target ---
33-
private static EntityStateManager Target;
32+
private static StateManager Target;
3433

3534
private void OnEnable()
3635
{
37-
Target = target as EntityStateManager;
36+
Target = target as StateManager;
3837
Initialize ();
3938
}
4039

@@ -142,14 +141,14 @@ private void UpdateSelection()
142141
}
143142

144143
// State GUI
145-
private void DrawState(StateInfo _state)
144+
private void DrawState(StateInfo state)
146145
{
147-
if (_state == null)
146+
if (state == null)
148147
{
149148
return;
150149
}
151150

152-
stateAsset = EditorUtil.GetAssetFromName (_state.name);
151+
stateAsset = EditorUtil.GetAssetFromName (state.name);
153152

154153
if (stateAsset == null)
155154
{
@@ -175,9 +174,9 @@ private void DrawState(StateInfo _state)
175174
//Toggle for convenience
176175
EditorGUI.indentLevel++;
177176
{
178-
for (int i = 0; i < _state.fields.Count; i++)
177+
for (int i = 0; i < state.fields.Count; i++)
179178
{
180-
StateFieldInfo field = _state.fields[i];
179+
StateFieldInfo field = state.fields[i];
181180
string name = field.info.DeclaringType.Name;
182181

183182
// Draw based on what the declaring type is
@@ -207,7 +206,7 @@ private void DrawState(StateInfo _state)
207206
names.Add (name);
208207
}
209208

210-
DrawField (_state.fields[i]);
209+
DrawField (state.fields[i]);
211210
}
212211

213212
EditorGUILayout.Space ();
File renamed without changes.

FSM/Scripts/State Machine/EntityStateMachineComponent.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

FSM/Scripts/State Machine/SerializableState.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ public State CreateStateFromType()
2828
/// <summary>
2929
/// Set the name of the state to be assigned. Should only really be needed from the editor
3030
/// </summary>
31-
/// <param name="_name">The full name of the state</param>
32-
public void SetStateName(string _name)
31+
/// <param name="name">The full name of the state</param>
32+
public void SetStateName(string name)
3333
{
34-
m_stateName = _name;
34+
m_stateName = name;
3535
}
3636
}
3737
}

FSM/Scripts/State Machine/State.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using FSM;
32
using UnityEngine;
43

54
namespace FSM
@@ -10,7 +9,7 @@ namespace FSM
109
public class State
1110
{
1211
// Connection to main GameObject
13-
private EntityStateMachine parent;
12+
private StateMachine parent;
1413

1514
//Timers
1615
public float age;
@@ -20,7 +19,7 @@ public State()
2019
{
2120
if (Application.isPlaying)
2221
{
23-
EntityStateManager.SetStateValues (this);
22+
StateManager.SetStateValues (this);
2423
}
2524
}
2625

@@ -76,7 +75,7 @@ public virtual void DebugTick(float delta)
7675
/// Set the parent of this state
7776
/// </summary>
7877
/// <param name="parent">The state parent</param>
79-
public void SetParent(EntityStateMachine parent)
78+
public void SetParent(StateMachine parent)
8079
{
8180
this.parent = parent;
8281
}

FSM/Scripts/State Machine/EntityStateMachine.cs renamed to FSM/Scripts/State Machine/StateMachine.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace FSM
44
{
5-
public class EntityStateMachine : MonoBehaviour
5+
public class StateMachine : MonoBehaviour
66
{
77
public bool isRunning = true;
88

@@ -83,15 +83,15 @@ private void OnDrawGizmos()
8383
/// <summary>
8484
/// Set a new state to the instance
8585
/// </summary>
86-
/// <param name="_state"></param>
87-
public void SetState(State _state)
86+
/// <param name="state"></param>
87+
public void SetState(State state)
8888
{
8989
if (!isRunning)
9090
{
9191
return;
9292
}
9393

94-
if (_state == null)
94+
if (state == null)
9595
{
9696
Debug.LogError ("Cannot set null state");
9797
return;
@@ -105,7 +105,7 @@ public void SetState(State _state)
105105
m_previousState = m_currentState;
106106

107107
// Update State
108-
m_currentState = _state;
108+
m_currentState = state;
109109
m_currentState.SetParent(this);
110110
m_currentState.OnEnter ();
111111
}

0 commit comments

Comments
 (0)