197 lines
5.6 KiB
C#
197 lines
5.6 KiB
C#
using BrewMonster.Assets.PerfectWorld.Scripts.Players;
|
|
using BrewMonster.Network;
|
|
using BrewMonster.Scripts;
|
|
using BrewMonster.Scripts.Managers;
|
|
using ModelRenderer.Scripts.Common;
|
|
using ModelRenderer.Scripts.GameData;
|
|
using UnityEngine;
|
|
|
|
namespace BrewMonster
|
|
{
|
|
/// <summary>
|
|
/// Pet shortcut for quick summoning/recalling pets
|
|
/// </summary>
|
|
public class CECSCPet : CECShortcut
|
|
{
|
|
/*#region Fields
|
|
|
|
private int m_iPetIndex = -1; // Pet index in pet corral
|
|
private PET_ESSENCE m_pPetEssence; // Pet essence data
|
|
private bool m_bHasEssence = false; // Whether the pet essence has been loaded
|
|
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
/// <summary>
|
|
/// Default constructor
|
|
/// </summary>
|
|
public CECSCPet()
|
|
{
|
|
m_iSCType = (int)ShortcutType.SCT_PET;
|
|
m_iPetIndex = -1;
|
|
m_bHasEssence = false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copy constructor
|
|
/// </summary>
|
|
/// <param name="src">Source pet shortcut to copy from</param>
|
|
public CECSCPet(CECSCPet src)
|
|
{
|
|
m_iSCType = src.m_iSCType;
|
|
m_iPetIndex = src.m_iPetIndex;
|
|
m_pPetEssence = src.m_pPetEssence;
|
|
m_bHasEssence = src.m_bHasEssence;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Initialization
|
|
|
|
/// <summary>
|
|
/// Initialize the pet shortcut with a pet index
|
|
/// </summary>
|
|
/// <param name="iPetIndex">Index of the pet in the pet corral</param>
|
|
/// <returns>True if initialization succeeded</returns>
|
|
public bool Init(int iPetIndex)
|
|
{
|
|
CECHostPlayer pHost = EC_Game.GetGameRun()?.GetHostPlayer();
|
|
if (pHost == null)
|
|
return false;
|
|
|
|
EC_PetCorral pPetCorral = pHost.GetPetCorral();
|
|
if (pPetCorral == null)
|
|
return false;
|
|
|
|
//CECPetData pPet = pPetCorral.GetPetData(iPetIndex);
|
|
if (pPet == null)
|
|
return false;
|
|
|
|
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
|
|
if (pDB == null)
|
|
return false;
|
|
|
|
DATA_TYPE dataType = DATA_TYPE.DT_INVALID;
|
|
object essenceObj = pDB.get_data_ptr((uint)pPet.GetTemplateID(), ID_SPACE.ID_SPACE_ESSENCE, ref dataType);
|
|
|
|
if (essenceObj == null || !(essenceObj is PET_ESSENCE))
|
|
return false;
|
|
|
|
m_pPetEssence = (PET_ESSENCE)essenceObj;
|
|
m_bHasEssence = true;
|
|
m_iPetIndex = iPetIndex;
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CECShortcut Overrides
|
|
|
|
/// <summary>
|
|
/// Clone this pet shortcut
|
|
/// </summary>
|
|
/// <returns>A new instance with the same data</returns>
|
|
public override CECShortcut Clone()
|
|
{
|
|
return new CECSCPet(this);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Execute the pet shortcut - summon or recall the pet
|
|
/// </summary>
|
|
/// <returns>True if execution succeeded</returns>
|
|
public override bool Execute()
|
|
{
|
|
if (m_iPetIndex < 0)
|
|
return false;
|
|
|
|
CECHostPlayer pHost = EC_Game.GetGameRun()?.GetHostPlayer();
|
|
if (pHost == null)
|
|
return false;
|
|
|
|
EC_PetCorral pPetCorral = pHost.GetPetCorral();
|
|
if (pPetCorral == null)
|
|
return false;
|
|
|
|
//if (pPetCorral.GetActivePetIndex() == m_iPetIndex)
|
|
//{
|
|
// // If this pet is the active one, recall it
|
|
// pHost.RecallPet();
|
|
//}
|
|
else
|
|
{
|
|
// Check action switcher for fly-to-ride transition
|
|
CECActionSwitcherBase pSwitcher = pHost.GetActionSwitcher();
|
|
//if (pSwitcher != null && pSwitcher.OnFlyToRideAction(m_iPetIndex))
|
|
//{
|
|
// return true;
|
|
//}
|
|
|
|
// Summon this pet
|
|
//pHost.SummonPet(m_iPetIndex);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the icon file path for this pet
|
|
/// </summary>
|
|
/// <returns>Icon file path</returns>
|
|
//public override string GetIconFile()
|
|
//{
|
|
// return m_pPetEssence?.file_icon ?? string.Empty;
|
|
//}
|
|
|
|
/// <summary>
|
|
/// Get the description text for this pet
|
|
/// </summary>
|
|
/// <returns>Pet description</returns>
|
|
//public override string GetDesc()
|
|
//{
|
|
// // TODO: Implement pet description retrieval
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Check if this pet is currently active
|
|
/// </summary>
|
|
/// <returns>True if this pet is the active pet</returns>
|
|
//public bool IsActivePet()
|
|
//{
|
|
// EC_PetCorral pPetCorral = EC_Game.GetGameRun()?.GetHostPlayer()?.GetPetCorral();
|
|
// if (pPetCorral == null)
|
|
// return false;
|
|
|
|
// return pPetCorral.GetActivePetIndex() == m_iPetIndex;
|
|
//}
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
/// <summary>
|
|
/// Get the pet index in pet corral
|
|
/// </summary>
|
|
/// <returns>Pet index</returns>
|
|
public int GetPetIndex()
|
|
{
|
|
return m_iPetIndex;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Get the pet essence data
|
|
/// </summary>
|
|
/// <returns>Pet essence</returns>
|
|
public PET_ESSENCE GetPetEssence()
|
|
{
|
|
return m_pPetEssence;
|
|
}
|
|
|
|
#endregion*/
|
|
}
|
|
} |