public void Action_AttackCharge(Pawn target, out Vector3 destTarget) { this.speed = speed_dash; this.solAction = SoLAction.ChargeAttacking; this.assignedTarget = target; destTarget = target.DrawPos; }
public void Action_Guard(Pawn target, out Vector3 destTarget) { this.speed = speed_walk; this.solAction = SoLAction.Guarding; this.assignedTarget = target; destTarget = target.DrawPos; }
public void Action_Clean(out Vector3 destTarget) { List <Thing> filthList = this.Map.listerFilthInHomeArea.FilthInHomeArea; Thing closestDirt = null; float dirtPos = 0; for (int i = 0; i < filthList.Count; i++) { if (closestDirt != null) { float dirtDistance = (filthList[i].DrawPos - origin).magnitude; if (dirtDistance < dirtPos) { dirtPos = dirtDistance; closestDirt = filthList[i]; } } else { closestDirt = filthList[i]; dirtPos = (filthList[i].DrawPos - origin).magnitude; } } if (closestDirt != null) { solAction = SoLAction.Cleaning; destTarget = closestDirt.DrawPos; } else { Action_Hover(out destTarget); } }
public void Action_CircleTarget(Thing target, out Vector3 destTarget) { Vector3 drawCenter = target.DrawPos; Vector3 rndDir = Vector3Utility.FromAngleFlat(Rand.Range(0, 360)); Vector3 startPos = drawCenter + (rndDir * 3f); Vector3 endPos = drawCenter + (rndDir * -3f); this.speed = speed_jog; this.solAction = SoLAction.Circling; destTarget = startPos; doublesidedVariance = 1; if (Rand.Chance(.5f)) { doublesidedVariance = -1; } List <Vector3> totalCircle = new List <Vector3>(); totalCircle.Clear(); CalculateCurvePoints(startPos, endPos, 90, 10); totalCircle.AddRange(this.curvePoints); CalculateCurvePoints(endPos, startPos, 90, 10); totalCircle.AddRange(this.curvePoints); this.curvePoints = totalCircle; this.destinationCurvePoint++; this.destination = this.curvePoints[this.destinationCurvePoint]; this.ticksToImpact = this.StartingTicksToImpact; this.delayCount = 0; this.doublesidedVariance = 0; }
public void Action_Return() { this.speed = speed_jog; this.solAction = SoLAction.Returning; CalculateCurvePoints(this.origin, GetCasterOffset_Exact, 20, 10); this.destinationCurvePoint++; this.destination = this.curvePoints[this.destinationCurvePoint]; this.ticksToImpact = this.StartingTicksToImpact; }
public void Action_Attack(Pawn target, out Vector3 destTarget) { this.speed = speed_jog; this.solAction = SoLAction.Attacking; this.assignedTarget = target; destTarget = TM_Calc.GetVectorBetween(this.origin, target.DrawPos); CalculateCurvePoints(this.origin, destTarget, 40, 10); this.destinationCurvePoint++; this.destination = this.curvePoints[this.destinationCurvePoint]; this.ticksToImpact = this.StartingTicksToImpact; this.delayCount = 0; }
public void Action_Hover(out Vector3 destTarget) { this.speed = speed_hover; this.solAction = SoLAction.Hovering; destTarget = GetCasterOffset_Rand; if ((this.origin - destTarget).magnitude > .5f) { this.speed = speed_walk; if ((this.origin - destTarget).magnitude > 25f) { Action_FromLimbo(out destTarget); } } }
public void Action_Sleeping(out Vector3 destTarget) { this.speed = speed_hover; this.solAction = SoLAction.Sleeping; this.delayCount++; if (delayCount > 10 && EnergyChance && pawn.needs.mood != null && pawn.needs.mood.thoughts != null) { this.delayCount = 0; if (pawn.needs.mood.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_PleasantDreamsTD) == null) { ActualLightCost(5f); pawn.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_PleasantDreamsTD); } if (pawn.needs.mood.thoughts.memories.GetFirstMemoryOfDef(ThoughtDefOf.SleepDisturbed) != null) { ActualLightCost(3f); pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDefOf.SleepDisturbed); } } destTarget = GetCasterOffset_Rand; }
public void UpdateAction(SoLAction withAction = SoLAction.Pending) { SoLAction inAction = this.solAction; Vector3 destTarget = this.ExactPosition; this.curveVariance = 0; //Log.Message("action for " + solAction.ToString() + " queued action: " + queuedAction.ToString()); if (queuedAction != SoLAction.Null) { solAction = queuedAction; queuedAction = SoLAction.Null; } if (solAction == SoLAction.Pending || solAction == SoLAction.Goto) { if (this.pawn.GetPosture() == PawnPosture.LayingInBed || this.pawn.CurJobDef == JobDefOf.LayDown) { if (!pawn.Awake() && LightEnergy > 5f) { Action_Sleeping(out destTarget); } //pawn injured? } else if (this.pawn.Drafted) { this.delayCount++; if (LightEnergy > 20 && EnergyChance && this.delayCount > 2) { Pawn p = TM_Calc.FindNearbyEnemy(this.pawn, (int)AttackTarget_ShortRange); if (p != null && TM_Calc.HasLoSFromTo(pawn.Position, p, pawn, 0, AttackTarget_ShortRange)) { Action_AttackCharge(p, out destTarget); queuedAction = SoLAction.Limbo; } else { if (LightEnergy > 30 && this.delayCount > 6) { p = TM_Calc.FindNearbyEnemy(this.pawn.Position, this.pawn.Map, this.pawn.Faction, AttackTarget_MaxRange, AttackTarget_ShortRange); if (p != null && TM_Calc.HasLoSFromTo(pawn.Position, p, pawn, 0, AttackTarget_MaxRange)) { Action_Attack(p, out destTarget); queuedAction = SoLAction.Returning; } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } } else { Action_Hover(out destTarget); } } else if (this.pawn.Downed && this.pawn.health.hediffSet.GetInjuriesTendable().Count() > 0 && LightEnergy > 10) { Action_GotoTarget(this.pawn.DrawPos, speed_jog, out destTarget); this.assignedTarget = this.pawn; queuedAction = SoLAction.Guarding; } else if (this.shouldGlow) { this.shouldGlow = false; Action_GotoTarget(this.glowCenter.ToVector3Shifted(), this.speed_jog, out destTarget); queuedAction = SoLAction.Glow; } else if (LightEnergy > 20 && EnergyChance) { Pawn p = TM_Calc.FindNearbyInjuredPawnOther(this.pawn, 10, 10f); this.delayCount++; if (this.delayCount > 1 && p != null && p.Downed && TM_Calc.HasLoSFromTo(this.pawn.Position, p, this.pawn, 0, 10) && p.health.hediffSet.GetInjuriesTendable().Count() > 0) { Action_GotoTarget(p.DrawPos, speed_dash, out destTarget); queuedAction = SoLAction.Guarding; this.assignedTarget = p; } else if (LightEnergy > 60 && EnergyChance) { if (this.delayCount > 2) { p = TM_Calc.FindNearbyPawn(this.pawn, 10); if (p != null && p.needs != null && TM_Calc.HasLoSFromTo(this.pawn.Position, p, this.pawn, 0, 10)) { if ((this.pawn.CurJobDef.joyKind != null || this.pawn.CurJobDef == JobDefOf.Wait_Wander || this.pawn.CurJobDef == JobDefOf.GotoWander) && this.pawn.needs.joy.CurLevelPercentage < .5f) { this.delayCount = 0; Action_JoyBurst(this.pawn.DrawPos, out destTarget); } else if (p.needs.joy != null && (p.CurJobDef.joyKind != null || p.CurJobDef == JobDefOf.Wait_Wander || p.CurJobDef == JobDefOf.GotoWander) && p.needs.joy.CurLevelPercentage < .5f) { this.delayCount = 0; Action_JoyBurst(p.DrawPos, out destTarget); } else if (this.delayCount > 3 && p.needs.mood != null && p.needs.mood.thoughts != null && p.needs.mood.thoughts.memories != null && p.needs.mood.thoughts.memories.GetFirstMemoryOfDef(TorannMagicDefOf.TM_BrightDayTD) == null) { this.delayCount = 0; Action_GotoTarget(p.DrawPos, speed_jog, out destTarget); this.assignedTarget = p; queuedAction = SoLAction.BrightenDay; //action circle target } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } //else if(LightEnergy > 90 && (EnergyChance && EnergyChance && EnergyChance)) //{ // Action_Clean(out destTarget); //} else { this.delayCount = 0; Action_Hover(out destTarget); } } else if (solAction == SoLAction.BrightenDay) { if (this.assignedTarget != null && this.assignedTarget is Pawn) { Pawn p = this.assignedTarget as Pawn; ActualLightCost(6f); p.needs.mood.thoughts.memories.TryGainMemory(TorannMagicDefOf.TM_BrightDayTD); Action_CircleTarget(this.assignedTarget, out destTarget); queuedAction = SoLAction.Returning; } } else if (solAction == SoLAction.Glow) { if (this.glowing) { StopGlow(); } else { DoGlow(); } Action_Return(); } else if (solAction == SoLAction.Returning) { Action_Return(); } else if (solAction == SoLAction.Guarding) { if (LightEnergy > 10 && this.assignedTarget != null && this.assignedTarget is Pawn) { Pawn p = this.assignedTarget as Pawn; if (p.health.hediffSet.GetInjuriesTendable().Count() > 0) { this.ticksToImpact = 300; ActualLightCost(2f); CauterizeWounds(p); queuedAction = SoLAction.Guarding; } else { Action_Hover(out destTarget); } } else { Action_Hover(out destTarget); } } else if (solAction == SoLAction.Limbo) { Action_FromLimbo(out destTarget); } if (solAction != SoLAction.Attacking && solAction != SoLAction.Returning && solAction != SoLAction.Guarding && solAction != SoLAction.Circling) { this.destination = destTarget; this.ticksToImpact = this.StartingTicksToImpact; } //Log.Message("ending update action, new action: " + solAction.ToString() + " speed: " + this.speed + " delay action: " + this.delayCount + " light energy: "+ LightEnergy); if (this.solAction != inAction && this.solAction != SoLAction.Hovering && this.solAction != SoLAction.Sleeping) { this.delayCount = 0; } }
public override void Tick() { age++; Vector3 exactPosition = this.ExactPosition; this.ticksToImpact--; if (!initialized) { Initialize(); if (this.glowing && this.glowCenter != default(IntVec3)) { this.shouldGlow = true; } } if (Find.TickManager.TicksGame % this.chargeFrequency == 0) { LightEnergy += ChargeAmount; } bool dFlag = false; if (this.pawn.DestroyedOrNull()) { dFlag = true; this.Destroy(DestroyMode.Vanish); } else if (!this.pawn.Spawned || this.pawn.Map != this.Map || this.pawn.Map == null) { solAction = SoLAction.Limbo; dFlag = true; this.delayCount++; if (delayCount >= 300) { StopGlow(); this.shouldGlow = false; this.Destroy(DestroyMode.Vanish); } if (this.delayCount == 10) { MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, 1f); MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .7f); MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .4f); } } else if (this.shouldDismiss) { if (this.glowing) { this.glowCenter = default(IntVec3); StopGlow(); this.Destroy(DestroyMode.Vanish); } } if (!dFlag) { bool flag = !this.ExactPosition.InBounds(base.Map); if (flag) { if (!this.pawn.DestroyedOrNull() && this.pawn.Spawned) { base.Position = pawn.Position; this.destination = GetCasterOffset_Exact; this.speed = speed_dash; this.ticksToImpact = this.StartingTicksToImpact; } this.ticksToImpact++; base.Position = this.ExactPosition.ToIntVec3(); } else if (this.solAction == SoLAction.Limbo) { UpdateAction(this.solAction); } else { base.Position = this.ExactPosition.ToIntVec3(); if (Find.TickManager.TicksGame % ActionDelay == 0) { DoAction(); } bool flag2 = this.ticksToImpact <= 0; if (flag2) { if (this.shouldDismiss) { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } this.ImpactSomething(); } else { UpdateSoLPower(); if (this.curveVariance > 0) { if ((this.curvePoints.Count() - 1) > this.destinationCurvePoint) { this.origin = curvePoints[destinationCurvePoint]; this.destinationCurvePoint++; this.destination = this.curvePoints[this.destinationCurvePoint]; this.ticksToImpact = this.StartingTicksToImpact; } else { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } this.origin = this.ExactPosition; solAction = SoLAction.Pending; UpdateAction(solAction); } } else { bool flag3 = this.DestinationCell.InBounds(base.Map); if (flag3) { base.Position = this.DestinationCell; } if (this.solAction == SoLAction.ChargeAttacking) { ActualLightCost(5f); int moteAngle = Mathf.RoundToInt(Vector3Utility.ToAngleFlat(this.origin - this.destination) - 90f); TM_Action.DamageEntities(this.assignedTarget, null, Rand.Range(10f, 15f) * LightPotency, TMDamageDefOf.DamageDefOf.TM_BurningLight, this.pawn); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_LightShield, this.ExactPosition, this.Map, 1.5f, .1f, 0f, .2f, 0, 2f, moteAngle, moteAngle); } this.origin = this.destination; solAction = SoLAction.Pending; UpdateAction(solAction); } } } if (this.nextMoteTick <= this.age && solAction != SoLAction.Limbo) { DrawMotes(); } } } }
public void Action_GotoTarget(Vector3 target, float speed, out Vector3 destTarget) { destTarget = target; this.speed = speed; this.solAction = SoLAction.Goto; }