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}"); } } }
public static bool AlreadyReachedMax(this InnerShineRecord ISR, int max) { if (ISR.spawned.NullOrEmpty()) { return(false); } return(ISR.spawned.Count() >= max); }
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); }
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; }
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 ); } }
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(); } } } }
public static void ResetTicks(this InnerShineItem ISI, InnerShineRecord ISR) => ISR.ticksLeft = ISI.NewPeriod();