Commit 9573686b by alsunj

Remove unnecessary calls

parent f89e3fc7
Showing with 2 additions and 39 deletions
......@@ -14,27 +14,6 @@ public class Barrel : NetworkBehaviour, IDestrucable
{
_health.Value = _destructableSettings.health;
}
_health.OnValueChanged += OnHealthChanged;
}
public override void OnDestroy()
{
_health.OnValueChanged -= OnHealthChanged;
}
private void OnHealthChanged(float oldHealth, float newHealth)
{
if (newHealth <= 0)
{
transform.DOScale(Vector3.zero, 0.5f).SetDelay(_destructableSettings.hitDelay)
.OnComplete(() => gameObject.SetActive(false));
}
else
{
transform.DOShakePosition(0.5f, _destructableSettings.shakeOffset, 10, 90, false, true)
.SetDelay(_destructableSettings.hitDelay);
}
}
[ClientRpc]
......@@ -60,28 +39,13 @@ public class Barrel : NetworkBehaviour, IDestrucable
private void RequestTakeDamageServerRpc(float damage)
{
_health.Value -= damage;
Debug.Log(_health.Value);
Debug.Log("health value at checking: " + _health.Value);
if (_health.Value <= 0)
{
CmdShowBarrelDestroyForEveryOneServerRpc();
RpcShowBarrelDestroyForEveryOneClientRpc();
}
else
{
CmdShowBarrelDamageForEveryoneServerRpc();
RpcShowBarrelDamageForEveryoneClientRpc();
}
}
[ServerRpc(RequireOwnership = false)]
private void CmdShowBarrelDestroyForEveryOneServerRpc()
{
RpcShowBarrelDestroyForEveryOneClientRpc();
}
[ServerRpc(RequireOwnership = false)]
private void CmdShowBarrelDamageForEveryoneServerRpc()
{
RpcShowBarrelDamageForEveryoneClientRpc();
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment