protected void MakeMote(TargetInfo A) { Vector3 vector = (A.HasThing ? A.Thing.DrawPos : A.Cell.ToVector3Shifted()); if (!vector.ShouldSpawnMotesAt(A.Map)) { return; } int randomInRange = def.burstCount.RandomInRange; for (int i = 0; i < randomInRange; i++) { Mote mote = (Mote)ThingMaker.MakeThing(def.moteDef); mote.Scale = def.scale.RandomInRange; mote.exactPosition = vector + def.positionOffset + Gen.RandomHorizontalVector(def.positionRadius); mote.rotationRate = def.rotationRate.RandomInRange; mote.exactRotation = def.rotation.RandomInRange; MoteThrown moteThrown = mote as MoteThrown; if (moteThrown != null) { moteThrown.airTimeLeft = def.airTime.RandomInRange; moteThrown.SetVelocity(def.angle.RandomInRange, def.speed.RandomInRange); } if (A.HasThing) { mote.Attach(A); } GenSpawn.Spawn(mote, vector.ToIntVec3(), A.Map); } }
public override void SubEffectTick(TargetInfo A, TargetInfo B) { if (this.interactMote == null) { this.interactMote = MoteMaker.MakeInteractionOverlay(this.def.moteDef, A, B); } }
public void DrawMoteInternal(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, int layer) { Mote mote = (Mote)thing; float alpha = mote.Alpha; if (alpha <= 0f) { return; } Color color = base.Color * mote.instanceColor; color.a *= alpha; Vector3 exactScale = mote.exactScale; exactScale.x *= this.data.drawSize.x; exactScale.z *= this.data.drawSize.y; Matrix4x4 matrix = default(Matrix4x4); matrix.SetTRS(mote.DrawPos, Quaternion.AngleAxis(mote.exactRotation, Vector3.up), exactScale); Material matSingle = this.MatSingle; if (!this.ForcePropertyBlock && color.IndistinguishableFrom(matSingle.color)) { Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, layer, null, 0); } else { Graphic_Mote.propertyBlock.SetColor(ShaderPropertyIDs.Color, color); Graphics.DrawMesh(MeshPool.plane10, matrix, matSingle, layer, null, 0, Graphic_Mote.propertyBlock); } }
public static float CalculateMoteAlpha(Mote mote) { ThingDef def = mote.def; float ageSecs = mote.AgeSecs; if (ageSecs <= def.mote.fadeInTime) { if (def.mote.fadeInTime > 0f) { return(ageSecs / def.mote.fadeInTime); } return(1f); } else { if (ageSecs <= def.mote.fadeInTime + def.mote.solidTime) { return(1f); } if (def.mote.fadeOutTime > 0f) { return(1f - Mathf.InverseLerp(def.mote.fadeInTime + def.mote.solidTime, def.mote.fadeInTime + def.mote.solidTime + def.mote.fadeOutTime, ageSecs)); } return(1f); } }
protected void MakeMote(TargetInfo A) { Vector3 vector = (!A.HasThing) ? A.Cell.ToVector3Shifted() : A.Thing.DrawPos; if (vector.ShouldSpawnMotesAt(A.Map)) { int randomInRange = this.def.burstCount.RandomInRange; for (int i = 0; i < randomInRange; i++) { Mote mote = (Mote)ThingMaker.MakeThing(this.def.moteDef, null); mote.Scale = this.def.scale.RandomInRange; mote.exactPosition = vector + Gen.RandomHorizontalVector(this.def.positionRadius); mote.rotationRate = this.def.rotationRate.RandomInRange; mote.exactRotation = this.def.rotation.RandomInRange; MoteThrown moteThrown = mote as MoteThrown; if (moteThrown != null) { moteThrown.airTimeLeft = this.def.airTime.RandomInRange; moteThrown.SetVelocity(this.def.angle.RandomInRange, this.def.speed.RandomInRange); } if (A.HasThing) { mote.Attach(A); } GenSpawn.Spawn(mote, vector.ToIntVec3(), A.Map, WipeMode.Vanish); } } }
protected void MakeMote(TargetInfo A, TargetInfo B) { Vector3 vector = Vector3.zero; switch (def.spawnLocType) { case MoteSpawnLocType.OnSource: vector = A.CenterVector3; break; case MoteSpawnLocType.BetweenPositions: { Vector3 vector2 = (!A.HasThing) ? A.Cell.ToVector3Shifted() : A.Thing.DrawPos; Vector3 vector3 = (!B.HasThing) ? B.Cell.ToVector3Shifted() : B.Thing.DrawPos; vector = ((A.HasThing && !A.Thing.Spawned) ? vector3 : ((!B.HasThing || B.Thing.Spawned) ? (vector2 * def.positionLerpFactor + vector3 * (1f - def.positionLerpFactor)) : vector2)); break; } case MoteSpawnLocType.RandomCellOnTarget: vector = ((!B.HasThing) ? CellRect.CenteredOn(B.Cell, 0) : B.Thing.OccupiedRect()).RandomCell.ToVector3Shifted(); break; case MoteSpawnLocType.BetweenTouchingCells: vector = A.Cell.ToVector3Shifted() + (B.Cell - A.Cell).ToVector3().normalized * 0.5f; break; } if (parent != null) { Rand.PushState(parent.GetHashCode()); if (A.CenterVector3 != B.CenterVector3) { vector += (B.CenterVector3 - A.CenterVector3).normalized * parent.def.offsetTowardsTarget.RandomInRange; } vector += Gen.RandomHorizontalVector(parent.def.positionRadius); Rand.PopState(); } Map map = A.Map ?? B.Map; float num = (!def.absoluteAngle) ? (B.Cell - A.Cell).AngleFlat : 0f; if (map != null && vector.ShouldSpawnMotesAt(map)) { int randomInRange = def.burstCount.RandomInRange; for (int i = 0; i < randomInRange; i++) { Mote mote = (Mote)ThingMaker.MakeThing(def.moteDef); GenSpawn.Spawn(mote, vector.ToIntVec3(), map); mote.Scale = def.scale.RandomInRange; mote.exactPosition = vector + Gen.RandomHorizontalVector(def.positionRadius); mote.rotationRate = def.rotationRate.RandomInRange; mote.exactRotation = def.rotation.RandomInRange + num; MoteThrown moteThrown = mote as MoteThrown; if (moteThrown != null) { moteThrown.airTimeLeft = def.airTime.RandomInRange; moteThrown.SetVelocity(def.angle.RandomInRange + num, def.speed.RandomInRange); } } } }
public override void DrawWorker(Vector3 loc, Rot4 rot, ThingDef thingDef, Thing thing, float extraRotation) { Mote mote = (Mote)thing; Graphic_Mote.propertyBlock.SetColor(ShaderPropertyIDs.Color, color); Graphic_Mote.propertyBlock.SetFloat(ShaderPropertyIDs.AgeSecs, mote.AgeSecs); DrawMoteInternal(loc, rot, thingDef, thing, 0); }
protected void MakeMote(TargetInfo A, TargetInfo B) { Vector3 vector = Vector3.zero; switch (base.def.spawnLocType) { case MoteSpawnLocType.OnSource: vector = A.Cell.ToVector3Shifted(); break; case MoteSpawnLocType.BetweenPositions: { Vector3 vector2 = (!A.HasThing) ? A.Cell.ToVector3Shifted() : A.Thing.DrawPos; Vector3 vector3 = (!B.HasThing) ? B.Cell.ToVector3Shifted() : B.Thing.DrawPos; vector = ((!A.HasThing || A.Thing.Spawned) ? ((!B.HasThing || B.Thing.Spawned) ? (vector2 * base.def.positionLerpFactor + vector3 * (float)(1.0 - base.def.positionLerpFactor)) : vector2) : vector3); break; } case MoteSpawnLocType.RandomCellOnTarget: vector = ((!B.HasThing) ? CellRect.CenteredOn(B.Cell, 0) : B.Thing.OccupiedRect()).RandomCell.ToVector3Shifted(); break; case MoteSpawnLocType.BetweenTouchingCells: vector = A.Cell.ToVector3Shifted() + (B.Cell - A.Cell).ToVector3().normalized * 0.5f; break; } Map map = A.Map ?? B.Map; if (map != null && vector.ShouldSpawnMotesAt(map)) { int randomInRange = base.def.burstCount.RandomInRange; for (int i = 0; i < randomInRange; i++) { Mote mote = (Mote)ThingMaker.MakeThing(base.def.moteDef, null); GenSpawn.Spawn(mote, vector.ToIntVec3(), map); mote.Scale = base.def.scale.RandomInRange; mote.exactPosition = vector + Gen.RandomHorizontalVector(base.def.positionRadius); mote.rotationRate = base.def.rotationRate.RandomInRange; float num = (float)((!base.def.absoluteAngle) ? (B.Cell - A.Cell).AngleFlat : 0.0); mote.exactRotation = base.def.rotation.RandomInRange + num; MoteThrown moteThrown = mote as MoteThrown; if (moteThrown != null) { moteThrown.airTimeLeft = base.def.airTime.RandomInRange; moteThrown.SetVelocity(base.def.angle.RandomInRange + num, base.def.speed.RandomInRange); } } } }
public void MoteDespawned(Mote oldMote) { this.allMotes.Remove(oldMote); }
public void MoteSpawned(Mote newMote) { this.allMotes.Add(newMote); }
public virtual void ExplosionAffectCell(Explosion explosion, IntVec3 c, List <Thing> damagedThings, List <Thing> ignoredThings, bool canThrowMotes) { if (def.explosionCellMote != null && canThrowMotes) { Mote mote = c.GetFirstThing(explosion.Map, def.explosionCellMote) as Mote; if (mote != null) { mote.spawnTick = Find.TickManager.TicksGame; } else { float t = Mathf.Clamp01((explosion.Position - c).LengthHorizontal / explosion.radius); Color color = Color.Lerp(def.explosionColorCenter, def.explosionColorEdge, t); MoteMaker.ThrowExplosionCell(c, explosion.Map, def.explosionCellMote, color); } } thingsToAffect.Clear(); float num = float.MinValue; bool flag = false; List <Thing> list = explosion.Map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing thing = list[i]; if (thing.def.category != ThingCategory.Mote && thing.def.category != ThingCategory.Ethereal) { thingsToAffect.Add(thing); if (thing.def.Fillage == FillCategory.Full && thing.def.Altitude > num) { flag = true; num = thing.def.Altitude; } } } for (int j = 0; j < thingsToAffect.Count; j++) { if (thingsToAffect[j].def.Altitude >= num) { ExplosionDamageThing(explosion, thingsToAffect[j], damagedThings, ignoredThings, c); } } if (!flag) { ExplosionDamageTerrain(explosion, c); } if (def.explosionSnowMeltAmount > 0.0001f) { float lengthHorizontal = (c - explosion.Position).LengthHorizontal; float num2 = 1f - lengthHorizontal / explosion.radius; if (num2 > 0f) { explosion.Map.snowGrid.AddDepth(c, (0f - num2) * def.explosionSnowMeltAmount); } } if (def != DamageDefOf.Bomb && def != DamageDefOf.Flame) { return; } List <Thing> list2 = explosion.Map.listerThings.ThingsOfDef(ThingDefOf.RectTrigger); for (int k = 0; k < list2.Count; k++) { RectTrigger rectTrigger = (RectTrigger)list2[k]; if (rectTrigger.activateOnExplosion && rectTrigger.Rect.Contains(c)) { rectTrigger.ActivatedBy(null); } } }