Files
Cielonos/Assets/Scripts/MainGame/AttackArea/Submodules/AttackSubmodule.cs

52 lines
1.8 KiB
C#
Raw Normal View History

2025-11-25 08:19:33 -05:00
using System;
using Cielonos.MainGame.Characters;
2026-05-23 08:27:50 -04:00
using Cielonos.MainGame.Inventory;
2025-11-25 08:19:33 -05:00
using UnityEngine;
2026-06-13 18:43:40 -04:00
using Random = UnityEngine.Random;
2025-11-25 08:19:33 -05:00
namespace Cielonos.MainGame
{
2026-07-18 03:16:20 -04:00
public partial class AttackAreaBase
2025-11-25 08:19:33 -05:00
{
2026-07-18 03:16:20 -04:00
public class AttackSubmodule : AttackAreaSubmoduleBase
2025-11-25 08:19:33 -05:00
{
2026-07-18 03:16:20 -04:00
public bool isOverridingHitEffect;
public GameObject hitVFXPrefab;
public AttackUnit attackUnit;
public Attack.Value attackValue;
public Action<GameObject, CharacterBase> modifyHitEffectAction;
public AttackSubmodule(AttackAreaBase attackArea, AttackUnit attackUnit, GameObject hitVFXPrefab) : base(attackArea)
{
this.attackUnit = attackUnit;
this.attackValue = attackUnit.GetAttackValue(owner.creator);
this.isOverridingHitEffect = false;
this.hitVFXPrefab = hitVFXPrefab;
}
2025-11-25 08:19:33 -05:00
2026-07-18 03:16:20 -04:00
public GameObject SpawnHitVFX(CharacterBase creator, Vector3 position, Vector3 direction = default)
2025-11-25 08:19:33 -05:00
{
2026-07-18 03:16:20 -04:00
if (isOverridingHitEffect) return null;
if (hitVFXPrefab != null)
2026-06-13 18:43:40 -04:00
{
2026-07-18 03:16:20 -04:00
direction = direction != default ? direction : Vector3.up;
Quaternion rotation = Quaternion.LookRotation(direction);
if (attackUnit.randomizeVfxRotation)
{
rotation *= Quaternion.Euler(Random.Range(0f, 360f), Random.Range(0f, 360f), 0);
}
GameObject hitEffect = VFXObject.Spawn(hitVFXPrefab, creator, position, rotation,
timePolicy: owner.timePolicy);
return hitEffect;
2026-06-13 18:43:40 -04:00
}
2026-07-18 03:16:20 -04:00
return null;
2025-11-25 08:19:33 -05:00
}
}
}
2026-07-18 03:16:20 -04:00
}