结构大修改,改成朴实无华的结构,不过度架构。能跑就行

This commit is contained in:
2025-12-23 00:09:39 +08:00
parent 384f11f620
commit 3d14085920
2837 changed files with 149714 additions and 1100 deletions

View File

@@ -0,0 +1,74 @@
using ECM2;
using ECM2.Examples.FirstPerson;
using Fantasy.Async;
using NBC;
using Fantasy.Entitas;
using Fantasy.Entitas.Interface;
using RootMotion.FinalIK;
using UnityEngine;
namespace NBF.Fishing2
{
/// <summary>
/// Unit 对应的unity对象组件
/// </summary>
public class UnitUnityComponent : Entity
{
public GameObject GameObject { get; set; }
public GameObject ModelGameObject { get; set; }
public Transform Transform { get; set; }
public PlayerModelAsset ModelAsset { get; set; }
public CharacterMovement Character { get; set; }
public FirstPersonCharacter FirstPerson { get; set; }
public PlayerRootAsset RootAsset { get; set; }
#region System
public class UnitUnityComponentDestroySystem : DestroySystem<UnitUnityComponent>
{
protected override void Destroy(UnitUnityComponent self)
{
if (self.GameObject != null)
{
Object.Destroy(self.GameObject);
}
self.ModelAsset = null;
self.GameObject = null;
self.Transform = null;
self.Character = null;
self.FirstPerson = null;
self.RootAsset = null;
}
}
#endregion
public async FTask InitUnityObject()
{
var gameObject = PrefabsHelper.CreatePlayer(SceneSettings.Instance.Node);
GameObject = gameObject;
Transform = gameObject.transform;
Transform.localPosition = new Vector3(484, 1, 422);
Parent.GetOrAddComponent<FlashlightComponent>();
Character = gameObject.GetComponent<CharacterMovement>();
FirstPerson = gameObject.GetComponent<FirstPersonCharacter>();
RootAsset = gameObject.GetComponent<PlayerRootAsset>();
// Parent.GetOrAddComponent<CharacterControllerComponent>();
var modelObject = PrefabsHelper.CreatePlayer(RootAsset.Root, "Human_Male");
modelObject.transform.localPosition = Vector3.zero;
ModelGameObject = modelObject;
ModelAsset = modelObject.GetComponent<PlayerModelAsset>();
Parent.GetOrAddComponent<CharacterMovementComponent>();
Parent.GetOrAddComponent<CharacterLookComponent>();
Parent.GetOrAddComponent<CharacterAnimatorComponent>();
}
}
}