37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using UnityGameFramework.Runtime;
|
|
|
|
namespace SepCore.Entity
|
|
{
|
|
public static class EntityExtension
|
|
{
|
|
private static int s_SerialId = -10;
|
|
|
|
public static EntityBase GetGameEntity(this EntityComponent entityComponent, int entityId)
|
|
{
|
|
UnityGameFramework.Runtime.Entity entity = entityComponent.GetEntity(entityId);
|
|
if (entity == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
return (EntityBase)entity.Logic;
|
|
}
|
|
|
|
public static void HideEntity(this EntityComponent entityComponent, EntityBase entity)
|
|
{
|
|
entityComponent.HideEntity(entity.Entity);
|
|
}
|
|
|
|
public static void AttachEntity(this EntityComponent entityComponent, EntityBase entityBase, int ownerId,
|
|
string parentTransformPath = null, object userData = null)
|
|
{
|
|
entityComponent.AttachEntity(entityBase.Entity, ownerId, parentTransformPath, userData);
|
|
}
|
|
|
|
public static int NextId(this EntityComponent entityComponent)
|
|
{
|
|
return --s_SerialId;
|
|
}
|
|
}
|
|
}
|