working on humbie still
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
using RebootKit.Engine.Simulation;
|
||||
|
||||
namespace RebootReality.jelycho.Enemies {
|
||||
public interface IKillable {
|
||||
bool IsAlive();
|
||||
|
||||
// @NOTE: Returns damage dealt
|
||||
ulong OnHit(Actor attacker, ulong damage);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5449b1adab2f474b9d7a25cb59c66e6d
|
||||
timeCreated: 1754955332
|
||||
@@ -2,6 +2,7 @@
|
||||
using RebootKit.Engine.Extensions;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using RebootReality.jelycho.Enemies.Zombie;
|
||||
using Unity.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
3
Assets/jelycho/Code/Enemies/Zombie.meta
Normal file
3
Assets/jelycho/Code/Enemies/Zombie.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 72a9c46420c34ee594e3a68ac031a649
|
||||
timeCreated: 1761227055
|
||||
@@ -6,16 +6,19 @@ using RebootKit.Engine.Extensions;
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Network;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using RebootReality.jelycho.Actors;
|
||||
using RebootReality.jelycho.Beacons;
|
||||
using RebootReality.jelycho.Main;
|
||||
using RebootReality.jelycho.Player;
|
||||
using TriInspector;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
using Random = UnityEngine.Random;
|
||||
using UnityEvent = UnityEngine.Events.UnityEvent;
|
||||
|
||||
namespace RebootReality.jelycho.Enemies {
|
||||
namespace RebootReality.jelycho.Enemies.Zombie {
|
||||
public class ZombieActorData : IActorData {
|
||||
public void Serialize(NetworkBufferWriter writer) {
|
||||
}
|
||||
@@ -101,7 +104,7 @@ namespace RebootReality.jelycho.Enemies {
|
||||
|
||||
[DeclareBoxGroup("Body parts")]
|
||||
[DeclareBoxGroup("Animations")]
|
||||
public class ZombieActor : Actor, IKillable {
|
||||
public class ZombieActor : Actor, IHasHealth {
|
||||
static readonly Logger s_Logger = new Logger(nameof(ZombieActor));
|
||||
|
||||
[SerializeField] AnimancerComponent m_Animancer;
|
||||
@@ -335,35 +338,14 @@ namespace RebootReality.jelycho.Enemies {
|
||||
}
|
||||
|
||||
//
|
||||
// @MARK: IKillable
|
||||
// @MARK: IHasHealth
|
||||
//
|
||||
public ulong Health { get; private set; } = 100;
|
||||
public ulong MaxHealth { get; private set; } = 100;
|
||||
|
||||
public bool IsAlive() {
|
||||
return Health > 0;
|
||||
}
|
||||
|
||||
public ulong OnHit(Actor attacker, ulong damage) {
|
||||
if (!RR.IsServer()) {
|
||||
s_Logger.Error("OnHit can only be called on the server.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!IsAlive()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
s_Logger.Info($"Hit: {damage}");
|
||||
|
||||
damage = math.min(damage, Health);
|
||||
Health -= damage;
|
||||
if (Health <= 0) {
|
||||
Die();
|
||||
return damage;
|
||||
}
|
||||
|
||||
return damage;
|
||||
}
|
||||
|
||||
//
|
||||
// @MARK: damage?
|
||||
@@ -374,7 +356,12 @@ namespace RebootReality.jelycho.Enemies {
|
||||
}
|
||||
}
|
||||
|
||||
public void ReceiveDamage(ulong damage, ZombieBodyPartType bodyPartType) {
|
||||
public void ReceiveBodyPartDamage(ulong damage, ZombieBodyPartType bodyPartType) {
|
||||
if (!RR.IsServer()) {
|
||||
s_Logger.Error("ReceiveBodyPartDamage can only be called on the server.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsAlive()) {
|
||||
return;
|
||||
}
|
||||
@@ -384,10 +371,26 @@ namespace RebootReality.jelycho.Enemies {
|
||||
return;
|
||||
}
|
||||
|
||||
bodyPart.HideParts();
|
||||
bodyPart.bloodStreamParticles.Play();
|
||||
bool isBodyPartDestroyed = Random.Range(0.0f, 1.0f) > 0.5f;
|
||||
|
||||
Die();
|
||||
if (isBodyPartDestroyed) {
|
||||
bodyPart.HideParts();
|
||||
bodyPart.bloodStreamParticles.Play();
|
||||
|
||||
if (bodyPartType == ZombieBodyPartType.Head) {
|
||||
damage = Health;
|
||||
} else if (bodyPartType == ZombieBodyPartType.LeftLeg ||
|
||||
bodyPartType == ZombieBodyPartType.RightLeg) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
damage = math.min(damage, Health);
|
||||
|
||||
Health -= damage;
|
||||
if (Health <= 0) {
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasBodyPart(ZombieBodyPartType bodyPart) {
|
||||
@@ -1,10 +1,12 @@
|
||||
using RebootKit.Engine.Main;
|
||||
using RebootKit.Engine.Simulation;
|
||||
using RebootReality.jelycho.Damage;
|
||||
using RebootReality.jelycho.Main;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace RebootReality.jelycho.Enemies {
|
||||
namespace RebootReality.jelycho.Enemies.Zombie {
|
||||
public class ZombieHurtbox : MonoBehaviour, IHurtbox {
|
||||
public ZombieActor owner;
|
||||
[SerializeField] ZombieBodyPartType m_BodyPart = ZombieBodyPartType.Body;
|
||||
@@ -18,7 +20,7 @@ namespace RebootReality.jelycho.Enemies {
|
||||
return;
|
||||
}
|
||||
|
||||
owner.ReceiveDamage(damage, m_BodyPart);
|
||||
owner.ReceiveBodyPartDamage(damage, m_BodyPart);
|
||||
|
||||
if (RR.World.Context is WorldContext worldContext) {
|
||||
worldContext.FeedbacksManager.SpawnBloodSplash(worldHitPos);
|
||||
Reference in New Issue
Block a user