protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return(reserveTargetA); yield return(Toils_Goto.GotoThing(building, PathEndMode.ClosestTouch)); Toil deactivatePortal = new Toil(); deactivatePortal.initAction = () => { portalBldg = TargetA.Thing as Building_TMPortal; if (portalBldg != null) { //Log.Message(" " + portalBldg.Label + " is valid at loc " + portalBldg.Position + " on map " + portalBldg.Map); //Log.Message("Portal pairing is " + portalBldg.IsPaired); } }; deactivatePortal.AddFinishAction(() => { if (portalBldg != null) { portalBldg.IsPaired = false; //Log.Message("Portal pairing is now " + portalBldg.IsPaired); } }); yield return(deactivatePortal); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return(reserveTargetA); yield return(Toils_Goto.GotoThing(building, PathEndMode.ClosestTouch)); Toil selectDestination = new Toil(); selectDestination.initAction = () => { portalBldg = TargetA.Thing as Building_TMPortal; if (portalBldg != null) { } }; selectDestination.AddFinishAction(() => { if (portalBldg != null) { StartChoosingDestination(); } }); yield return(selectDestination); }
public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { Building_TMPortal portal = t as Building_TMPortal; Building_TMArcaneCapacitor arcaneCapacitor = t as Building_TMArcaneCapacitor; Building_TM_DMP dmp = t as Building_TM_DMP; CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>(); if (comp != null && portal != null && comp.IsMagicUser && comp.Mana.CurLevelPercentage >= .7f && portal.IsPaired && portal.ArcaneEnergyCur < .7f) { if (pawn != null && pawn.RaceProps.Humanlike && pawn.workSettings.WorkIsActive(TorannMagicDefOf.TM_Magic) && pawn.health.capacities.GetLevel(TorannMagicDefOf.MagicManipulation) > 0 && pawn.IsColonist && pawn.Awake() && !pawn.Drafted && !pawn.Downed && pawn.CanReserveAndReach(portal, PathEndMode.InteractionCell, Danger.Some)) { return(true); } } if (comp != null && arcaneCapacitor != null && comp.IsMagicUser && comp.Mana.CurLevelPercentage >= .9f && arcaneCapacitor.ArcaneEnergyCur < arcaneCapacitor.TargetArcaneEnergyPct && arcaneCapacitor.CapacitorIsOn) { if (pawn != null && pawn.RaceProps.Humanlike && pawn.workSettings.WorkIsActive(TorannMagicDefOf.TM_Magic) && pawn.health.capacities.GetLevel(TorannMagicDefOf.MagicManipulation) > 0 && pawn.IsColonist && pawn.Awake() && !pawn.Drafted && !pawn.Downed && pawn.CanReserveAndReach(arcaneCapacitor, PathEndMode.InteractionCell, Danger.Some)) { return(true); } } if (comp != null && dmp != null && comp.IsMagicUser && comp.Mana.CurLevelPercentage >= .9f && dmp.ArcaneEnergyCur < dmp.TargetArcaneEnergyPct && dmp.IsOn) { if (pawn != null && pawn.RaceProps.Humanlike && pawn.workSettings.WorkIsActive(TorannMagicDefOf.TM_Magic) && pawn.health.capacities.GetLevel(TorannMagicDefOf.MagicManipulation) > 0 && pawn.IsColonist && pawn.Awake() && !pawn.Drafted && !pawn.Downed && pawn.CanReserveAndReach(dmp, PathEndMode.InteractionCell, Danger.Some)) { return(true); } } return(false); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); portalBldg = TargetA.Thing as Building_TMPortal; yield return(Toils_Reserve.Reserve(building)); Toil gotoPortal = new Toil() { initAction = () => { pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoPortal); yield return(Toils_Goto.GotoThing(building, PathEndMode.InteractionCell)); }
public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol) { Map visibleMap = Find.CurrentMap; GenDraw.DrawFieldEdges(Building_TMPortal.PortableCellsAround(center, visibleMap)); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); portalBldg = TargetA.Thing as Building_TMPortal; yield return(Toils_Reserve.Reserve(building)); Toil gotoPortal = new Toil() { initAction = () => { pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoPortal); Toil portalStockpile = new Toil(); portalStockpile.initAction = () => { foreach (IntVec3 current in portalBldg.PortableCells) { Thing stockpileThing = current.GetFirstItem(base.Map); if (stockpileThing != null) { MoteMaker.ThrowHeatGlow(stockpileThing.Position, stockpileThing.Map, 1f); MoteMaker.ThrowLightningGlow(stockpileThing.Position.ToVector3Shifted(), stockpileThing.Map, 1f); stockpileThing.DeSpawn(); GenPlace.TryPlaceThing(stockpileThing, portalBldg.PortalDestinationPosition, portalBldg.PortalDestinationMap, ThingPlaceMode.Near, null); stockpileThing.SetForbidden(true, false); stockpileThing.SetForbidden(false, false); MoteMaker.ThrowLightningGlow(stockpileThing.Position.ToVector3Shifted(), stockpileThing.Map, 1f); } List <Thing> thingList; Pawn portalAnimal = null; thingList = current.GetThingList(base.Map); int z = 0; if (thingList != null) { while (z < thingList.Count) { bool validator = thingList[z] is Pawn; if (validator) { portalAnimal = thingList[z] as Pawn; if (portalAnimal != null) { if (!portalAnimal.RaceProps.Humanlike && portalAnimal.RaceProps.Animal && portalAnimal.Faction == Faction.OfPlayer) { MoteMaker.ThrowHeatGlow(stockpileThing.Position, stockpileThing.Map, 1f); MoteMaker.ThrowLightningGlow(stockpileThing.Position.ToVector3Shifted(), stockpileThing.Map, 1f); portalAnimal.jobs.ClearQueuedJobs(); portalAnimal.DeSpawn(); GenSpawn.Spawn(portalAnimal, portalBldg.PortalDestinationPosition, portalBldg.PortalDestinationMap); MoteMaker.ThrowLightningGlow(stockpileThing.Position.ToVector3Shifted(), stockpileThing.Map, 1f); } } } z++; } } } portalBldg.ArcaneEnergyCur -= 0.1f; }; yield return(portalStockpile); }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return(reserveTargetA); comp = this.pawn.GetComp <CompAbilityUserMagic>(); portalBldg = TargetA.Thing as Building_TMPortal; arcaneCapacitor = TargetA.Thing as Building_TMArcaneCapacitor; dmp = TargetA.Thing as Building_TM_DMP; bldg = TargetA.Thing as Building; Toil gotoPortal = new Toil() { initAction = () => { //pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); if (pawn.pather != null && bldg.InteractionCell != null) { pawn.pather.StartPath(bldg.InteractionCell, PathEndMode.OnCell); } }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoPortal); Toil chargePortal = new Toil() { initAction = () => { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (comp != null && comp.Mana != null && comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } else if (bldg.def.defName == "TM_DimensionalManaPocket") { this.duration = 220; } }, tickAction = () => { if (age > (effectsAge + ticksTillEffects)) { this.effectsAge = this.age; TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); Vector3 moteDirection = TM_Calc.GetVector(this.pawn.Position, bldg.Position); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Shadow, pawn.DrawPos, pawn.Map, Rand.Range(.4f, .6f), Rand.Range(.1f, .2f), .04f, Rand.Range(.1f, .2f), 300, 5f, (Quaternion.AngleAxis(90, Vector3.up) * moteDirection).ToAngleFlat(), 0); } if (age > (chargeAge + ticksTillCharge)) { if (bldg.def.defName == "TM_Portal") { comp.Mana.CurLevel -= .01f; portalBldg.ArcaneEnergyCur += .01f; xpNum += 3; } else if (bldg.def.defName == "TM_ArcaneCapacitor") { comp.Mana.CurLevel -= .01f; arcaneCapacitor.ArcaneEnergyCur += 1f; } else if (bldg.def.defName == "TM_DimensionalManaPocket") { comp.Mana.CurLevel -= .05f; dmp.ArcaneEnergyCur += 4f; age += 4; } else { age = duration; } chargeAge = age; } age++; if (age > duration) { AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .1f) { AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .05f && bldg.def.defName == "TM_DimensionalManaPocket") { //AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (portalBldg != null && portalBldg.ArcaneEnergyCur >= 1f) { AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (arcaneCapacitor != null && arcaneCapacitor.ArcaneEnergyCur >= arcaneCapacitor.TargetArcaneEnergyPct) { //AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } if (dmp != null && dmp.ArcaneEnergyCur >= dmp.TargetArcaneEnergyPct) { //AttributeXP(comp); this.EndJobWith(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; yield return(chargePortal); }
protected override IEnumerable<Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return reserveTargetA; comp = pawn.GetComp<CompAbilityUserMagic>(); portalBldg = TargetA.Thing as Building_TMPortal; Toil gotoPortal = new Toil() { initAction = () => { pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return gotoPortal; Toil chargePortal = new Toil() { initAction = () => { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if(comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } }, tickAction = () => { if (age > (effectsAge + ticksTillEffects)) { TM_MoteMaker.ThrowCastingMote(pawn.DrawPos, pawn.Map, Rand.Range(1.2f, 2f)); TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_Shadow, pawn.DrawPos, pawn.Map, Rand.Range(.4f, .6f), Rand.Range(.1f, .2f), .04f, Rand.Range(.1f, .2f), 300, 5f, Rand.Range(-10, 10), 0); } if (age > (chargeAge + ticksTillCharge)) { comp.Mana.CurLevel -= .01f; portalBldg.ArcaneEnergyCur += .01f; chargeAge = age; } age++; if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } if (portalBldg.ArcaneEnergyCur >= 1f) { this.EndJobWith(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; yield return chargePortal; }
protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDestroyedOrNull(building); Toil reserveTargetA = Toils_Reserve.Reserve(building); yield return(reserveTargetA); comp = pawn.GetComp <CompAbilityUserMagic>(); portalBldg = TargetA.Thing as Building_TMPortal; Toil gotoPortal = new Toil() { initAction = () => { pawn.pather.StartPath(portalBldg.InteractionCell, PathEndMode.OnCell); }, defaultCompleteMode = ToilCompleteMode.PatherArrival }; yield return(gotoPortal); Toil chargePortal = new Toil() { initAction = () => { if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } }, tickAction = () => { if (age > (chargeAge + ticksTillCharge)) { comp.Mana.CurLevel -= .01f; portalBldg.ArcaneEnergyCur += .01f; chargeAge = age; } age++; if (age > duration) { this.EndJobWith(JobCondition.Succeeded); } if (comp.Mana.CurLevel < .01f) { this.EndJobWith(JobCondition.Succeeded); } if (portalBldg.ArcaneEnergyCur >= 1f) { this.EndJobWith(JobCondition.Succeeded); } }, defaultCompleteMode = ToilCompleteMode.Never }; yield return(chargePortal); }