You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
3.4 KiB
90 lines
3.4 KiB
using System.Collections.Generic;
|
|
using System.IO;
|
|
using AOT;
|
|
using CoreGame;
|
|
using CoreGame.Render;
|
|
using Entitas;
|
|
using UnityEngine.Animations;
|
|
|
|
namespace CoreGame.Render
|
|
{
|
|
public class DetachAssetSystem : ReactiveSystem<CombatEntity>
|
|
{
|
|
public DetachAssetSystem(Contexts contexts) : base(contexts.combat)
|
|
{
|
|
}
|
|
|
|
protected override ICollector<CombatEntity> GetTrigger(IContext<CombatEntity> context)
|
|
{
|
|
return context.CreateCollector(CombatMatcher.DetachAsset);
|
|
}
|
|
|
|
protected override bool Filter(CombatEntity entity)
|
|
{
|
|
return entity.hasAsset;
|
|
}
|
|
|
|
private void DetachHand(BindPointProxy parentBp, int b1)
|
|
{
|
|
if (parentBp.GetBindPointMap().TryGetValue(b1, out var bp2))
|
|
{
|
|
if (bp2.gameObject.TryGetComponent<PositionConstraint>(out var positionConstraint))
|
|
{
|
|
positionConstraint.constraintActive = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void Execute(List<CombatEntity> entities)
|
|
{
|
|
for (var index = 0; index < entities.Count; index++)
|
|
{
|
|
var e = entities[index];
|
|
var detachAssetComponent = e.detachAsset;
|
|
e.RemoveDetachAsset();
|
|
|
|
var reuseGoData = e.asset.mainAssetParam.reuseGoData;
|
|
if (reuseGoData.go)
|
|
{
|
|
reuseGoData.go.UnLink();
|
|
}
|
|
|
|
var parentParentEntity = e.parentRecorder.ParentEntity;
|
|
var assetComponent = parentParentEntity.asset;
|
|
if (assetComponent != null)
|
|
{
|
|
assetComponent.UnRecordLinkEnt(e.creationIndex);
|
|
}
|
|
parentParentEntity.bindPointProxy.DetachFallbackBindPoint(e.bindPointProxy.GetBindPointMap());
|
|
DetachHand(parentParentEntity.bindPointProxy, (int)BindPointType.LHand);
|
|
DetachHand(parentParentEntity.bindPointProxy, (int)BindPointType.RHand);
|
|
|
|
GunSrv.DestoryCircleVfx(parentParentEntity, e);
|
|
|
|
|
|
|
|
// 如果有动画,也要挂载进去
|
|
var parentEntityAnimationProxy = parentParentEntity.animationProxy;
|
|
if (parentEntityAnimationProxy != null && assetComponent != null)
|
|
{
|
|
var subAssetData = SptPool<SubAssetData>.Malloc();
|
|
subAssetData.reuseGoData = reuseGoData;
|
|
var path = assetComponent.mainAssetParam.path;
|
|
var fileName = Path.GetFileName(path);
|
|
if (path != null)
|
|
{
|
|
var skinParam = new SkinParam
|
|
{
|
|
bpType = detachAssetComponent.bindPointType,
|
|
path = UnrealNames.GetFName(path.Substring(0, path.Length - fileName.Length - 1)),
|
|
animPrefix = UnrealNames.GetFName(fileName.Substring(0, fileName.LastIndexOf('.')))
|
|
};
|
|
parentEntityAnimationProxy.PopPartAnimancer(subAssetData, skinParam);
|
|
}
|
|
subAssetData.reuseGoData = null;
|
|
SptPool<SubAssetData>.Free(ref subAssetData);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|