Ejemplo n.º 1
0
        public static void UpdateMotes(this InnerShineItem ISI, InnerShineRecord ISR, Pawn pawn, bool debug = false)
        {
            if (ISR.spawned.NullOrEmpty())
            {
                return;
            }
            for (int i = ISR.spawned.Count - 1; i >= 0; i--)
            {
                Thing curT = ISR.spawned[i];

                if (curT.DestroyedOrNull())
                {
                    ISR.spawned.RemoveAt(i);
                    continue;
                }
                if (!ISI.HasCompatibleActivity(pawn))
                {
                    curT.Destroy();
                    ISR.spawned.RemoveAt(i);
                    continue;
                }
                if (curT is Mote mote)
                {
                    mote.exactPosition = pawn.DrawPos + pawn.GetLinkOffset(ISI.linkType) + ISI.GetDrawOffset(pawn);
                    //if (debug) Log.Warning(ISR.label + $" => mote.exactPosition: {mote.exactPosition} mote.DrawPos:{mote.DrawPos}");
                }
            }
        }
Ejemplo n.º 2
0
        public static bool AlreadyReachedMax(this InnerShineRecord ISR, int max)
        {
            if (ISR.spawned.NullOrEmpty())
            {
                return(false);
            }

            return(ISR.spawned.Count() >= max);
        }
Ejemplo n.º 3
0
        public static bool ShouldSpawnMote(this InnerShineItem ISI, InnerShineRecord ISR, Pawn p)
        {
            if (!ISI.HasCompatibleActivity(p))
            {
                return(false);
            }

            if (ISI.HasMoteNumLimit())
            {
                return(!ISR.AlreadyReachedMax(ISI.spawningRules.spawnedMax));
            }

            return(true);
        }
Ejemplo n.º 4
0
        public static void ChangeMoteColor(this InnerShineItem ISI, InnerShineRecord ISR, Mote mote)
        {
            if (!ISI.HasColorRange || mote == null)
            {
                return;
            }

            if (ISR.lastColor == Color.black)
            {
                ISR.lastColor = ISI.colorRange.colorA;
            }

            ISR.lastColor = ISI.colorRange.RandomPickColor(ISR.lastColor, ISI.debug);

            mote.instanceColor = ISR.lastColor;
        }
Ejemplo n.º 5
0
        public static void InitSpecs(this InnerShineItem ISI, InnerShineRecord ISR, Pawn pawn, out Vector3 drawPosWithOffset, out float scale)
        {
            Vector3 drawPos = pawn.DrawPos;

            ISI.GetSpecifities(pawn, out Vector3 bodyTypeOffset, out scale);
            Vector3 linkOffset = pawn.GetLinkOffset(ISI.linkType);

            drawPosWithOffset = drawPos + linkOffset + bodyTypeOffset;

            if (ISI.debug)
            {
                Log.Warning(
                    pawn.ThingID + " " + ISI.label + " TryPlaceMote - " +
                    "drawPos: " + drawPos + " linkOffset:" + linkOffset + " bodyTypeOffset:" + bodyTypeOffset +
                    "scale: " + scale
                    );
            }
        }
Ejemplo n.º 6
0
        public static void TryPlaceMote(this InnerShineItem ISI, InnerShineRecord ISR, Pawn pawn)
        {
            //if (!HasShinePool)return;
            //Thing result = null;

            // wont exit because we want to record lastFootPos + use old value before recording it
            if (pawn.Position.InBounds(pawn.Map))
            {
                float rot = 0;
                ISI.InitSpecs(ISR, pawn, out Vector3 drawPosWithOffset, out float scale);

                if (drawPosWithOffset.ToIntVec3().InBounds(pawn.Map))
                {
                    ThingDef moteDef = ISI.motePool.RandomElementWithFallback();

                    if (drawPosWithOffset.TryAnyMoteSpawn(pawn.Map, rot, scale, moteDef, ISI.debug) is Mote mote)
                    {
                        ISI.ChangeMoteColor(ISR, mote);
                        ISR.spawned.Add(mote);
                        ISI.NewPeriod();
                    }
                }
            }
        }
Ejemplo n.º 7
0
 public static void ResetTicks(this InnerShineItem ISI, InnerShineRecord ISR) => ISR.ticksLeft = ISI.NewPeriod();