using System; using System.Collections; using System.Collections.Generic; using CombatLibrary.CombatLibrary.CombatCore; using CombatLibrary.CombatLibrary.CombatCore.CustomizeTimeLogic.FxLogic; using UnityEngine; using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface; public abstract class TimeLineEventLogicBasic : IDisposable { public TimeLineAssetSerialization timeLineAssetSerialization { get { return mTimeLineAssetSerialization; } } protected TimeLineAssetSerialization mTimeLineAssetSerialization; /// /// 是否进入 /// protected bool IsEnter; protected bool IsLeave; protected bool IsDis; public ILifeCycle castEntity { get { return _castEntity; } } public ITimeLineTriggerEntity ITimeLineTriggerEntity { get { return _timeLineTriggerEntity; } } public TriggerData extraData { get { return _extraData; } set { _extraData = value; } } /// /// 施放者(谁施放的这个效果 (EntityBasic)) /// protected ILifeCycle _castEntity; /// /// 触发者(谁触发的这个效果(skill)) /// protected ITimeLineTriggerEntity _timeLineTriggerEntity; protected BetterList currTarget; protected TriggerData _extraData; public Vector3[] customizePos { get { return _customizePos; } } protected Vector3[] _customizePos; protected TimeLineEventLogicGroupBasic _timeLineEventLogicGroup; public TimeLineEventLogicGroupBasic TimeLineEventLogicGroup { get { return _timeLineEventLogicGroup; } } public void InitEventLogic(TimeLineEventLogicGroupBasic timeLineEventLogicGroup, TimeLineAssetSerialization timeLineAssetSerialization) { mTimeLineAssetSerialization = timeLineAssetSerialization; this._timeLineEventLogicGroup = timeLineEventLogicGroup; } /// /// timeline触发后持续更新 /// /// 当前时间线从执行到现在的时间 public void TimeUpdate(float time) { if (time >= mTimeLineAssetSerialization.startTime) { if (!IsEnter) { IsEnter = true; Enter(); } } ProTimeUpdate(); if (time >= mTimeLineAssetSerialization.endTime) { if (!IsLeave) { IsLeave = true; Leave(); } } } protected void Enter() { ProEnter(); } protected void Leave() { ProLeave(); } public void Pause() { ProPause(); } protected virtual void ProPause() { } public void SetCombatInfo(ILifeCycle castEntity, ITimeLineTriggerEntity targetEntity, BetterList currTarget, TriggerData extraData, Vector3[] customizePos) { this._castEntity = castEntity; this._timeLineTriggerEntity = targetEntity; this.currTarget = currTarget; this._extraData = extraData; this._customizePos = customizePos; ProSetCombatInfo(); } ///// m ///// 关闭FXinfo,隐藏掉改info创建并在使用的特效 ///// public void BreakTimeLine() { if (currTarget != null) { currTarget.Clear(); } ProBreakTimeLine(); Dispose(); } public void Dispose() { if (IsDis) { return; } IsDis = true; if (!IsLeave && IsEnter) { IsLeave = true; Leave(); } ProDispose(); this._timeLineTriggerEntity = null; this._castEntity = null; this.currTarget = null; this._extraData = default; this._customizePos = null; } public BetterList GetSkillTarget() { if (mTimeLineAssetSerialization.targetEntityType.HasFlag(FXTargetType.Oneself)) { BetterList target = CombatListPool.Instance.Get(); target.Add(_castEntity.GetMainHotPoin(true)); return target; } else { if (currTarget != null && currTarget.Count > 0) { return FilterTargetForCombat(currTarget); } if (_timeLineTriggerEntity == null) { return new BetterList(1); } ITimeLineTargetEntity timeLineTargetEntity = _timeLineTriggerEntity as ITimeLineTargetEntity; if (timeLineTargetEntity == null) { return new BetterList(1); } currTarget = CombatListPool.Instance.Get(); ILifetCycleHitPoint[] getTarget = timeLineTargetEntity.GetTineLineTargetEntity(this); currTarget.AddRange(getTarget); getTarget = currTarget.ToArray(); if ((int)mTimeLineAssetSerialization.targetEntityType != 2) { ILifetCycleHitPoint[] point = timeLineTargetEntity.FilterTarget(this, mTimeLineAssetSerialization.targetEntityType, getTarget); currTarget.Clear(); currTarget.AddRange(point); } return FilterTargetForCombat(currTarget); } } private BetterList FilterTargetForCombat(BetterList point) { ITimeLineTargetEntity timeLineTargetEntity = _timeLineTriggerEntity as ITimeLineTargetEntity; if (timeLineTargetEntity == null) { return point; } ILifetCycleHitPoint[] lifetCycleHitPoints = timeLineTargetEntity.FilterTargetForCombat(this, mTimeLineAssetSerialization.targetEntityType, point.ToArray()); point.Clear(); point.AddRange(lifetCycleHitPoints); return point; } protected abstract void ProSetCombatInfo(); protected abstract void ProEnter(); protected abstract void ProLeave(); protected abstract void ProTimeUpdate(); protected abstract void ProBreakTimeLine(); protected virtual void ProDispose() { } }