Skip to content

Commit 4ba8dc3

Browse files
refactored code
1 parent c223966 commit 4ba8dc3

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

Control/AIController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private void Update() {
5252
return;
5353
}
5454
if (IsAggrevated()) {
55-
timeSinceLastSawPlayer = 0f;
55+
timeSinceLastSawPlayer = 0;
5656
AttackBehaviour();
5757
} else if (timeSinceLastSawPlayer < suspicionTime) {
5858
SuspicionBehaviour();
@@ -114,7 +114,7 @@ private void PatrolBehaviour() {
114114
if (patrolPath != null) {
115115
if (IsAtWayPoint()) {
116116
if (dwellTime < timeSinceLastWaypoint) {
117-
timeSinceLastWaypoint = 0f;
117+
timeSinceLastWaypoint = 0;
118118
CycleWaypoint();
119119
}
120120
}

Movement/Mover.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void Update() {
3434
if (callbackOnReachingDestination != null && !navMeshAgent.pathPending) {
3535
navMeshAgent.stoppingDistance = interactStoppingDistance;
3636
if (navMeshAgent.remainingDistance <= navMeshAgent.stoppingDistance) {
37-
if (!navMeshAgent.hasPath || navMeshAgent.velocity.sqrMagnitude == 0f) {
37+
if (!navMeshAgent.hasPath || Mathf.Approximately(navMeshAgent.velocity.sqrMagnitude, 0)) {
3838
Cancel();
3939
callbackOnReachingDestination();
4040
callbackOnReachingDestination = null;

Stats/BaseStats.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,4 @@ public float GetStat(Stat stat) {
100100
return (progression.GetStat(stat, characterClass, currentLevel.value) + GetAdditiveModifiers(stat)) * (1 + GetPercentageModifier(stat) / 100);
101101
}
102102
}
103-
104103
}

Stats/Progression.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public float GetStat(Stat stat, CharacterClass characterClass, int level) {
9393
BuildLookup();
9494
float[] levels = lookupTable[characterClass][stat];
9595
if (levels.Length < level) {
96-
return 0f;
96+
return 0;
9797
}
9898
return levels[level - 1];
9999
}

UI/CameraFacing.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22

33
namespace RPG.UI {
44
public class CameraFacing : MonoBehaviour {
5+
private Camera mainCamera;
6+
7+
private void Start() {
8+
mainCamera = Camera.main;
9+
}
510

611
private void LateUpdate() {
7-
transform.forward = Camera.main.transform.forward;
12+
transform.forward = mainCamera.transform.forward;
813
}
914
}
1015

0 commit comments

Comments
 (0)