added 'ts' command to change timescale in debug builds; triplanar mapping for infected area textures
This commit is contained in:
@@ -12,7 +12,7 @@ using UnityEngine;
|
||||
using Logger = RebootKit.Engine.Foundation.Logger;
|
||||
|
||||
namespace RebootReality.jelycho.Player {
|
||||
public class PlayerActor : Actor, IKillable {
|
||||
public class PlayerActor : Actor, IKillable {
|
||||
static readonly Logger s_Logger = new Logger(nameof(PlayerActor));
|
||||
|
||||
[SerializeField] PlayerAnimator m_PlayerAnimator;
|
||||
@@ -81,7 +81,7 @@ namespace RebootReality.jelycho.Player {
|
||||
ItemActor m_EquippedItem;
|
||||
|
||||
[SerializeField] float m_StartChargeDelay = 0.15f;
|
||||
|
||||
|
||||
bool m_IsCharging;
|
||||
float m_ChargeTimer;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace RebootReality.jelycho.Player {
|
||||
}
|
||||
|
||||
QuickAttackState m_QuickAttackState;
|
||||
|
||||
|
||||
int m_QuickAttackComboCounter;
|
||||
float m_QuickAttackComboTimer;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace RebootReality.jelycho.Player {
|
||||
void OnEnable() {
|
||||
Inventory.OnItemPickedUp += OnItemPickedUp;
|
||||
Inventory.OnItemDropped += OnItemDropped;
|
||||
|
||||
|
||||
m_PlayerAnimator.onQuickAttackFinished.AddListener(OnQuickAttackFinishedAnimation);
|
||||
m_PlayerAnimator.onChargeReady.AddListener(OnChargeReadyAnimation);
|
||||
}
|
||||
@@ -227,14 +227,14 @@ namespace RebootReality.jelycho.Player {
|
||||
s_Logger.Error("Cannot begin primary action when not set up as owner.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (m_EquippedItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemConfig itemConfig = m_EquippedItem.Config;
|
||||
|
||||
if (!m_IsCharging && itemConfig.isChargeable && m_EquippedItem.Config.chargeAction != null ) {
|
||||
if (!m_IsCharging && itemConfig.isChargeable && m_EquippedItem.Config.chargeAction != null) {
|
||||
m_ChargeTimer += Time.deltaTime;
|
||||
|
||||
if (m_ChargeTimer >= m_StartChargeDelay) {
|
||||
@@ -295,7 +295,7 @@ namespace RebootReality.jelycho.Player {
|
||||
m_QuickAttackComboCounter = 0;
|
||||
PlayQuickAttackAnimation(m_QuickAttackComboCounter);
|
||||
m_QuickAttackState = QuickAttackState.PlayingAnimation;
|
||||
|
||||
|
||||
if (m_EquippedItem.Config.quickAttackAction != null) {
|
||||
m_EquippedItem.Config.quickAttackAction.Attack(this, m_EquippedItem);
|
||||
}
|
||||
@@ -367,7 +367,7 @@ namespace RebootReality.jelycho.Player {
|
||||
m_TargetInteractable.Value.Interact();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// @MARK: Hands animations
|
||||
//
|
||||
@@ -401,10 +401,10 @@ namespace RebootReality.jelycho.Player {
|
||||
base.OnClientTick(deltaTime);
|
||||
|
||||
if (m_IsSetupAsOwner) {
|
||||
TickCamera();
|
||||
TickCamera(deltaTime);
|
||||
UpdateAnimator(m_Locomotion.Velocity);
|
||||
SenseInteractable();
|
||||
|
||||
|
||||
if (m_QuickAttackComboTimer > 0.0f) {
|
||||
m_QuickAttackComboTimer -= deltaTime;
|
||||
|
||||
@@ -418,7 +418,7 @@ namespace RebootReality.jelycho.Player {
|
||||
if (m_SyncRemoteStateTimer <= 0.0f) {
|
||||
m_SyncRemoteStateTimer = 1.0f / NetworkSystem.TickRate.IndexValue;
|
||||
|
||||
RemotePlayerActorState remoteState = new RemotePlayerActorState {
|
||||
var remoteState = new RemotePlayerActorState {
|
||||
Position = transform.position,
|
||||
Velocity = m_Locomotion.Velocity,
|
||||
LookPitch = m_Camera.Pitch,
|
||||
@@ -531,15 +531,14 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
switch ((PlayerActorEvents) actorEvent.EventID) {
|
||||
case PlayerActorEvents.UpdatedRemoteState: {
|
||||
RemotePlayerActorState remoteState = new RemotePlayerActorState();
|
||||
var remoteState = new RemotePlayerActorState();
|
||||
DataSerializationUtils.Deserialize(actorEvent.Data, ref remoteState);
|
||||
m_RemoteState = remoteState;
|
||||
break;
|
||||
}
|
||||
|
||||
case PlayerActorEvents.PrimaryEquippedItemChanged: {
|
||||
PlayerActorPrimaryEquippedItemChangedEvent itemChangedEvent =
|
||||
new PlayerActorPrimaryEquippedItemChangedEvent();
|
||||
var itemChangedEvent = new PlayerActorPrimaryEquippedItemChangedEvent();
|
||||
DataSerializationUtils.Deserialize(actorEvent.Data, ref itemChangedEvent);
|
||||
|
||||
if (itemChangedEvent.ItemActorID == 0) {
|
||||
@@ -563,8 +562,9 @@ namespace RebootReality.jelycho.Player {
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerUpdateInventoryEvent updateInventoryEvent = new PlayerUpdateInventoryEvent();
|
||||
DataSerializationUtils.Deserialize(actorEvent.Data, ref updateInventoryEvent);
|
||||
var updateInventoryEvent = new PlayerUpdateInventoryEvent();
|
||||
DataSerializationUtils.Deserialize(actorEvent.Data,
|
||||
ref updateInventoryEvent);
|
||||
|
||||
for (int i = 0; i < Inventory.SlotsCount; i++) {
|
||||
ushort actorID = updateInventoryEvent.SlotsActorIDs[i];
|
||||
@@ -588,7 +588,7 @@ namespace RebootReality.jelycho.Player {
|
||||
break;
|
||||
}
|
||||
|
||||
PlayerPlayHandsAnimationEvent handsAnimationEvent = new PlayerPlayHandsAnimationEvent();
|
||||
var handsAnimationEvent = new PlayerPlayHandsAnimationEvent();
|
||||
DataSerializationUtils.Deserialize(actorEvent.Data, ref handsAnimationEvent);
|
||||
|
||||
// if (m_Animator.HasState(m_HandsLayerIndex, handsAnimationEvent.AnimationHash)) {
|
||||
@@ -620,9 +620,9 @@ namespace RebootReality.jelycho.Player {
|
||||
m_IsSetupAsOwner = true;
|
||||
}
|
||||
|
||||
void TickCamera() {
|
||||
void TickCamera(float deltaTime) {
|
||||
// Camera Stuff
|
||||
m_Camera.Tick();
|
||||
m_Camera.Tick(deltaTime);
|
||||
|
||||
if (m_Locomotion.IsGrounded &&
|
||||
m_Locomotion.SpeedXZ >= m_Locomotion.runSpeed * m_EnableCameraBobbingPercentThreshold) {
|
||||
@@ -637,10 +637,10 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
m_CurrentCameraBobbing = Mathf.MoveTowards(m_CurrentCameraBobbing,
|
||||
m_TargetCameraBobbing,
|
||||
m_CameraBobbingTransitionSpeed * Time.deltaTime);
|
||||
m_CameraBobbingTransitionSpeed * deltaTime);
|
||||
m_Camera.SetBobbing(m_CurrentCameraBobbing);
|
||||
|
||||
m_CameraSpring.UpdateSpring(Time.deltaTime,
|
||||
m_CameraSpring.UpdateSpring(deltaTime,
|
||||
m_CharacterForwardTransform.up,
|
||||
m_CharacterForwardTransform.right,
|
||||
m_CharacterForwardTransform.forward);
|
||||
@@ -655,10 +655,11 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
public void DealDamage(IKillable target) {
|
||||
if (target is Actor actor) {
|
||||
PlayerActorDealDamageCommand dealDamageCommand = new PlayerActorDealDamageCommand {
|
||||
var dealDamageCommand = new PlayerActorDealDamageCommand {
|
||||
TargetActorID = actor.ActorID
|
||||
};
|
||||
SendActorCommand((byte)PlayerActorCommands.DealDamage, ref dealDamageCommand);
|
||||
SendActorCommand((byte) PlayerActorCommands.DealDamage,
|
||||
ref dealDamageCommand);
|
||||
} else {
|
||||
s_Logger.Error($"Player can only deal damage to other actors!");
|
||||
}
|
||||
@@ -706,8 +707,9 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerUpdateInventoryEvent updateInventoryEvent = new PlayerUpdateInventoryEvent();
|
||||
updateInventoryEvent.SlotsActorIDs = new NativeArray<ushort>(Inventory.SlotsCount, Allocator.Temp);
|
||||
var updateInventoryEvent = new PlayerUpdateInventoryEvent {
|
||||
SlotsActorIDs = new NativeArray<ushort>(Inventory.SlotsCount, Allocator.Temp)
|
||||
};
|
||||
for (int i = 0; i < Inventory.SlotsCount; i++) {
|
||||
updateInventoryEvent.SlotsActorIDs[i] = Inventory.GetItem(i)?.ActorID ?? (ushort) 0;
|
||||
}
|
||||
@@ -763,10 +765,9 @@ namespace RebootReality.jelycho.Player {
|
||||
m_EquippedItem.MountTo(this, m_EquippedItem.Config.characterEquippedMountSlotName);
|
||||
}
|
||||
|
||||
PlayerActorPrimaryEquippedItemChangedEvent itemChangedEvent =
|
||||
new PlayerActorPrimaryEquippedItemChangedEvent {
|
||||
ItemActorID = m_EquippedItem != null ? m_EquippedItem.ActorID : (ushort) 0
|
||||
};
|
||||
var itemChangedEvent = new PlayerActorPrimaryEquippedItemChangedEvent {
|
||||
ItemActorID = m_EquippedItem != null ? m_EquippedItem.ActorID : (ushort) 0
|
||||
};
|
||||
SendActorEvent((byte) PlayerActorEvents.PrimaryEquippedItemChanged, ref itemChangedEvent);
|
||||
|
||||
if (m_EquippedItem != null) {
|
||||
@@ -779,7 +780,7 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
SetHandsIdleAnimation();
|
||||
}
|
||||
|
||||
|
||||
void SpawnAdditionalEquippedItemActors() {
|
||||
DestroyAdditionalEquippedItemActors();
|
||||
|
||||
@@ -861,7 +862,9 @@ namespace RebootReality.jelycho.Player {
|
||||
// @MARK: Sensors
|
||||
//
|
||||
public bool TryGetBeaconPosition(out Vector3 position) {
|
||||
Ray ray = new Ray(m_Camera.Camera.transform.position, m_Camera.Camera.transform.forward);
|
||||
var ray = new Ray(m_Camera.Camera.transform.position,
|
||||
m_Camera.Camera.transform.forward);
|
||||
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, m_BeaconPlacementMaxDistance, m_BeaconPlacementLayerMask) &&
|
||||
Vector3.Dot(hit.normal, Vector3.up) >= m_NormalDotUpThreshold) {
|
||||
position = hit.point;
|
||||
@@ -888,7 +891,7 @@ namespace RebootReality.jelycho.Player {
|
||||
return;
|
||||
}
|
||||
|
||||
PlayerActorPickupItemCommand command = new PlayerActorPickupItemCommand {
|
||||
var command = new PlayerActorPickupItemCommand {
|
||||
ItemActorID = actor.ActorID
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.PickupItem, ref command);
|
||||
@@ -906,8 +909,9 @@ namespace RebootReality.jelycho.Player {
|
||||
SelectedInventorySlot.Value = Inventory.SlotsCount - 1;
|
||||
}
|
||||
|
||||
PlayerActorSelectItemSlotCommand command = new PlayerActorSelectItemSlotCommand();
|
||||
command.SlotIndex = SelectedInventorySlot.Value;
|
||||
var command = new PlayerActorSelectItemSlotCommand {
|
||||
SlotIndex = SelectedInventorySlot.Value
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.SelectItemSlot, ref command);
|
||||
}
|
||||
|
||||
@@ -923,8 +927,9 @@ namespace RebootReality.jelycho.Player {
|
||||
SelectedInventorySlot.Value = 0;
|
||||
}
|
||||
|
||||
PlayerActorSelectItemSlotCommand command = new PlayerActorSelectItemSlotCommand();
|
||||
command.SlotIndex = SelectedInventorySlot.Value;
|
||||
var command = new PlayerActorSelectItemSlotCommand {
|
||||
SlotIndex = SelectedInventorySlot.Value
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.SelectItemSlot, ref command);
|
||||
}
|
||||
|
||||
@@ -941,8 +946,9 @@ namespace RebootReality.jelycho.Player {
|
||||
|
||||
SelectedInventorySlot.Value = slotIndex;
|
||||
|
||||
PlayerActorSelectItemSlotCommand command = new PlayerActorSelectItemSlotCommand();
|
||||
command.SlotIndex = SelectedInventorySlot.Value;
|
||||
var command = new PlayerActorSelectItemSlotCommand {
|
||||
SlotIndex = SelectedInventorySlot.Value
|
||||
};
|
||||
SendActorCommand((byte) PlayerActorCommands.SelectItemSlot, ref command);
|
||||
}
|
||||
|
||||
@@ -963,11 +969,11 @@ namespace RebootReality.jelycho.Player {
|
||||
m_CharacterTurnVelocitySmooth = 0.0f;
|
||||
}
|
||||
|
||||
PlayerLocomotionAnimatorParams locomotionParams = new PlayerLocomotionAnimatorParams {
|
||||
var locomotionParams = new PlayerLocomotionAnimatorParams {
|
||||
IsGrounded = m_Locomotion.IsGrounded,
|
||||
VelocityForwardNormalized = forwardNormalized,
|
||||
VelocityRightNormalized = rightNormalized,
|
||||
TurnVelocity = m_CharacterTurnVelocitySmooth
|
||||
TurnVelocity = m_CharacterTurnVelocitySmooth
|
||||
};
|
||||
m_PlayerAnimator.SetLocomotionParams(locomotionParams);
|
||||
|
||||
@@ -1093,7 +1099,7 @@ namespace RebootReality.jelycho.Player {
|
||||
return sizeof(int); // SlotIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct PlayerActorRequestHandsAnimationCommand : IActorData {
|
||||
public int AnimationHash;
|
||||
|
||||
@@ -1116,7 +1122,7 @@ namespace RebootReality.jelycho.Player {
|
||||
public int GetMaxBytes() {
|
||||
return sizeof(ushort);
|
||||
}
|
||||
|
||||
|
||||
public void Serialize(NetworkBufferWriter writer) {
|
||||
writer.Write(TargetActorID);
|
||||
}
|
||||
@@ -1174,7 +1180,7 @@ namespace RebootReality.jelycho.Player {
|
||||
return sizeof(byte) + SlotsActorIDs.Length * sizeof(ushort);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct PlayerPlayHandsAnimationEvent : IActorData {
|
||||
public int AnimationHash;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user