示例#1
0
        public static Graphic ResolveCycledGraphic(ThingWithComps pAnimatee, CompProperties_Animated pProps, int pCurIndex)
        {
            Graphic result           = null;
            var     haveMovingFrames = !pProps.movingFrames.NullOrEmpty();

            if (haveMovingFrames &&
                pAnimatee is Pawn pPawn &&
                pPawn.Drawer?.renderer?.graphics is PawnGraphicSet pawnGraphicSet)
            {
                // Start Pawn
                pawnGraphicSet.ClearCache();

                if (pPawn.pather?.MovingNow ?? false)
                {
                    result = pProps.movingFrames[pCurIndex].Graphic;
                    pawnGraphicSet.nakedGraphic = result;
                }
                else if (!pProps.stillFrames.NullOrEmpty())
                {
                    result = pProps.stillFrames[pCurIndex].Graphic;
                    pawnGraphicSet.nakedGraphic = result;
                }
                else
                {
                    result = pProps.movingFrames[pCurIndex].Graphic;
                }
            }
示例#2
0
        public static Graphic ResolveCycledGraphic(Pawn pAnimatee, CompProperties_Animated pProps, int pCurIndex)
        {
            Graphic result = null;

            if (!pProps.movingFrames.NullOrEmpty() &&
                pAnimatee.Drawer?.renderer?.graphics is PawnGraphicSet pawnGraphicSet)
            {
                pawnGraphicSet.ClearCache();
                if (pAnimatee.pather != null && pAnimatee.pather.MovingNow)
                {
                    result = pProps.movingFrames[pCurIndex].Graphic;
                    pawnGraphicSet.nakedGraphic = result;
                }
                else if (!pProps.stillFrames.NullOrEmpty())
                {
                    result = pProps.stillFrames[pCurIndex].Graphic;
                    pawnGraphicSet.nakedGraphic = result;
                }
                else
                {
                    result = pProps.movingFrames[pCurIndex].Graphic;
                }
            }
            return(result);
        }
示例#3
0
        public static Graphic ResolveCurGraphic(ThingWithComps pThingWithComps, CompProperties_Animated pProps, ref Graphic result,
                                                ref int pCurIndex, ref int pTicksToCycle, ref bool pDirty, bool useBaseGraphic = true)
        {
            if (pProps.secondsBetweenFrames <= 0.0f)
            {
                Log.ErrorOnce("CompAnimated :: CompProperties_Animated secondsBetweenFrames needs to be more than 0",
                              132);
            }

            if (pThingWithComps != null && pProps.secondsBetweenFrames > 0.0f && Find.TickManager.TicksGame > pTicksToCycle)
            {
                pTicksToCycle = Find.TickManager.TicksGame + pProps.secondsBetweenFrames.SecondsToTicks();

                bool asPawn = AsPawn(pThingWithComps, out var pAnimatee);
                if (asPawn && (pAnimatee?.pather?.MovingNow ?? false))
                {
                    pCurIndex = (pCurIndex + 1) % pProps.movingFrames.Count();
                    if (pProps.sound != null)
                    {
                        pProps.sound.PlayOneShot(SoundInfo.InMap(pAnimatee));
                    }
                    result = ResolveCycledGraphic(pAnimatee, pProps, pCurIndex);
                }
                else
                {
                    if (!pProps.stillFrames.NullOrEmpty())
                    {
                        Log.Message("ticked still");
                        pCurIndex = (pCurIndex + 1) % pProps.stillFrames.Count();
                        result    = ResolveCycledGraphic(pThingWithComps, pProps, pCurIndex);
                        pDirty    = false;
                        return(result);
                    }
                    if (pAnimatee != null && useBaseGraphic)
                    {
                        result = ResolveBaseGraphic(pAnimatee);
                    }
                    else
                    {
                        result = ResolveCycledGraphic(pThingWithComps, pProps, pCurIndex);
                    }
                }
            }
            pDirty = false;
            return(result);
        }
        public static Graphic ResolveCycledGraphic(ThingWithComps pAnimatee, CompProperties_Animated pProps, int pCurIndex)
        {
            Graphic result           = null;
            bool    haveMovingFrames = !pProps.movingFrames.NullOrEmpty();

            if (!pProps.movingFrames.NullOrEmpty() &&
                AsPawn(pAnimatee, out var pPawn) &&
                pPawn.Drawer?.renderer?.graphics is PawnGraphicSet pawnGraphicSet)
            {
                /*Start Pawn*/
                pawnGraphicSet.ClearCache();

                if (haveMovingFrames && AsPawn(pAnimatee, out var p) && (p?.pather?.MovingNow ?? false))
                {
                    result = pProps.movingFrames[pCurIndex].Graphic;
                    pawnGraphicSet.nakedGraphic = result;
                }
                else if (!pProps.stillFrames.NullOrEmpty())
                {
                    result = pProps.stillFrames[pCurIndex].Graphic;
                    pawnGraphicSet.nakedGraphic = result;
                }
                else if (haveMovingFrames)
                {
                    result = pProps.movingFrames[pCurIndex].Graphic;
                }
            } /*Start Non Pawn*/
            else if (!pProps.stillFrames.NullOrEmpty())
            {
                result = pProps.stillFrames[pCurIndex].Graphic;
            }
            else if (haveMovingFrames)
            {
                result = pProps.movingFrames[pCurIndex].Graphic;
            }

            return(result);
        }
示例#5
0
 public static Graphic ResolveCurGraphic(Pawn pawn, CompProperties_Animated pProps, ref Graphic result,
                                         ref int pCurIndex, ref int pTicksToCycle, ref bool pDirty, bool useBaseGraphic = true)
 {
     return(ResolveCurGraphic(pawn as ThingWithComps, pProps, ref result, ref pCurIndex, ref pTicksToCycle, ref pDirty, useBaseGraphic));
 }
示例#6
0
 public static Graphic ResolveCycledGraphic(Pawn pAnimatee, CompProperties_Animated pProps, int pCurIndex)
 {
     return(ResolveCycledGraphic(pAnimatee as ThingWithComps, pProps, pCurIndex));
 }