Silly enemy, attack bug fix

This commit is contained in:
ThomasCharester committed 2026-11-18 21:34:31 +03:00
1 parent b02e201cd0
commit 1d107924bf
567 files changed
+197825 -635242

No files matched your search

@@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;
@@ -6,6 +7,8 @@ namespace Code.OfficeGame.BattleMode.Actions.AI
public abstract class EnemyDecider
{
public abstract UniTask<(BattleActionDecisionResult decisionResult, BattleActionData actionData)>
DecideEnemy(CancellationToken ctx, EntityProperties entity);
DecideEnemy(CancellationToken ctx, EntityProperties entity, Dictionary<BattleActionType, BattleAction> battleActions);
public abstract EnemyDeciderTypes EnemyDeciderType { get; }
}
}
@@ -1,3 +1,3 @@
fileFormatVersion: 2
guid: c1bba480028a459a960d731f9ae971d5
timeCreated: 1794940179
guid: bbfe8fd114bf4814b5efecee9b2bf086
timeCreated: 1794949033
@@ -0,0 +1,66 @@
using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;
using UnityEngine;
namespace Code.OfficeGame.BattleMode.Actions.AI.EnemyDeciders
{
public class FrankAttackDecider : EnemyDecider
{
private EntityProperties _player;
public FrankAttackDecider(EntityProperties player)
{
_player = player;
}
public override async UniTask<(BattleActionDecisionResult decisionResult, BattleActionData actionData)> DecideEnemy(
CancellationToken ctx,
EntityProperties entity,
Dictionary<BattleActionType,BattleAction> battleActions)
{
await UniTask.Yield();
var entityPosition = entity.transform.position;
var playerPosition = _player.transform.position;
var enemyToPlayer = playerPosition - entityPosition;
var rotateToPlayer = Quaternion.LookRotation(
playerPosition - entityPosition,
Vector3.up);
BattleActionDecisionResult decisionResult = null;
BattleActionData actionData = null;
if (enemyToPlayer.magnitude > 1f)
{
var positionToPlayer = entityPosition + enemyToPlayer.normalized * (enemyToPlayer.magnitude - 0.5f);
decisionResult = new PositionBattleActionDeciderResult()
{
ActionType = BattleActionType.Move,
Position = positionToPlayer,
Rotation = rotateToPlayer,
ResultCode = BattleActionDecisionResultCode.Decided
};
actionData = battleActions[BattleActionType.Move].MountAndGetFrames(entity, decisionResult);
}
else
{
decisionResult = new RotationBattleActionDeciderResult()
{
ActionType = BattleActionType.PlayerAttackMMA,
Rotation = rotateToPlayer,
ResultCode = BattleActionDecisionResultCode.Decided
};
actionData = battleActions[BattleActionType.PlayerAttackMMA].MountAndGetFrames(entity, decisionResult);
}
return (decisionResult, actionData);
}
public override EnemyDeciderTypes EnemyDeciderType => EnemyDeciderTypes.FrankAttack;
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: e2dfe2052460497c938ce9fdcc3826c1
timeCreated: 1794949053
@@ -1,7 +1,6 @@
using Code.Game.Gameplay.Player;
using Code.OfficeGame.BattleMode.Actions.Deciders;
using Code.OfficeGame.BattleMode.Timeline;
using KinematicCharacterController;
using UnityEngine;
using UnityEngine.AI;
@@ -7,9 +7,9 @@ namespace Code.OfficeGame.BattleMode.Actions
public override void Tick(float tickDelta, EntityProperties entity, BattleActionDecisionResult battleActionDecisionResult,
BattleActionData battleActionData)
{
battleActionData.Finished = true;
// battleActionData.Finished = true;
}
public override BattleActionType ActionType => BattleActionType.None;
public override DeciderType DeciderType => DeciderType.AsIs;
public override BattleActionData MountAndGetFrames(EntityProperties entity, BattleActionDecisionResult result)
@@ -15,7 +15,7 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
private CameraStateMachine _cameraStateMachine;
private IInputService _inputService;
private Quaternion _targetRotation;
private Quaternion _targetRotation, _chosenRotation;
private LayerMask _navMeshMask;
@@ -46,11 +46,13 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
_waitForEnterTokenSource.Dispose();
_waitForEnterTokenSource = null;
if (_chosenRotation == default) _chosenRotation = _targetRotation;
return new RotationBattleActionDeciderResult()
{
ResultCode = _decisionResultCode,
Rotation = _targetRotation
Rotation = _chosenRotation
};
}
@@ -153,6 +155,8 @@ namespace Code.OfficeGame.BattleMode.Actions.Deciders
_playerLockedDecisionMarker.transform.rotation = _targetRotation;
_playerLockedDecisionMarker.Toggle(true);
_chosenRotation = _targetRotation;
_waitForEnterTokenSource?.Cancel();
}
}
@@ -22,7 +22,7 @@ namespace Code.OfficeGame.BattleMode.Actions
public EntityHealth EntityHealth;
public EntityTeam Team;
public EntityTeamData TeamData;
[DoNotSerialize]
public List<Effect> Effects = new();