Files
Fishing2/Assets/Scripts/Fishing/Player/FPlayer.cs
2025-12-24 00:09:28 +08:00

66 lines
1.7 KiB
C#

using System;
using ECM2;
using ECM2.Examples.FirstPerson;
using Fantasy;
using NBF.Fishing2;
using UnityEngine;
using UnityEngine.InputSystem;
namespace NBF
{
public partial class FPlayer : MonoService<FPlayer>
{
public Transform Root;
public Transform Eye;
public Transform FppLook;
public Transform IK;
public PlayerModelAsset ModelAsset;
public CharacterMovement Character;
public FirstPersonCharacter FirstPerson;
public GameObject ModelGameObject { get; set; }
public PlayerAnimator Animator;
public FPlayerData Data { get; private set; }
protected override void OnAwake()
{
Character = gameObject.GetComponent<CharacterMovement>();
FirstPerson = gameObject.GetComponent<FirstPersonCharacter>();
Animator = gameObject.AddComponent<PlayerAnimator>();
Data = FPlayerData.Instance;
transform.localPosition = new Vector3(484, 1, 422);
}
private void Start()
{
AddInputEvent();
CreatePlayerModel();
}
private void Update()
{
UpdateMove();
}
private void OnDestroy()
{
RemoveInputEvent();
}
#region
private void CreatePlayerModel()
{
var modelObject = PrefabsHelper.CreatePlayer(Root, "Human_Male");
modelObject.transform.localPosition = Vector3.zero;
ModelGameObject = modelObject;
ModelAsset = modelObject.GetComponent<PlayerModelAsset>();
Animator.SetModelAsset(this);
}
#endregion
}
}