partial void pStartAnimation(ActiveAni aa, float fpsMult, float progress) { if (this.vob is NPC) { var gVob = ((NPC)vob).gVob; if (gVob != null) { gVob.AniCtrl.StopTurnAnis(); var gModel = gVob.GetModel(); int aniID = gModel.GetAniIDFromAniName(aa.AniJob.Name); if (aniID > 0) { var gAni = gModel.GetAniFromAniID(aniID); if (gAni.Address != 0) { gModel.StartAni(gAni, 0); var activeAni = gModel.GetActiveAni(gAni); if (activeAni.Address != 0) { if (!gAni.IsReversed) { activeAni.SetActFrame(aa.Ani.StartFrame + aa.Ani.GetFrameNum() * progress); } else { activeAni.SetActFrame(gAni.NumFrames - (aa.Ani.StartFrame + aa.Ani.GetFrameNum() * progress)); } } } } } } }
/// <summary> /// Starts the given Animation with the given frame speed multiplier value and calls onStop at the end of the animation. /// Returns false if the Animation can't be played (f.e not the right overlays applied). /// </summary> public ActiveAni StartAniJob(AniJob aniJob, float fpsMult, float progress, FrameActionPair[] pairs) { ActiveAni aa = PlayAni(aniJob, fpsMult, progress, pairs); pStartAnimation(aa, fpsMult, progress); return(aa); }
partial void pStopAnimation(ActiveAni aa, bool fadeOut) { if (this.vob.IsSpawned) { Messages.WriteAniStop(this, aa.AniJob, fadeOut); } }
partial void pStartAnimation(ActiveAni aa, float fpsMult, float progress) { if (this.vob.IsSpawned) { Messages.WriteAniStart(this, aa.AniJob, fpsMult, progress); } }
ActiveAni PlayAni(AniJob aniJob, float fpsMult, float progress, FrameActionPair[] pairs) { if (aniJob == null) { throw new ArgumentNullException("AniJob is null!"); } if (aniJob.ModelInstance != this.Instance) { throw new ArgumentException("AniJob is not for this Model!"); } if (fpsMult <= 0) { throw new ArgumentException("Frame speed multiplier has to be greater than zero!"); } if (!this.TryGetAniFromJob(aniJob, out Animation ani)) { return(null); } // search a free ActiveAni ActiveAni aa = null; for (int i = 0; i < activeAnis.Count; i++) { if (activeAnis[i].Ani == null) // this ActiveAni is unused { aa = activeAnis[i]; // continue to search, maybe there's an active ani with the same layer } else if (activeAnis[i].AniJob.Layer == aniJob.Layer) // same layer, stop this animation { aa = activeAnis[i]; aa.Stop(); // stop this animation break; } } if (aa == null) // no free ActiveAni, create a new one { aa = new ActiveAni(this); activeAnis.Add(aa); } aa.Start(ani, fpsMult, progress, pairs); return(aa); }
public static void ReadAniStop(PacketReader stream, bool fadeOut) { if (World.Current.TryGetVob(stream.ReadUShort(), out Vob vob)) { Model model = vob.Model; if (model.Instance.TryGetAniJob(stream.ReadUShort(), out AniJob job)) { ActiveAni aa = model.GetActiveAniFromAniJob(job); if (aa != null) { model.ScriptObject.StopAnimation(aa, fadeOut); } } } }
public void StopAnimation(ActiveAni ani, bool fadeOut = false) { if (ani == null) { throw new ArgumentNullException("ActiveAni is null!"); } if (ani.Ani == null) { return; } if (ani.Model != this) { throw new ArgumentException("ActiveAni is not from this Model!"); } pStopAnimation(ani, fadeOut); ani.Stop(); }
partial void pStopAnimation(ActiveAni aa, bool fadeOut) { if (this.vob is NPC) { var gVob = ((NPC)vob).gVob; if (gVob != null) { var gModel = gVob.GetModel(); int id = gModel.GetAniIDFromAniName(aa.AniJob.Name); var activeAni = gModel.GetActiveAni(id); if (fadeOut) { gModel.StopAni(activeAni); } else { gModel.FadeOutAni(activeAni); } } } }
public void StopAnimation(ActiveAni ani, bool fadeOut) { this.BaseInst.StopAnimation(ani, fadeOut); }
partial void pStopAnimation(ActiveAni aa, bool fadeOut);
partial void pStartAnimation(ActiveAni aa, float fpsMult, float progress);