예제 #1
0
        // This version of GetSprite uses a callstack to check if it isn't going into an endless loop
        private FrameInfo GetSprite(int index, HashSet <StateStructure> prevstates)
        {
            // If we have sprite of our own, see if we can return this index
            if (index < sprites.Count)
            {
                return(sprites[index]);
            }

            // Otherwise, continue searching where goto tells us to go
            if (gotostate != null)
            {
                // Find the class
                ActorStructure a = parser.GetArchivedActorByName(gotostate.ClassName);
                if (a != null)
                {
                    StateStructure s = a.GetState(gotostate.StateName);
                    if ((s != null) && !prevstates.Contains(s))
                    {
                        prevstates.Add(this);
                        return(s.GetSprite(gotostate.SpriteOffset, prevstates));
                    }
                }
            }

            // If there is no goto keyword used, just give us one of our sprites if we can
            if (sprites.Count > 0)
            {
                // The following behavior should really depend on the flow control keyword (loop or stop) but who cares.
                return(sprites[0]);
            }

            return(new FrameInfo());
        }
예제 #2
0
 /// <summary>
 /// This returns a specific state, or null when the state can't be found.
 /// </summary>
 public StateStructure GetState(string statename)
 {
     if (states.ContainsKey(statename))
     {
         return(states[statename]);
     }
     if (!skipsuper && (baseclass != null))
     {
         return(baseclass.GetState(statename));
     }
     return(null);
 }
예제 #3
0
        /// <summary>
        /// This returns a specific state, or null when the state can't be found.
        /// </summary>
        public StateStructure GetState(string statename)
        {
            // [ZZ] we should NOT pick up any states from Actor. (except Spawn, as the very default state)
            //      for the greater good. (otherwise POL5 from GenericCrush is displayed for actors without frames, preferred before TNT1)
            if (classname.ToLowerInvariant() == "actor" && statename.ToLowerInvariant() != "spawn")
            {
                return(null);
            }

            if (states.ContainsKey(statename))
            {
                return(states[statename]);
            }
            if (!skipsuper && (baseclass != null))
            {
                return(baseclass.GetState(statename));
            }
            return(null);
        }