Skip to content

Commit b2ffb5a

Browse files
committed
[CodeStyle] refactoring v1
1 parent 59ccb09 commit b2ffb5a

File tree

9 files changed

+14
-43
lines changed

9 files changed

+14
-43
lines changed

Assets/Scripts/Action.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public virtual void Continue(GameObject obj)
3333
public abstract void Update();
3434
public abstract void End();
3535

36-
public void SetState(ETriggerStates state)
36+
public void SetState(ETriggerStates triggerState)
3737
{
38-
this.state = state;
39-
enabled = state == ETriggerStates.RUNNING;
38+
state = triggerState;
39+
enabled = triggerState == ETriggerStates.RUNNING;
4040
}
4141

42-
public bool IsState(ETriggerStates state)
42+
public bool IsState(ETriggerStates triggerState)
4343
{
44-
return this.state == state;
44+
return state == triggerState;
4545
}
4646
}
4747
}

Assets/Scripts/Events/EventOnUse.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public override void Update()
2323
{
2424
if (IsState(ETriggerRunMode.ASYNCHRONOUSLY))
2525
{
26-
if (!UpdateAsyn()) Continue();
26+
if (!UpdateAsync()) Continue();
2727
}
2828
else
2929
{
30-
if (!UpdateSyn()) Continue();
30+
if (!UpdateSync()) Continue();
3131
}
3232
}
3333

Assets/Scripts/Events/EventOnUseTransmitter.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,14 @@ private void Start()
2121
SetState(ETriggerStates.NOT_ACTIVATED);
2222
}
2323

24-
private void Update()
25-
{
26-
}
27-
2824
public void Log(string msg)
2925
{
3026
if (debug) Debug.Log(msg);
3127
}
3228

33-
public bool IsState(ETriggerStates state)
29+
public bool IsState(ETriggerStates State)
3430
{
35-
return this.state == state;
31+
return this.state == State;
3632
}
3733

3834
public void SetState(ETriggerStates state)
-164 Bytes
Binary file not shown.

Assets/Scripts/Interfaces/ITriggerStates.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
internal interface ITriggerStates
44
{
55
void SetState(ETriggerStates state);
6-
bool IsState(ETriggerStates state);
6+
bool IsState(ETriggerStates State);
77
}
88
}

Assets/Scripts/SimpleController.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ public class SimpleController : MonoBehaviour
77
public float speedMove = 150.0f;
88
private GameObject usingItem;
99

10-
private void Start()
11-
{
12-
}
13-
14-
1510
private void Update()
1611
{
1712
transform.Rotate(0f, Input.GetAxis("Horizontal") * Time.deltaTime * speedMove, 0f);

Assets/Scripts/Trigger.cs

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,17 @@ public abstract class Event : MonoBehaviour, IDebug, ITriggerExecute
66
{
77
public QueueActions queue;
88

9-
109
[SerializeField] protected ETriggerRunMode runMode = ETriggerRunMode.SYNCHRONOUSLY;
1110
[SerializeField] protected ETriggerWorkMode workMode = ETriggerWorkMode.FIRE;
1211

13-
1412
public bool once = true;
1513

16-
1714
public bool debug;
1815

19-
2016
[SerializeField] protected int countTriggered;
2117

22-
2318
private ETriggerStates state = ETriggerStates.NOT_ACTIVATED;
2419

25-
2620
protected GameObject whoTriggered;
2721

2822
private void Start()
@@ -37,7 +31,6 @@ public void Log(string msg)
3731

3832
public abstract void Update();
3933

40-
4134
public void Run(GameObject obj)
4235
{
4336
if (IsState(ETriggerStates.NOT_ACTIVATED) || IsState(ETriggerStates.FINISHED))
@@ -83,8 +76,7 @@ public void Pause()
8376

8477
public abstract void End();
8578

86-
87-
protected bool UpdateSyn()
79+
protected bool UpdateSync()
8880
{
8981
if (queue.Current() == null)
9082
{
@@ -107,13 +99,11 @@ protected bool UpdateSyn()
10799
return CheckOver();
108100
}
109101

110-
111-
protected bool UpdateAsyn()
102+
protected bool UpdateAsync()
112103
{
113104
return CheckOver();
114105
}
115106

116-
117107
private bool CheckOver()
118108
{
119109
if (IsAllActionsExecuted())
@@ -151,7 +141,6 @@ private void NewStart(GameObject obj)
151141
countTriggered++;
152142
}
153143

154-
155144
protected void PopAction(GameObject obj)
156145
{
157146
queue.Next();
@@ -164,21 +153,18 @@ protected void PopAction(GameObject obj)
164153
}
165154
}
166155

167-
168156
protected void RunSynchronously(GameObject obj)
169157
{
170158
PopAction(obj);
171159
}
172160

173-
174161
protected void RunAsynchronously(GameObject obj)
175162
{
176163
whoTriggered = obj;
177164
Log("Starting asyn actions");
178165
foreach (var action in queue.GetActions()) action.Run(obj);
179166
}
180167

181-
182168
protected bool IsAllActionsExecuted()
183169
{
184170
return queue.IsAllActionsExecuted();
@@ -215,7 +201,6 @@ public bool IsState(ETriggerWorkMode workMode)
215201
return this.workMode == workMode;
216202
}
217203

218-
219204
protected abstract void Init();
220205
}
221206
}

Assets/Scripts/Utils/AllowedLayers.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,9 @@ public class AllowedLayers
88
{
99
public List<int> list;
1010

11-
1211
public bool IsAllowed(int layer)
1312
{
14-
if (IsEmpty())
15-
return true;
16-
17-
return list.Contains(layer);
13+
return IsEmpty() || list.Contains(layer);
1814
}
1915

2016

@@ -23,10 +19,9 @@ public bool IsAllowed(int[] layers)
2319
return false;
2420
}
2521

26-
2722
private bool IsEmpty()
2823
{
29-
return list != null && list.Count == 0;
24+
return list is {Count: 0};
3025
}
3126
}
3227
}
-180 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)