Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Commit

Permalink
Merge pull request #3 from potatoes1286/master
Browse files Browse the repository at this point in the history
  • Loading branch information
Frityet authored Jul 26, 2021
2 parents 21be365 + cd2f6dc commit a6a0f3d
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
1 change: 0 additions & 1 deletion .idea/.idea.HADES.H3VR/.idea/.name

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/.idea.HADES.H3VR/.idea/indexLayout.xml

This file was deleted.

6 changes: 4 additions & 2 deletions HADES.Core/src/EnhancedHealth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace HADES.Core
{
public class EnhancedHealth : MonoBehaviour
{
private HADES _hadesSystem;
private float _initialHealth;
public float HealthPercentage { get; private set; }

Expand All @@ -16,10 +17,11 @@ public class EnhancedHealth : MonoBehaviour
private float RegenDelay => HADESConfig.EnhancedHealth.RegenDelay;
private float RegenSpeed => HADESConfig.EnhancedHealth.RegenSpeed;

private GameObject HealthBars => HADES.Player.HealthBar;
private GameObject HealthBars => _hadesSystem.Player.HealthBar;

private void Start()
{
_hadesSystem = GetComponent<HADES>();
Print("Injected EnhancedHealth into player");
_initialHealth = GM.GetPlayerHealth();
}
Expand All @@ -45,7 +47,7 @@ private IEnumerator Regenerate()
float curHealth = CurrentHealth;
Logging.Debug.Print($"Current health {curHealth}\nInit health {initHealth}");
if (curHealth < initHealth) goto regen;
HADES.Player.HealPercent(i);
_hadesSystem.Player.HealPercent(i);
}

Logging.Debug.Print("Done Regeneration");
Expand Down
6 changes: 4 additions & 2 deletions HADES.Core/src/EnhancedMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ namespace HADES.Core
{
public class EnhancedMovement : MonoBehaviour
{
private HADES _hadesSystem;
public float Stamina { get; private set; }

public float Weight
{
get
{
var qbSlots = HADES.Player.QuickbeltSlots;
var qbSlots = _hadesSystem.Player.QuickbeltSlots;

var weight = 0.0f;

Expand Down Expand Up @@ -52,14 +53,15 @@ public float Weight

private void Start()
{
_hadesSystem = GetComponent<HADES>();
Stamina = MaxStamina;
}

private void Update()
{
if (!HADESConfig.EnhancedMovement.Enabled) return;

float speed = HADES.Player.GetBodyMovementSpeed();
float speed = _hadesSystem.Player.GetBodyMovementSpeed();
if (speed < 10f) return;
GM.CurrentMovementManager.SlidingSpeed -= Stamina / 100;
}
Expand Down
11 changes: 8 additions & 3 deletions HADES.Core/src/FallDamage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace HADES.Core
{
public class FallDamage : MonoBehaviour
{
private HADES _hadesSystem;
private Vector3 _currentPos;
private float _currentVelocity;
private Vector3 _previousPos;
Expand All @@ -15,7 +16,11 @@ public class FallDamage : MonoBehaviour

private void Start()
{
if (!HADESConfig.FallDamage.Enabled) Print("Injected FallDamage into player");
_hadesSystem = GetComponent<HADES>();
if (HADESConfig.FallDamage.Enabled)
{
Print("Injected FallDamage into player");
}
}

private void Update()
Expand All @@ -25,7 +30,7 @@ private void Update()
var fallDmg = CalculateFallDamage();
Print($"DMG: {fallDmg.Item1}, VEL: {fallDmg.Item2}");
if (fallDmg.Item1 >= 1)
HADES.Player.HarmPercent(fallDmg.Item1 / 100); //Harm the player the percentage that they fell
_hadesSystem.Player.HarmPercent(fallDmg.Item1 / 100); //Harm the player the percentage that they fell
}

public void FixedUpdate()
Expand Down Expand Up @@ -55,7 +60,7 @@ private void CalculateVelocity()
//set prev pos
_previousPos = _currentPos;
//probably not a good idea to hard-code the idea that there's only ever one player.
_currentPos = HADES.Player.transform.position;
_currentPos = _hadesSystem.Player.transform.position;

//get velocity
_previousVelocity = _currentVelocity;
Expand Down
4 changes: 2 additions & 2 deletions HADES.Core/src/HADES.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace HADES.Core
{
public class HADES : MonoBehaviour
{
public static FVRPlayerBody Player => GM.CurrentPlayerBody;
public FVRPlayerBody Player => GM.CurrentPlayerBody;

public FallDamage FallDamage { get; private set; }
public EnhancedHealth EnhancedHealth { get; private set; }
public EnhancedMovement EnhancedMovement { get; private set; }

private void Awake()
{
Print("Injected EHADS into player");
Print("Injected HADES into player");
FallDamage = gameObject.AddComponent<FallDamage>();
EnhancedHealth = gameObject.AddComponent<EnhancedHealth>();
EnhancedMovement = gameObject.AddComponent<EnhancedMovement>();
Expand Down

0 comments on commit a6a0f3d

Please sign in to comment.