Commit ea62025f by alsunj

Merge branch 'fix/refactor-barrel-rpcs' into 'main'

Remove unnecessary calls

See merge request alsunj/loputoo!12
parents f8ffd702 9573686b
Showing with 3 additions and 38 deletions
...@@ -14,27 +14,6 @@ public class Barrel : NetworkBehaviour, IDestrucable ...@@ -14,27 +14,6 @@ public class Barrel : NetworkBehaviour, IDestrucable
{ {
_health.Value = _destructableSettings.health; _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] [ClientRpc]
...@@ -60,28 +39,13 @@ public class Barrel : NetworkBehaviour, IDestrucable ...@@ -60,28 +39,13 @@ public class Barrel : NetworkBehaviour, IDestrucable
private void RequestTakeDamageServerRpc(float damage) private void RequestTakeDamageServerRpc(float damage)
{ {
_health.Value -= damage; _health.Value -= damage;
Debug.Log(_health.Value);
Debug.Log("health value at checking: " + _health.Value);
if (_health.Value <= 0) if (_health.Value <= 0)
{ {
CmdShowBarrelDestroyForEveryOneServerRpc();
}
else
{
CmdShowBarrelDamageForEveryoneServerRpc();
}
}
[ServerRpc(RequireOwnership = false)]
private void CmdShowBarrelDestroyForEveryOneServerRpc()
{
RpcShowBarrelDestroyForEveryOneClientRpc(); RpcShowBarrelDestroyForEveryOneClientRpc();
} }
else
[ServerRpc(RequireOwnership = false)]
private void CmdShowBarrelDamageForEveryoneServerRpc()
{ {
RpcShowBarrelDamageForEveryoneClientRpc(); 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