/// <summary> Adds an AniJob to this Model. </summary> public void AddAniJob(AniJob job) { if (job == null) { throw new ArgumentNullException("AniJob is null!"); } if (job.IsCreated) { throw new ArgumentException("AniJob is already added to another Model!"); } if (job.NextAni != null && job.NextAni.ModelInstance != this) { throw new ArgumentException("AniJob's NextAni is for a different Model!"); } CanChangeNow(); aniIDs.Add(job); aniJobs.Add(job, ref job.collID); dynJobs.Add(job, ref job.dynID); pAddAniJob(job); job.SetModel(this); }
/// <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 pStartUncontrolledAni(AniJob aniJob) { if (this.vob.IsSpawned) { Messages.WriteAniStartUncontrolled(this, aniJob); } }
public static void WriteAniStartUncontrolled(Model model, AniJob job) { PacketWriter stream = stream = GameServer.SetupStream(ServerMessages.ModelAniUncontrolledMessage); stream.Write((ushort)model.vob.ID); stream.Write((ushort)job.ID); model.vob.ForEachVisibleClient(c => c.Send(stream, NetPriority.High, NetReliability.ReliableOrdered, 'W')); }
public static void WriteAniStop(Model model, AniJob job, bool fadeout) { PacketWriter stream = GameServer.SetupStream(fadeout ? ServerMessages.ModelAniFadeMessage : ServerMessages.ModelAniStopMessage); stream.Write((ushort)model.vob.ID); stream.Write((ushort)job.ID); model.vob.ForEachVisibleClient(c => c.Send(stream, NetPriority.High, NetReliability.ReliableOrdered, 'W')); }
/// <summary> Returns an ActiveAni-Object or null of the given AniJob. </summary> public ActiveAni GetActiveAniFromAniJob(AniJob aniJob) { for (int i = 0; i < activeAnis.Count; i++) { if (activeAnis[i].Ani != null && activeAnis[i].Ani.AniJob == aniJob) { return(activeAnis[i]); } } return(null); }
partial void pStartUncontrolledAni(AniJob aniJob) { if (this.vob is NPC) { var gVob = ((NPC)vob).gVob; if (gVob != null) { gVob.AniCtrl.StopTurnAnis(); gVob.GetModel().StartAni(aniJob.Name, 0); } } }
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); }
/// <summary> Checks this Vob's applied Overlays and returns the right Animation or null for the specified AniJob. </summary> public bool TryGetAniFromJob(AniJob job, out Animation ani) { if (overlays != null) { for (int i = 0; i < overlays.Count; i++) { if (job.TryGetOverlayAni(overlays[i], out ani)) { return(true); } } } ani = job.DefaultAni; return(ani != null); }
public static void WriteAniStart(Model model, AniJob job, float fpsMult, float progress) { PacketWriter stream; if (fpsMult == 1.0f) { stream = GameServer.SetupStream(ServerMessages.ModelAniStartMessage); } else { stream = GameServer.SetupStream(ServerMessages.ModelAniStartFPSMessage); stream.Write(fpsMult); } stream.Write(progress); stream.Write((ushort)model.vob.ID); stream.Write((ushort)job.ID); model.vob.ForEachVisibleClient(c => c.Send(stream, NetPriority.High, NetReliability.ReliableOrdered, 'W')); }
/// <summary> /// Starts the AniJob without controlling the process. I.e. it can be interrupted by Gothic (f.e. falling). /// </summary> public void StartUncontrolledAni(AniJob aniJob) { if (!this.vob.IsSpawned) { throw new Exception("Vob is not spawned!"); } if (aniJob == null) { throw new ArgumentNullException("AniJob is null!"); } if (aniJob.ModelInstance != this.Instance) { throw new ArgumentException("AniJob is not for this Model!"); } pStartUncontrolledAni(aniJob); }
public void RemoveAniJob(AniJob job) { if (job == null) { throw new ArgumentNullException("AniJob is null!"); } if (job.ModelInstance != this) { throw new Exception("AniJob is not from this Model!"); } CanChangeNow(); job.SetModel(null); aniIDs.Remove(job); aniJobs.Remove(ref job.collID); dynJobs.Remove(ref job.dynID); pRemoveAniJob(job); }
public void RemoveAniJob(AniJob aniJob) { RemoveAniJob((ScriptAniJob)aniJob.ScriptObject); }
public void AddAniJob(AniJob aniJob) { AddAniJob((ScriptAniJob)aniJob.ScriptObject); }
public ScriptAniJob() { this.baseAniJob = new AniJob(this); }
public bool TryGetAniJob(int id, out AniJob job) { return(aniIDs.TryGet(id, out job)); }
partial void pRemoveAniJob(AniJob job);
partial void pAddAniJob(AniJob job);
public ActiveAni StartAniJob(AniJob aniJob, float fpsMult, float progress) { return(StartAniJob((ScriptAniJob)aniJob.ScriptObject, fpsMult, progress)); }
public void StartAniJobUncontrolled(AniJob aniJob) { StartAniJobUncontrolled((ScriptAniJob)aniJob.ScriptObject); }
partial void pStartUncontrolledAni(AniJob aniJob);