Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
 partial void pStartUncontrolledAni(AniJob aniJob)
 {
     if (this.vob.IsSpawned)
     {
         Messages.WriteAniStartUncontrolled(this, aniJob);
     }
 }
Ejemplo n.º 4
0
            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'));
            }
Ejemplo n.º 5
0
            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'));
            }
Ejemplo n.º 6
0
 /// <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);
 }
Ejemplo n.º 7
0
 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);
         }
     }
 }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
0
 /// <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);
 }
Ejemplo n.º 10
0
            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'));
            }
Ejemplo n.º 11
0
        /// <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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 public void RemoveAniJob(AniJob aniJob)
 {
     RemoveAniJob((ScriptAniJob)aniJob.ScriptObject);
 }
Ejemplo n.º 14
0
 public void AddAniJob(AniJob aniJob)
 {
     AddAniJob((ScriptAniJob)aniJob.ScriptObject);
 }
Ejemplo n.º 15
0
 public ScriptAniJob()
 {
     this.baseAniJob = new AniJob(this);
 }
Ejemplo n.º 16
0
 public bool TryGetAniJob(int id, out AniJob job)
 {
     return(aniIDs.TryGet(id, out job));
 }
Ejemplo n.º 17
0
 partial void pRemoveAniJob(AniJob job);
Ejemplo n.º 18
0
 partial void pAddAniJob(AniJob job);
Ejemplo n.º 19
0
 public ActiveAni StartAniJob(AniJob aniJob, float fpsMult, float progress)
 {
     return(StartAniJob((ScriptAniJob)aniJob.ScriptObject, fpsMult, progress));
 }
Ejemplo n.º 20
0
 public void StartAniJobUncontrolled(AniJob aniJob)
 {
     StartAniJobUncontrolled((ScriptAniJob)aniJob.ScriptObject);
 }
Ejemplo n.º 21
0
 partial void pStartUncontrolledAni(AniJob aniJob);