public void Attacked(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { if (newattack) { newattack = false; } }
public void Aura(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { if (props.aura != null) { for (int i = pos.x - props.auraSize; i <= pos.x + props.auraSize; i++) { for (int j = pos.z - props.auraSize; j <= pos.z + props.auraSize; j++) { IntVec3 temp = new IntVec3(i, 0, j); if (temp != pos && temp.InBounds(map)) { ThingDef particle = ThingDef.Named(props.aura); List <ThingDef> thingdefs = new List <ThingDef>(); foreach (Thing t in temp.GetThingList(map)) { thingdefs.Add(t.def); } if (particle.GetCompProperties <CompProperties_AuraParticle>() != null && temp.GetFirstBuilding(map) == null && !thingdefs.Contains(ThingDef.Named(props.aura))) { particle.GetCompProperties <CompProperties_AuraParticle>().duration = props.duration; GenSpawn.Spawn(ThingDef.Named(props.aura), temp, map); } } } } } }
public void Proximity(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { for (int i = pos.x - props.proximity; i <= pos.x + props.proximity; i++) { for (int j = pos.z - props.proximity; j <= pos.z + props.proximity; j++) { IntVec3 temp = new IntVec3(i, 0, j); if (temp.InBounds(map) && temp.GetFirstPawn(map) != null && temp != pos && !temp.GetFirstPawn(map).Dead&& !temp.GetFirstPawn(map).Downed) { React(pos, map, props); } } } }
public void React(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { if (props.defenseType == CompProperties_ReactiveDefense.defType.aura) { Aura(pos, map, props); } if (props.defenseType == CompProperties_ReactiveDefense.defType.buff) { } if (props.defenseType == CompProperties_ReactiveDefense.defType.hide) { Hide(pos, map, props); } if (props.defenseType == CompProperties_ReactiveDefense.defType.projectile) { } }
public void Defend(CompProperties_ReactiveDefense props) { IntVec3 pos = base.parent.Position; Map map = base.parent.Map; if (props.defenseTrigger == CompProperties_ReactiveDefense.defTrigger.attacked) { Attacked(pos, map, props); } if (props.defenseTrigger == CompProperties_ReactiveDefense.defTrigger.health) { React(pos, map, props); } if (props.defenseTrigger == CompProperties_ReactiveDefense.defTrigger.proximity) { Proximity(pos, map, props); } }
public void Hide(IntVec3 pos, Map map, CompProperties_ReactiveDefense props) { if (props.statDefs == null || props.statDefs.Count == 0 || props.statValues == null || props.statValues.Count == 0 || props.statDefs.Count != props.statValues.Count) { return; } Pawn pawn = (Pawn)parent; if (pawn.Dead) { if (pawn.apparel.WornApparel.Count > 0) { List <Apparel> tap = pawn.apparel.WornApparel.ToList(); foreach (Apparel apparel in tap) { pawn.apparel.Remove(apparel); } } return; } if (((Pawn)parent).health.hediffSet.GetPartHealth(((Pawn)parent).RaceProps.body.corePart) < ((Pawn)parent).RaceProps.body.corePart.def.hitPoints * props.hpThreshold * ((Pawn)parent).def.race.baseHealthScale) { //Log.Error("a"); if (!hidden) { if (Props.apparel != null) { Apparel apparel = (Apparel)ThingMaker.MakeThing(Props.apparel); for (int i = 0; i < props.statDefs.Count; i++) { apparel.def.SetStatBaseValue(props.statDefs[i], props.statValues[i]); } if (ApparelUtility.HasPartsToWear(pawn, apparel.def)) { if (pawn.apparel == null) { pawn.apparel = new Pawn_ApparelTracker(pawn); } pawn.apparel.Wear(apparel, false); } } if (Props.stopAttacker && !stoppedAttacker) { ((Pawn)lastattack.Instigator).jobs.StartJob(new Job(JobDefOf.WaitWander), JobCondition.InterruptForced); stoppedAttacker = true; } ResolveHideGraphic(); hidden = true; pawn.jobs.StartJob(new Job(JobDefOf.FleeAndCower, pawn.Position), JobCondition.InterruptForced); } } else { //Log.Error("b"); if (hidden) { if (Props.apparel != null && pawn.apparel != null) { pawn.apparel.DestroyAll(); } ResolveBaseGraphic(); hidden = false; stoppedAttacker = false; } } }