2025-08-28 16:20:24 +08:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2025-10-10 14:08:23 +08:00
|
|
|
using Base;
|
|
|
|
|
using Data;
|
|
|
|
|
using Entity;
|
2025-07-21 13:58:58 +08:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace Prefab
|
|
|
|
|
{
|
|
|
|
|
public class EntityPrefab : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
public Entity.Entity entity;
|
|
|
|
|
public Outline outline;
|
|
|
|
|
|
2025-08-07 16:44:43 +08:00
|
|
|
public Vector3 Position
|
|
|
|
|
{
|
2025-10-10 14:08:23 +08:00
|
|
|
get => transform.position;
|
|
|
|
|
set => transform.position = value;
|
2025-08-07 16:44:43 +08:00
|
|
|
}
|
2025-07-21 13:58:58 +08:00
|
|
|
|
2025-10-10 14:08:23 +08:00
|
|
|
public void Init(EntityDef entityDef)
|
2025-07-21 13:58:58 +08:00
|
|
|
{
|
2025-08-19 20:22:10 +08:00
|
|
|
entity.Init(entityDef);
|
2025-08-07 16:44:43 +08:00
|
|
|
outline.Init();
|
|
|
|
|
outline.Hide();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void DefaultInit()
|
|
|
|
|
{
|
|
|
|
|
var animator = GetComponentsInChildren<SpriteAnimator>();
|
2025-08-27 19:56:49 +08:00
|
|
|
var inf = animator.Cast<ITick>().ToArray();
|
|
|
|
|
foreach (EntityState state in Enum.GetValues(typeof(EntityState)))
|
|
|
|
|
{
|
|
|
|
|
var orientationDict = new Dictionary<Orientation, ITick[]>();
|
|
|
|
|
foreach (Orientation orientation in Enum.GetValues(typeof(Orientation)))
|
|
|
|
|
orientationDict[orientation] = inf; // 所有值都指向同一个列表
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-21 13:58:58 +08:00
|
|
|
outline.Init();
|
|
|
|
|
outline.Hide();
|
|
|
|
|
}
|
|
|
|
|
|
2025-10-10 14:08:23 +08:00
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"实体定义: {entity.entityDef.defName}" +
|
|
|
|
|
$"实体位置: {entity.Position.x},{entity.Position.y},{entity.Position.z}";
|
|
|
|
|
}
|
2025-07-21 13:58:58 +08:00
|
|
|
}
|
|
|
|
|
}
|