working on humbie still

This commit is contained in:
2025-10-24 13:54:27 +02:00
parent 98cf38ac00
commit 18effac005
33 changed files with 359 additions and 129 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7ba665ddebe34f608f00db5d8107b685
timeCreated: 1761225260

View File

@@ -5,7 +5,7 @@ using UnityEngine;
using UnityEngine.AddressableAssets;
using Logger = RebootKit.Engine.Foundation.Logger;
namespace RebootReality.jelycho {
namespace RebootReality.jelycho.Actors {
public class ActorSpawner : Actor {
static readonly Logger s_Logger = new Logger(nameof(ActorSpawner));

View File

@@ -6,7 +6,7 @@ using UnityEngine;
using UnityEngine.Events;
using Logger = RebootKit.Engine.Foundation.Logger;
namespace RebootReality.jelycho {
namespace RebootReality.jelycho.Actors {
public class ButtonActor : Actor, IInteractable {
static readonly Logger s_Logger = new Logger(nameof(ButtonActor));

View File

@@ -0,0 +1,8 @@
namespace RebootReality.jelycho.Actors {
public interface IHasHealth {
ulong Health { get; }
ulong MaxHealth { get; }
bool IsAlive();
}
}

View File

@@ -1,4 +1,4 @@
namespace RebootReality.jelycho {
namespace RebootReality.jelycho.Actors {
public interface IInteractable {
void SetHighlight(bool highlight);
void Interact();

View File

@@ -4,6 +4,7 @@ using RebootKit.Engine.Main;
using RebootKit.Engine.Network;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.InfectedArea;
using RebootReality.jelycho.Main;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.AddressableAssets;

View File

@@ -1,5 +1,6 @@
using RebootKit.Engine.Network;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Actors;
using RebootReality.jelycho.Enemies;
using UnityEngine;
@@ -24,7 +25,7 @@ namespace RebootReality.jelycho.Beacons {
}
}
public class MotherActor : Actor, IKillable {
public class MotherActor : Actor, IHasHealth {
MotherActorData m_ActorData = new MotherActorData();
[field: SerializeField] public Transform GutConnector { get; private set; }
@@ -35,16 +36,24 @@ namespace RebootReality.jelycho.Beacons {
protected override IActorData CreateActorData() {
return m_ActorData;
}
//
// @MARK: IKillable
//
// @MARK: IHasHealth
//
public ulong Health {
get {
return m_ActorData.Health;
}
private set {
m_ActorData.Health = value;
}
}
[field: SerializeField] public ulong MaxHealth { get; private set; }
public bool IsAlive() {
return m_ActorData.Health > 0;
}
public ulong OnHit(Actor attacker, ulong damage) {
return damage;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: aaf9c8fc3fd047bfa82bdf2c1422c6be
timeCreated: 1761224582

View File

@@ -7,7 +7,7 @@ using Unity.Mathematics;
using UnityEngine;
using Logger = RebootKit.Engine.Foundation.Logger;
namespace RebootReality.jelycho {
namespace RebootReality.jelycho.Damage {
public class HitboxManagerActor : Actor {
static readonly Logger s_Logger = new Logger(nameof(HitboxManagerActor));
static readonly Collider[] s_CollidersBuffer = new Collider[512];
@@ -54,25 +54,6 @@ namespace RebootReality.jelycho {
hurtbox.ReceiveDamage(attacker, damage, p);
}
// if (s_CollidersBuffer[i].TryGetComponent(out IKillable killable)) {
// Actor killableActor = killable as Actor;
// if (killableActor == attacker) {
// continue;
// }
//
// if (killable is IHasHitFeedback hitFeedback) {
// float3 p = s_CollidersBuffer[i].ClosestPoint(origin);
// if (ShouldShowHitboxes()) {
// DbgDraw.Sphere(p, Quaternion.identity, Vector3.one * 0.1f, Color.magenta, m_HitboxDebugDuration);
// }
//
// hitFeedback.HitFeedback(p);
// }
//
// // @TODO: send command to server to hit an killable
// killable.OnHit(attacker, damage);
// }
}
}

View File

@@ -1,7 +1,7 @@
using RebootKit.Engine.Simulation;
using Unity.Mathematics;
namespace RebootReality.jelycho {
namespace RebootReality.jelycho.Damage {
public interface IHurtbox {
void ReceiveDamage(Actor attacker, ulong damage, float3 worldHitPos);
}

View File

@@ -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);
}
}

View File

@@ -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;

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 72a9c46420c34ee594e3a68ac031a649
timeCreated: 1761227055

View File

@@ -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) {

View File

@@ -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);

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using RebootKit.Engine.Main;
using RebootReality.jelycho.Main;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Experimental.Rendering;

View File

@@ -1,6 +1,7 @@
using HighlightPlus;
using RebootKit.Engine.Network;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Actors;
using UnityEngine;
using Logger = RebootKit.Engine.Foundation.Logger;

View File

@@ -1,5 +1,6 @@
using RebootKit.Engine.Main;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Main;
using RebootReality.jelycho.Player;
using UnityEngine;
@@ -10,13 +11,13 @@ namespace RebootReality.jelycho.Items {
return;
}
PlayerActor playerActor = attacker as PlayerActor;
var playerActor = attacker as PlayerActor;
if (playerActor == null) {
return;
}
Vector3 attackPosition = playerActor.GetAttackPosition();
float attackRadius = 1.0f;
float attackRadius = 0.5f;
worldContext.HitboxManager.HitSphere(attackPosition, attackRadius, attacker, itemActor.Config.baseDamage);
}

View File

@@ -1,5 +1,6 @@
using RebootKit.Engine.Main;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Main;
using RebootReality.jelycho.Player;
using UnityEngine;
using Logger = RebootKit.Engine.Foundation.Logger;

View File

@@ -1,12 +1,13 @@
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Beacons;
using RebootReality.jelycho.Damage;
using RebootReality.jelycho.Enemies;
using RebootReality.jelycho.Feedbacks;
using RebootReality.jelycho.InfectedArea;
using RebootReality.jelycho.Ropes;
using UnityEngine;
namespace RebootReality.jelycho {
namespace RebootReality.jelycho.Main {
public class WorldContext : MonoBehaviour, IWorldContext {
[field: SerializeField] public Transform PlayerSpawnPoint { get; private set; }
[field: SerializeField] public RopesManager RopesManager { get; private set; }

View File

@@ -4,15 +4,17 @@ using RebootKit.Engine.Extensions;
using RebootKit.Engine.Main;
using RebootKit.Engine.Network;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Actors;
using RebootReality.jelycho.Enemies;
using RebootReality.jelycho.Items;
using RebootReality.jelycho.Main;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
using Logger = RebootKit.Engine.Foundation.Logger;
namespace RebootReality.jelycho.Player {
public class PlayerActor : Actor, IKillable {
public class PlayerActor : Actor, IHasHealth {
static readonly Logger s_Logger = new Logger(nameof(PlayerActor));
[SerializeField] PlayerAnimator m_PlayerAnimator;
@@ -526,23 +528,6 @@ namespace RebootReality.jelycho.Player {
break;
}
case PlayerActorCommands.DealDamage: {
PlayerActorDealDamageCommand dealDamageCommand = new PlayerActorDealDamageCommand();
DataSerializationUtils.Deserialize(actorCommand.Data, ref dealDamageCommand);
Actor targetActor = RR.FindSpawnedActor(dealDamageCommand.TargetActorID);
if (targetActor == null) {
s_Logger.Error($"Target actor with ID {dealDamageCommand.TargetActorID} not found.");
break;
}
if (targetActor is IKillable killable) {
killable.OnHit(this, 100);
}
break;
}
}
}
@@ -673,18 +658,6 @@ namespace RebootReality.jelycho.Player {
}
}
public void DealDamage(IKillable target) {
if (target is Actor actor) {
var dealDamageCommand = new PlayerActorDealDamageCommand {
TargetActorID = actor.ActorID
};
SendActorCommand((byte) PlayerActorCommands.DealDamage,
ref dealDamageCommand);
} else {
s_Logger.Error($"Player can only deal damage to other actors!");
}
}
//
// @MARK: Remote
//
@@ -830,16 +803,15 @@ namespace RebootReality.jelycho.Player {
}
//
// @MARK: IKillable
// @MARK: IHasHealth
//
public ulong Health { get; private set; } = 100;
public ulong MaxHealth { get; private set; } = 100;
public bool IsAlive() {
return true;
}
public ulong OnHit(Actor attacker, ulong damage) {
return 0;
}
//
// @MARK: Common
//
@@ -1055,8 +1027,7 @@ namespace RebootReality.jelycho.Player {
DropItem = 0x03,
EquipItem = 0x04,
SelectItemSlot = 0x05,
RequestHandsAnimation = 0x06,
DealDamage = 0x07
RequestHandsAnimation = 0x06
}
struct PlayerActorPickupItemCommand : IActorData {
@@ -1139,22 +1110,6 @@ namespace RebootReality.jelycho.Player {
}
}
struct PlayerActorDealDamageCommand : IActorData {
public ushort TargetActorID;
public int GetMaxBytes() {
return sizeof(ushort);
}
public void Serialize(NetworkBufferWriter writer) {
writer.Write(TargetActorID);
}
public void Deserialize(NetworkBufferReader reader) {
reader.Read(out TargetActorID);
}
}
// @MARK: Player Actor Events
enum PlayerActorEvents : byte {
None = 0x00,

View File

@@ -5,6 +5,7 @@ using RebootKit.Engine.Input;
using RebootKit.Engine.Main;
using RebootKit.Engine.Network;
using RebootKit.Engine.Simulation;
using RebootReality.jelycho.Actors;
using RebootReality.jelycho.Main;
using RebootReality.jelycho.Player.HUD;
using Unity.Mathematics;

View File

@@ -1,4 +1,5 @@
using RebootKit.Engine.Main;
using RebootReality.jelycho.Main;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Assertions;