-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
7 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,8 @@ | ||
using System; | ||
using UnityEngine; | ||
using VRC.SDKBase; | ||
using VRC.SDKBase; | ||
|
||
namespace GotoUdon.VRC | ||
{ | ||
public class VRCDestructible : MonoBehaviour, IVRC_Destructible | ||
public class VRCDestructible : VRC_DestructibleStandard | ||
{ | ||
private VRC_CombatSystem _vrcCombatSystem; | ||
public float maxHealth; | ||
public float currentHealth; | ||
public object[] state; | ||
private VRCPlayer _vrcPlayer; | ||
private bool _setup = false; | ||
|
||
public void Setup() | ||
{ | ||
state = new object[0]; | ||
_vrcCombatSystem = VRC_CombatSystem.GetInstance(); | ||
maxHealth = _vrcCombatSystem.maxPlayerHealth; | ||
currentHealth = _vrcCombatSystem.maxPlayerHealth; | ||
SimulatedVRCPlayer simulatedVrcPlayer = GetComponent<SimulatedVRCPlayer>(); | ||
if (simulatedVrcPlayer != null) | ||
{ | ||
_vrcPlayer = simulatedVrcPlayer.VRCPlayer; | ||
_vrcCombatSystem.onSetupPlayer(_vrcPlayer); | ||
} | ||
} | ||
|
||
public object[] GetState() | ||
{ | ||
return state; | ||
} | ||
|
||
public void SetState(object[] state) | ||
{ | ||
this.state = state; | ||
} | ||
|
||
public float GetMaxHealth() | ||
{ | ||
return maxHealth; | ||
} | ||
|
||
public float GetCurrentHealth() | ||
{ | ||
return currentHealth; | ||
} | ||
|
||
public void ApplyDamage(float damage) | ||
{ | ||
if (!_setup) return; | ||
currentHealth -= damage; | ||
if (_vrcPlayer != null) | ||
{ | ||
_vrcCombatSystem.onPlayerDamaged(_vrcPlayer); | ||
if (currentHealth <= 0) | ||
{ | ||
_vrcCombatSystem.onPlayerKilled(_vrcPlayer); | ||
} | ||
} | ||
} | ||
|
||
public void ApplyHealing(float healing) | ||
{ | ||
if (!_setup) return; | ||
currentHealth = Math.Min(currentHealth + healing, maxHealth); | ||
_vrcCombatSystem.onPlayerHealed(_vrcPlayer); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters