You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HighGroundRoyaleNetcode/Assets/Scripts/Gameplay/CrowsForesightAbility.cs

31 lines
1.2 KiB
C#

using Unity.Netcode;
using UnityEngine;
using Unity.BossRoom.Gameplay.GameplayObjects.Character;
[CreateAssetMenu(menuName = "Abilities/CrowsForesight")]
public class CrowsForesightAbility : Ability
{
public override void Execute(ServerCharacter character, Vector3 targetPosition, Vector3 targetRotation)
{
if (!NetworkManager.Singleton.IsServer)
{
Debug.LogError("[CrowsForesightAbility] Execute should only be called on the server.");
return;
}
Debug.Log($"[CrowsForesightAbility] Spawning foresight prefab for Crow {character.OwnerClientId}");
GameObject foresightInstance = Instantiate(GetPrefab(), character.transform.position, Quaternion.identity);
NetworkObject netObj = foresightInstance.GetComponent<NetworkObject>();
if (netObj)
{
netObj.Spawn();
CrowsForesightPrefab foresightPrefab = foresightInstance.GetComponent<CrowsForesightPrefab>();
foresightPrefab.Initialize(CrowManager.Instance.GetCurrentCrow().OwnerClientId, this);
Debug.Log($"[CrowsForesightAbility] Assigned foresight prefab to Crow {character.OwnerClientId}");
}
}
}