public override void CompTick() { base.CompTick(); tickCounter++; if (tickCounter > Props.tickInterval) { thisPawn = this.parent as Pawn; if (thisPawn != null && thisPawn.Map != null && !thisPawn.Dead && !thisPawn.Downed) { foreach (Thing thing in GenRadial.RadialDistinctThingsAround(thisPawn.Position, thisPawn.Map, Props.radius, true)) { Pawn pawn = thing as Pawn; if (pawn != null && pawn.IsColonist) { if (!pawn.Dead && !pawn.Downed && pawn.GetStatValue(StatDefOf.PsychicSensitivity, true) > 0f) { MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); pawn.health.AddHediff(HediffDef.Named(Props.hediff)); } } } } tickCounter = 0; } }
public override void CompTick() { base.CompTick(); tickCounter++; if (tickCounter > Props.tickInterval) { thisPawn = this.parent as Pawn; if (thisPawn != null && thisPawn.Map != null && !thisPawn.Dead && !thisPawn.Downed) { foreach (Thing thing in GenRadial.RadialDistinctThingsAround(thisPawn.Position, thisPawn.Map, Props.radius, true)) { Pawn pawn = thing as Pawn; if (pawn != null && pawn.IsColonist) { if (!pawn.Dead && !pawn.Downed && pawn.GetStatValue(StatDefOf.PsychicSensitivity, true) > 0f) { Find.TickManager.slower.SignalForceNormalSpeedShort(); SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); pawn.mindState.mentalStateHandler.TryStartMentalState(DefDatabase <MentalStateDef> .GetNamed(Props.mentalState, true), null, true, false, null, false); } } } } tickCounter = 0; } }
public override void CompTick() { base.CompTick(); tickCounter++; if (tickCounter > Props.tickInterval) { thisPawn = this.parent as Pawn; if (thisPawn != null && thisPawn.Map != null && !thisPawn.Dead && !thisPawn.Downed) { foreach (Thing thing in GenRadial.RadialDistinctThingsAround(thisPawn.Position, thisPawn.Map, Props.radius, true)) { Pawn pawn = thing as Pawn; if (pawn != null && !pawn.AnimalOrWildMan() && pawn.RaceProps.IsFlesh) { if (!pawn.Dead && !pawn.Downed && pawn.GetStatValue(StatDefOf.PsychicSensitivity, true) > 0f) { if (Props.showEffect) { Find.TickManager.slower.SignalForceNormalSpeedShort(); SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); } if (pawn.needs != null && pawn.needs.mood != null) { pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named(Props.thoughtDef), null); } } } } } tickCounter = 0; } }
public override void CompTick() { base.CompTick(); tickCounter++; //Only do anything every tickInterval if (tickCounter > Props.tickInterval) { thisPawn = this.parent as Pawn; //Null map check. Also will only work if pawn is not dead or downed if (thisPawn != null && thisPawn.Map != null && !thisPawn.Dead && !thisPawn.Downed) { foreach (Thing thing in GenRadial.RadialDistinctThingsAround(thisPawn.Position, thisPawn.Map, Props.radius, true)) { Pawn pawn = thing as Pawn; //Only work on colonists if (pawn != null && (pawn.IsColonist || Props.notOnlyAffectColonists)) { //Only work on not dead, not downed, not psychically immune colonists if (!pawn.Dead && !pawn.Downed && pawn.GetStatValue(StatDefOf.PsychicSensitivity, true) > 0f) { MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); pawn.health.AddHediff(HediffDef.Named(Props.hediff)); } } } } tickCounter = 0; } }
public override void CompTick() { base.CompTick(); tickCounter++; //Only do anything every tickInterval if (tickCounter > Props.tickInterval) { thisPawn = this.parent as Pawn; //Null map check. Also will only work if pawn is not dead or downed, and if needsToBeTamed is true, that the animal is tamed if (thisPawn != null && thisPawn.Map != null && !thisPawn.Dead && !thisPawn.Downed && (!Props.needsToBeTamed || (Props.needsToBeTamed && thisPawn.Faction != null && thisPawn.Faction.IsPlayer))) { foreach (Thing thing in GenRadial.RadialDistinctThingsAround(thisPawn.Position, thisPawn.Map, Props.radius, true)) { Pawn pawn = thing as Pawn; //It won't affect animals, cause they don't have Thoughts, or mechanoids, or itself if (pawn != null && !pawn.AnimalOrWildMan() && pawn.RaceProps.IsFlesh && pawn != this.parent) { //Only work on not dead, not downed, not psychically immune pawns if (!pawn.Dead && !pawn.Downed && pawn.GetStatValue(StatDefOf.PsychicSensitivity, true) > 0f) { //Only show an effect if the user wants it to, or it gets obnoxious if (Props.showEffect) { Find.TickManager.slower.SignalForceNormalSpeedShort(); SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); } if (!Props.conditionalOnWellBeing) { //Apply thought pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named(Props.thoughtDef), null); } else { bool wellbeingAffectedFlag = thisPawn.needs.food.Starving || (thisPawn.health.hediffSet.PainTotal > 0); if (wellbeingAffectedFlag) { pawn.needs.mood.thoughts.memories.RemoveMemoriesOfDef(ThoughtDef.Named(Props.thoughtDef)); pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named(Props.thoughtDefWhenSuffering), null); } else { pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named(Props.thoughtDef), null); } } } } } } tickCounter = 0; } }
public override void Notify_PawnDied() { if (Props.resurrectionEffect) { Map map = this.parent.pawn.Corpse.Map; if (map != null) { SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.pawn.Corpse.Position, this.parent.pawn.Corpse.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent.pawn.Corpse, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); ResurrectionUtility.Resurrect(this.parent.pawn.Corpse.InnerPawn); } } }
public override void CompPostTick(ref float severityAdjustment) { if (!parent.pawn.Awake() || parent.pawn.health == null || parent.pawn.health.InPainShock || !parent.pawn.Spawned) { return; } if (!Props.hideMoteWhenNotDrafted || parent.pawn.Drafted) { if (Props.mote != null && (mote == null || mote.Destroyed)) { mote = MoteMaker.MakeAttachedOverlay(parent.pawn, Props.mote, Vector3.zero); } if (mote != null) { mote.Maintain(); } } List <Pawn> list = null; list = parent.pawn.Map.mapPawns.PawnsInFaction(parent.pawn.Faction); foreach (Pawn item in list) { if (item.Dead || item.health == null || item == parent.pawn || !(item.Position.DistanceTo(parent.pawn.Position) <= Props.range) || !Props.targetingParameters.CanTarget(item) || ((Props.affectSameDef) && (item.def != parent.pawn.def))) { continue; } Hediff hediff = item.health.hediffSet.GetFirstHediffOfDef(Props.hediff); if (hediff == null) { hediff = item.health.AddHediff(Props.hediff, item.health.hediffSet.GetBrain()); hediff.Severity = Props.initialSeverity; HediffComp_Link hediffComp_Link = hediff.TryGetComp <HediffComp_Link>(); if (hediffComp_Link != null) { hediffComp_Link.drawConnection = true; hediffComp_Link.other = parent.pawn; } } HediffComp_Disappears hediffComp_Disappears = hediff.TryGetComp <HediffComp_Disappears>(); if (hediffComp_Disappears == null) { Log.Error("HediffComp_GiveHediffsInRange has a hediff in props which does not have a HediffComp_Disappears"); } else { hediffComp_Disappears.ticksToDisappear = 5; } } }
public override void Notify_PawnDied() { //This is just pure laziness, I hooked this code here so Vanilla Cooking Expanded's mechanite resurrector condiment //resurrects the pawn if it dies. But properly this should be a separate class. if (Props.resurrectionEffect) { Map map = this.parent.pawn.Corpse.Map; if (map != null) { SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.pawn.Corpse.Position, this.parent.pawn.Corpse.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent.pawn.Corpse, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); ResurrectionUtility.Resurrect(this.parent.pawn.Corpse.InnerPawn); } } }
public override void CompTick() { base.CompTick(); tickCounter++; //Only do anything every tickInterval if (tickCounter > Props.tickInterval) { thisPawn = this.parent as Pawn; //Null map check. Also will only work if pawn is not dead or downed if (thisPawn != null && thisPawn.Map != null && !thisPawn.Dead && !thisPawn.Downed && (!Props.needsToBeTamed || (Props.needsToBeTamed && thisPawn.Faction != null && thisPawn.Faction.IsPlayer))) { foreach (Thing thing in GenRadial.RadialDistinctThingsAround(thisPawn.Position, thisPawn.Map, Props.radius, true)) { Pawn pawn = thing as Pawn; //It won't affect mechanoids, dead people or itself if (pawn != null && !pawn.Dead && pawn.RaceProps.IsFlesh && pawn != this.parent) { //Only show an effect if the user wants it to, or it gets obnoxious if (Props.showEffect) { SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); } //Regenerate wounds if (pawn.health != null) { if (pawn.health.hediffSet.GetInjuriesTendable() != null && pawn.health.hediffSet.GetInjuriesTendable().Count <Hediff_Injury>() > 0) { foreach (Hediff_Injury injury in pawn.health.hediffSet.GetInjuriesTendable()) { injury.Severity = injury.Severity - 0.1f; break; } } } } } } tickCounter = 0; } }
public override IEnumerable <PreCastAction> GetPreCastActions() { if (Props.type == DeepStrikeType.Teleport) { yield return(new PreCastAction { action = delegate(LocalTargetInfo t, LocalTargetInfo d) { if (!this.parent.def.HasAreaOfEffect) { Pawn pawn = t.Pawn; if (pawn != null) { MoteMaker.MakeAttachedOverlay(pawn, ThingDefOf.Mote_PsycastSkipFlashEntry, Vector3.zero, 1f, -1f).detachAfterTicks = 5; } else { MoteMaker.MakeStaticMote(t.CenterVector3, this.parent.pawn.Map, ThingDefOf.Mote_PsycastSkipFlashEntry, 1f); } MoteMaker.MakeStaticMote(d.Cell, this.parent.pawn.Map, ThingDefOf.Mote_PsycastSkipInnerExit, 1f); } if (this.Props.destination != AbilityEffectDestination.RandomInRange) { MoteMaker.MakeStaticMote(d.Cell, this.parent.pawn.Map, ThingDefOf.Mote_PsycastSkipOuterRingExit, 1f); } if (!this.parent.def.HasAreaOfEffect) { SoundDefOf.Psycast_Skip_Entry.PlayOneShot(new TargetInfo(t.Cell, this.parent.pawn.Map, false)); SoundDefOf.Psycast_Skip_Exit.PlayOneShot(new TargetInfo(d.Cell, this.parent.pawn.Map, false)); } }, ticksAwayFromCast = 5 }); } yield break; }
//Generates a map with a defined seed private void GeneratePocketMap(int mapWidth) { IntVec3 size = new IntVec3(mapWidth, 1, mapWidth); this.dimensionSeed = Find.TickManager.TicksAbs.ToString(); // The new map must be connected to a parent on the world map var mapParent = (MapParent_PocketDimension)WorldObjectMaker.MakeWorldObject(PocketDimensionDefOf.CM_WorldObject_PocketDimension); mapParent.Tile = this.Map.Tile; mapParent.SetFaction(Faction.OfPlayer); Find.WorldObjects.Add(mapParent); // Generate the map and set the maps entrance to this box so the map knows what stuff it is made of string cachedSeedString = Find.World.info.seedString; Find.World.info.seedString = this.dimensionSeed; PocketDimensionUtility.Boxes[this.dimensionSeed] = this; mapParent.dimensionSeed = this.dimensionSeed; Map generatedMap = MapGenerator.GenerateMap(size, mapParent, mapParent.MapGeneratorDef, mapParent.ExtraGenStepDefs, null); Find.World.info.seedString = cachedSeedString; // Permanent darkness - seems moot since adding roof and walls... GameCondition_NoSunlight gameCondition_NoSunlight = (GameCondition_NoSunlight)GameConditionMaker.MakeCondition(PocketDimensionDefOf.CM_PocketDimensionCondition, -1); gameCondition_NoSunlight.Permanent = true; generatedMap.gameConditionManager.RegisterCondition(gameCondition_NoSunlight); // Now make an exit in the map ThingDef thingToMake = compCreator.Props.exitDef; List <Thing> thingList = generatedMap.Center.GetThingList(generatedMap).Where(x => x.def == thingToMake).ToList(); if (thingList.Count() == 0) { var newExit = ThingMaker.MakeThing(thingToMake, this.Stuff); newExit.SetFaction(this.Faction); GenPlace.TryPlaceThing(newExit, generatedMap.Center, generatedMap, ThingPlaceMode.Direct); thingList = generatedMap.Center.GetThingList(generatedMap).Where(x => x.def == thingToMake).ToList(); } Logger.MessageFormat(this, this.dimensionSeed); Building_PocketDimensionExit exit = thingList.First() as Building_PocketDimensionExit; exit.dimensionSeed = this.dimensionSeed; if (!string.IsNullOrEmpty(this.uniqueName)) { exit.uniqueName = "CM_PocketDimension_ExitName".Translate(this.uniqueName); } else { exit.uniqueName = "CM_PocketDimension_ExitName".Translate(this.LabelCap); } exit.SetVentOpen(ventOpen); PocketDimensionUtility.MapParents[this.dimensionSeed] = mapParent; PocketDimensionUtility.Exits[this.dimensionSeed] = exit; Messages.Message("CM_PocketDimensionCreated".Translate(), new TargetInfo(this), MessageTypeDefOf.PositiveEvent); ThingDef moteDef = DefDatabase <ThingDef> .GetNamedSilentFail("Mote_PsycastPsychicEffect"); SoundDef soundDef = DefDatabase <SoundDef> .GetNamedSilentFail("Psycast_Skip_Exit"); if (moteDef != null) { MoteMaker.MakeAttachedOverlay(this, moteDef, Vector3.zero, mapSize); } if (soundDef != null) { soundDef.PlayOneShot(new TargetInfo(this.Position, this.Map)); } }
public override void CompTick() { base.CompTick(); tickCounter++; if (tickCounter > Props.tickInterval) { thisBuilding = this.parent as Building; if (thisBuilding != null && thisBuilding.Map != null && thisBuilding.GetComp <CompPowerTrader>().PowerOn) { List <Pawn> allPawnsSpawned = thisBuilding.Map.mapPawns.AllPawnsSpawned; for (int k = 0; k < allPawnsSpawned.Count; k++) { if (allPawnsSpawned[k] != null && !allPawnsSpawned[k].AnimalOrWildMan() && allPawnsSpawned[k].RaceProps.IsFlesh) { pawnList.Add(allPawnsSpawned[k]); } } if (pawnList.Count > 0) { IntVec3 thisPawnLocation = thisBuilding.Position; List <Pawn> tempList = new List <Pawn>(); for (int k = 0; k < pawnList.Count; k++) { if (IntVec3Utility.ManhattanDistanceFlat(thisPawnLocation, pawnList[k].Position) < Props.radius) { tempList.Add(pawnList[k]); } } if (tempList.Count > 0) { Pawn chosenOne = tempList.RandomElement(); if (chosenOne != null) { if (!chosenOne.Dead && !chosenOne.Downed) { if (Props.showEffect) { Find.TickManager.slower.SignalForceNormalSpeedShort(); SoundDefOf.PsychicPulseGlobal.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false)); MoteMaker.MakeAttachedOverlay(this.parent, ThingDef.Named("Mote_PsycastPsychicEffect"), Vector3.zero, 1f, -1f); } if (chosenOne.needs.mood.thoughts.memories.GetFirstMemoryOfDef(ThoughtDef.Named(Props.foundThoughtDef)) != null) { //Log.Message("Memoria encontrada"); chosenOne.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named(Props.thoughtDef), null); } else //Log.Message("Memoria no encontrada"); { } } } } tempList.Clear(); } } pawnList.Clear(); tickCounter = 0; } }