重构清理敌人类
This commit is contained in:
@@ -5,6 +5,7 @@ using Cysharp.Threading.Tasks;
|
||||
using SepCore.CustomUtility;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
using HideEntityCompleteEventArgs = UnityGameFramework.Runtime.HideEntityCompleteEventArgs;
|
||||
using ShowEntityFailureEventArgs = UnityGameFramework.Runtime.ShowEntityFailureEventArgs;
|
||||
@@ -149,7 +150,7 @@ namespace SepCore.AsyncTask
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return ShowEntityByDataAsync<Player>(entityComponent, typeof(Player), "Player",
|
||||
return ShowEntityByDataAsync<Player>(entityComponent, typeof(Player), GameEntry.Luban.Global.PlayerGroupName,
|
||||
Constant.AssetPriority.PlayerAsset, data, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -165,7 +166,7 @@ namespace SepCore.AsyncTask
|
||||
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
|
||||
|
||||
return entityComponent.ShowEntityAsync(
|
||||
data.Id, enemyType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), "Enemy",
|
||||
data.Id, enemyType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), GameEntry.Luban.Global.EnemyGroupName,
|
||||
Constant.AssetPriority.EnemyAsset, data, timeout, cancellationToken)
|
||||
.ContinueWith(entity => entity.Logic as EnemyBase);
|
||||
}
|
||||
@@ -182,7 +183,7 @@ namespace SepCore.AsyncTask
|
||||
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
|
||||
|
||||
return entityComponent.ShowEntityAsync(
|
||||
data.Id, weaponType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), "Weapon",
|
||||
data.Id, weaponType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), GameEntry.Luban.Global.PlayerGroupName,
|
||||
Constant.AssetPriority.WeaponAsset, data, timeout, cancellationToken)
|
||||
.ContinueWith(entity => entity.Logic as WeaponBase);
|
||||
}
|
||||
@@ -195,7 +196,7 @@ namespace SepCore.AsyncTask
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return ShowEntityByDataAsync<Effect>(entityComponent, typeof(Effect), "Effect",
|
||||
return ShowEntityByDataAsync<Effect>(entityComponent, typeof(Effect), GameEntry.Luban.Global.EffectGroupNmae,
|
||||
Constant.AssetPriority.EffectAsset, data, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -207,7 +208,7 @@ namespace SepCore.AsyncTask
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return ShowEntityByDataAsync<CoinEntity>(entityComponent, typeof(CoinEntity), "Drop",
|
||||
return ShowEntityByDataAsync<CoinEntity>(entityComponent, typeof(CoinEntity), GameEntry.Luban.Global.DropGroupName,
|
||||
Constant.AssetPriority.EffectAsset, data, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -219,10 +220,76 @@ namespace SepCore.AsyncTask
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return ShowEntityByDataAsync<ExpEntity>(entityComponent, typeof(ExpEntity), "Drop",
|
||||
return ShowEntityByDataAsync<ExpEntity>(entityComponent, typeof(ExpEntity), GameEntry.Luban.Global.DropGroupName,
|
||||
Constant.AssetPriority.EffectAsset, data, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步显示投射物实体。
|
||||
/// </summary>
|
||||
public static UniTask<EnemyProjectile> ShowProjectileAsync(this EntityComponent entityComponent,
|
||||
EnemyProjectileData data,
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return ShowEntityByDataAsync<EnemyProjectile>(entityComponent, typeof(EnemyProjectile),
|
||||
GameEntry.Luban.Global.ProjectileGroupName,
|
||||
Constant.AssetPriority.BulletAsset, data, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步显示投射物实体(直接入参快捷方法)。
|
||||
/// </summary>
|
||||
public static UniTask<EnemyProjectile> ShowProjectileAsync(this EntityComponent entityComponent,
|
||||
int ownerEntityId,
|
||||
CampType ownerCamp,
|
||||
int attackDamage,
|
||||
Vector3 position,
|
||||
Vector3 direction,
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
int projectileEntityId = entityComponent.NextId();
|
||||
float speed = GameEntry.Luban.Global.ProjectileSpeed / 1000f;
|
||||
float lifeTime = GameEntry.Luban.Global.ProjectileLifeTime / 1000f;
|
||||
string assetName = GameEntry.Luban.Global.ProjectileEntity;
|
||||
|
||||
var projectileData = new EnemyProjectileData(projectileEntityId, ownerEntityId, ownerCamp,
|
||||
attackDamage, speed, lifeTime, direction, assetName)
|
||||
{
|
||||
Position = position,
|
||||
Rotation = Quaternion.LookRotation(direction, Vector3.up)
|
||||
};
|
||||
|
||||
return entityComponent.ShowProjectileAsync(projectileData, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步显示投射物实体。
|
||||
/// </summary>
|
||||
public static UniTask<EnemyProjectile> ShowProjectile(this EntityComponent entityComponent,
|
||||
EnemyProjectileData data,
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return entityComponent.ShowProjectileAsync(data, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步显示投射物实体(直接入参快捷方法)。
|
||||
/// </summary>
|
||||
public static UniTask<EnemyProjectile> ShowProjectile(this EntityComponent entityComponent,
|
||||
int ownerEntityId,
|
||||
CampType ownerCamp,
|
||||
int attackDamage,
|
||||
Vector3 position,
|
||||
Vector3 direction,
|
||||
float timeout = 30f,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return entityComponent.ShowProjectileAsync(ownerEntityId, ownerCamp, attackDamage, position, direction, timeout, cancellationToken);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步隐藏实体
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user