Fixing is endless
This commit is contained in:
1 parent
c0dec163cd
commit
3ca9444333
45 files changed
+123468
-18592
No files matched your search
@@ -1,9 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public class AttackBattleActionData : BattleActionData
|
||||
{
|
||||
public int CurrentFrame;
|
||||
public int TransitionFrames;
|
||||
|
||||
public override BattleActionData GetSnapshot()
|
||||
{
|
||||
var snapshot = new AttackBattleActionData()
|
||||
|
||||
@@ -1,20 +1,28 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public class StuggerActionData : BattleActionData
|
||||
{
|
||||
public int CurrentFrame;
|
||||
public int TransitionFrames = 60;
|
||||
public int TransitionFrames;
|
||||
|
||||
public Vector3 KnockbackDirection;
|
||||
public float KnockbackSpeed;
|
||||
public float KnockbackDistance;
|
||||
|
||||
public override BattleActionData GetSnapshot()
|
||||
{
|
||||
var snapshot = new StuggerActionData()
|
||||
return new StuggerActionData
|
||||
{
|
||||
TotalFrames = TotalFrames,
|
||||
Finished = Finished,
|
||||
CurrentFrame = CurrentFrame,
|
||||
TransitionFrames = TransitionFrames,
|
||||
KnockbackDirection = KnockbackDirection,
|
||||
KnockbackSpeed = KnockbackSpeed,
|
||||
KnockbackDistance = KnockbackDistance
|
||||
};
|
||||
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
public override void RestoreSnapshot(BattleActionData snapshot)
|
||||
@@ -25,6 +33,9 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
Finished = neededSnapshot.Finished;
|
||||
CurrentFrame = neededSnapshot.CurrentFrame;
|
||||
TransitionFrames = neededSnapshot.TransitionFrames;
|
||||
KnockbackDirection = neededSnapshot.KnockbackDirection;
|
||||
KnockbackSpeed = neededSnapshot.KnockbackSpeed;
|
||||
KnockbackDistance = neededSnapshot.KnockbackDistance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,5 +15,11 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
public int StuggerFrames;
|
||||
|
||||
public int Damage;
|
||||
|
||||
public float KnockbackSpeed = 6f;
|
||||
|
||||
public float KnockbackDistance = 2f;
|
||||
|
||||
public Vector3 LocalKnockbackDirection = Vector3.forward;
|
||||
}
|
||||
}
|
||||
@@ -98,12 +98,23 @@ namespace Code.OfficeGame.BattleMode.Actions.Attacks
|
||||
// entityAnimator.Play(EntryStateHash, 0, 0f);
|
||||
// entityAnimator.Update(0f);
|
||||
}
|
||||
|
||||
private void OnEnemyHit(Collider enemyCollider)
|
||||
|
||||
private void OnEnemyHit(Collider attacker, Collider enemyCollider)
|
||||
{
|
||||
var originEntityId = enemyCollider.GetComponentInParent<EntityProperties>().GetEntityId();
|
||||
|
||||
var actionData = new StuggerActionData { TotalFrames = _attackData.StuggerFrames, CurrentFrame = 0 };
|
||||
Vector3 attackerDirection = attacker.transform.TransformDirection(_attackData.LocalKnockbackDirection);
|
||||
attackerDirection.y = 0f;
|
||||
attackerDirection.Normalize();
|
||||
|
||||
var actionData = new StuggerActionData
|
||||
{
|
||||
TotalFrames = _attackData.StuggerFrames,
|
||||
CurrentFrame = 0,
|
||||
KnockbackDirection = attackerDirection,
|
||||
KnockbackSpeed = _attackData.KnockbackSpeed,
|
||||
KnockbackDistance = _attackData.KnockbackDistance
|
||||
};
|
||||
var decisionResult = new AsIsBattleActionDeciderResult { ActionType = BattleActionType.Stugger };
|
||||
|
||||
battleTimeline.ForceDecideAction(originEntityId, actionData, decisionResult);
|
||||
|
||||
@@ -21,19 +21,27 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
|
||||
public override BattleActionType ActionType => BattleActionType.Stugger;
|
||||
public override DeciderType DeciderType => DeciderType.AsIs;
|
||||
|
||||
public override BattleActionData MountAndGetFrames(EntityProperties entity, BattleActionDecisionResult result)
|
||||
{
|
||||
return new StuggerActionData { TotalFrames = _actionParameters.TotalFrames, Finished = false};
|
||||
return new StuggerActionData
|
||||
{
|
||||
TotalFrames = _actionParameters.TotalFrames,
|
||||
TransitionFrames = _actionParameters.TransitionFrames,
|
||||
Finished = false
|
||||
};
|
||||
}
|
||||
|
||||
public override void Finish(EntityProperties entity, BattleActionData actionData, BattleActionDecisionResult result)
|
||||
{
|
||||
|
||||
entity.KinematicCharacterMotor.BaseVelocity = Vector3.zero;
|
||||
entity.MovementController.Freeze = true;
|
||||
}
|
||||
|
||||
public override void Tick(float tickDelta,
|
||||
EntityProperties entity,
|
||||
BattleActionDecisionResult battleActionDecisionResult,
|
||||
public override void Tick(
|
||||
float tickDelta,
|
||||
EntityProperties entity,
|
||||
BattleActionDecisionResult battleActionDecisionResult,
|
||||
BattleActionData battleActionData)
|
||||
{
|
||||
if (battleActionData is not StuggerActionData stuggerActionData)
|
||||
@@ -42,21 +50,45 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
battleActionData.Finished = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (stuggerActionData.CurrentFrame == 0)
|
||||
{
|
||||
if (stuggerActionData.TotalFrames <= 0)
|
||||
stuggerActionData.TotalFrames = _actionParameters.TotalFrames;
|
||||
|
||||
if (stuggerActionData.TransitionFrames <= 0)
|
||||
stuggerActionData.TransitionFrames = _actionParameters.TransitionFrames;
|
||||
|
||||
var transitionTime = stuggerActionData.TransitionFrames * BattleTimeline.TickDelta;
|
||||
|
||||
|
||||
entity.SyncRootMotionToMotor();
|
||||
|
||||
entity.animator.applyRootMotion = false;
|
||||
entity.animator.CrossFadeInFixedTime(StuggerStateHash, transitionTime);
|
||||
}
|
||||
|
||||
if (stuggerActionData.KnockbackDistance > 0f
|
||||
&& stuggerActionData.KnockbackSpeed > 0f
|
||||
&& stuggerActionData.KnockbackDirection.sqrMagnitude > 0.0001f)
|
||||
{
|
||||
float stepDistance = Mathf.Min(
|
||||
stuggerActionData.KnockbackSpeed * tickDelta,
|
||||
stuggerActionData.KnockbackDistance);
|
||||
|
||||
stuggerActionData.KnockbackDistance -= stepDistance;
|
||||
|
||||
Vector3 step = stuggerActionData.KnockbackDirection * stepDistance;
|
||||
entity.KinematicCharacterMotor.MoveCharacter(
|
||||
entity.KinematicCharacterMotor.TransientPosition + step);
|
||||
}
|
||||
|
||||
stuggerActionData.CurrentFrame++;
|
||||
|
||||
if (stuggerActionData.CurrentFrame >= _actionParameters.TotalFrames)
|
||||
if (stuggerActionData.CurrentFrame >= stuggerActionData.TotalFrames)
|
||||
{
|
||||
Debug.Log("Frame last");
|
||||
entity.SyncRootMotionToMotor();
|
||||
entity.animator.Play(EntryStateHash, 0, 0f);
|
||||
entity.animator.Update(0f);
|
||||
|
||||
battleActionData.Finished = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,10 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
|
||||
|
||||
var hit = _hitBuffer[0];
|
||||
|
||||
var lookDirection = hit.point - _entityPosition;
|
||||
Vector3 hitPoint = hit.point;
|
||||
hitPoint.y = _entityPosition.y;
|
||||
|
||||
var lookDirection = hitPoint - _entityPosition;
|
||||
_targetRotation = Quaternion.LookRotation(lookDirection.normalized, Vector3.up);
|
||||
|
||||
_playerDecisionMarker.transform.rotation = _targetRotation;
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
public struct EntitySnapshot
|
||||
{
|
||||
public Vector3 BaseVelocity;
|
||||
public Vector3 Position;
|
||||
public Quaternion Rotation;
|
||||
|
||||
@@ -15,6 +16,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
return new EntitySnapshot
|
||||
{
|
||||
BaseVelocity = entityProperties.KinematicCharacterMotor.BaseVelocity,
|
||||
Position = entityProperties.KinematicCharacterMotor.TransientPosition,
|
||||
Rotation = entityProperties.KinematicCharacterMotor.TransientRotation,
|
||||
AnimatorSnapshot = AnimatorSnapshot.GetSnapshot(entityProperties.animator),
|
||||
@@ -26,7 +28,7 @@ namespace Code.OfficeGame.BattleMode.Actions
|
||||
{
|
||||
// 1. Возвращаем капсулу KCC
|
||||
entityProperties.KinematicCharacterMotor.SetPositionAndRotation(snapshot.Position, snapshot.Rotation);
|
||||
entityProperties.KinematicCharacterMotor.BaseVelocity = Vector3.zero;
|
||||
entityProperties.KinematicCharacterMotor.BaseVelocity = snapshot.BaseVelocity;
|
||||
|
||||
snapshot.ControllerSnapshot.RestoreSnapshot(entityProperties.MovementController);
|
||||
|
||||
|
||||
@@ -158,6 +158,13 @@ namespace Code.Game.OfficeGame.GameStates
|
||||
container = Context.SceneContainerManager.ScenesContainers[SceneId.Battle];
|
||||
}
|
||||
|
||||
//// TTT
|
||||
var player = container.Resolve<EntityProperties>();
|
||||
|
||||
entities.Remove(player);
|
||||
entities.Add(player);
|
||||
entities.Reverse();
|
||||
|
||||
_battleTimeline?.RunBattleLoopAsync(entities, _battleTokenSource.Token).Forget();
|
||||
|
||||
await container.Resolve<BattleTimelinePanel>().Open();
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Code.OfficeGame.BattleMode.HitBoxes
|
||||
_hitBoxLayerMask = LayerMask.GetMask("HitBox");
|
||||
}
|
||||
|
||||
public void CheckHitsForCurrentFrame(Action<Collider> onNewTargetHit, HitBoxPartType hitBoxPartType)
|
||||
public void CheckHitsForCurrentFrame(Action<Collider, Collider> onNewTargetHit, HitBoxPartType hitBoxPartType)
|
||||
{
|
||||
BoxCollider box = bodyParts[hitBoxPartType];
|
||||
Transform boxTransform = box.transform;
|
||||
@@ -46,7 +46,7 @@ namespace Code.OfficeGame.BattleMode.HitBoxes
|
||||
|
||||
if (hitCol.transform.root == transform.root) continue;
|
||||
|
||||
onNewTargetHit?.Invoke(hitCol);
|
||||
onNewTargetHit?.Invoke(box, hitCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,11 @@ namespace Code.OfficeGame.BattleMode.Snapshots
|
||||
Debug.Log(
|
||||
$"Also {battleActionData} of {currentActionData} for {entityId}");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log($"Something gone wrong for {entityId}, Restoring {actionDecisionResult.ActionType} Also {battleActionData}");
|
||||
}
|
||||
|
||||
actionDecisionResults[entityId] = actionDecisionResult.GetSnapshot();
|
||||
battleActionDatas[entityId] = battleActionData.GetSnapshot();
|
||||
|
||||
|
||||
@@ -265,7 +265,6 @@ namespace Code.OfficeGame.BattleMode.Timeline
|
||||
|
||||
while (accumulator >= TickDelta && !ctx.IsCancellationRequested)
|
||||
{
|
||||
// Debug.Log($"Simulating {counter}/{frameCount}");
|
||||
accumulator -= TickDelta;
|
||||
|
||||
var readyEntities = SimulateSingleFrame(_entities);
|
||||
|
||||
Reference in new issue
Block a user