public void UpdateRotation() { if (this.pawn.Destroyed) { return; } if (this.pawn.jobs.HandlingFacing) { return; } if (this.pawn.pather.Moving) { if (this.pawn.pather.curPath == null || this.pawn.pather.curPath.NodesLeftCount < 1) { return; } this.FaceAdjacentCell(this.pawn.pather.nextCell); return; } else { Stance_Busy stance_Busy = this.pawn.stances.curStance as Stance_Busy; if (stance_Busy != null && stance_Busy.focusTarg.IsValid) { if (stance_Busy.focusTarg.HasThing) { this.Face(stance_Busy.focusTarg.Thing.DrawPos); } else { this.FaceCell(stance_Busy.focusTarg.Cell); } return; } if (this.pawn.jobs.curJob != null) { LocalTargetInfo target = this.pawn.CurJob.GetTarget(this.pawn.jobs.curDriver.rotateToFace); if (target.HasThing) { bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = target.Thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (this.pawn.Position == new IntVec3(j, 0, i)) { this.Face(target.Thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(this.pawn.Position)) { this.FaceAdjacentCell(intVec); return; } if (intVec.AdjacentTo8Way(this.pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.6f, "jbthing", 50); GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } this.FaceAdjacentCell(c); return; } this.Face(target.Thing.DrawPos); return; } else { if (this.pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { this.pawn.Map.debugDrawer.FlashCell(this.pawn.Position, 0.2f, "jbloc", 50); GenDraw.DrawLineBetween(this.pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } this.FaceAdjacentCell(target.Cell); return; } if (target.Cell.IsValid && target.Cell != this.pawn.Position) { this.Face(target.Cell.ToVector3()); return; } } } if (this.pawn.Drafted) { this.pawn.Rotation = Rot4.South; } return; } }
public bool CanHitTarget(LocalTargetInfo targ) { return(this.caster != null && this.caster.Spawned && this.CanHitTargetFrom(this.caster.Position, targ)); }
public bool IsReserved(LocalTargetInfo target) { return(this.FirstReserverOf(target) != null); }
public Stance_Busy(int ticks, LocalTargetInfo focusTarg, Verb verb) { this.ticksLeft = ticks; this.focusTarg = focusTarg; this.verb = verb; }
public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo usedTarget, LocalTargetInfo intendedTarget, ProjectileHitFlags hitFlags, Thing equipment = null, ThingDef targetCoverDef = null) { this.launcher = launcher; this.origin = origin; this.usedTarget = usedTarget; this.intendedTarget = intendedTarget; this.targetCoverDef = targetCoverDef; HitFlags = hitFlags; if (equipment != null) { equipmentDef = equipment.def; weaponDamageMultiplier = equipment.GetStatValue(StatDefOf.RangedWeapon_DamageMultiplier); } else { equipmentDef = null; weaponDamageMultiplier = 1f; } destination = usedTarget.Cell.ToVector3Shifted() + Gen.RandomHorizontalVector(0.3f); ticksToImpact = Mathf.CeilToInt(StartingTicksToImpact); if (ticksToImpact < 1) { ticksToImpact = 1; } if (!def.projectile.soundAmbient.NullOrUndefined()) { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick); ambientSustainer = def.projectile.soundAmbient.TrySpawnSustainer(info); } }
public float EffectiveMinRange(LocalTargetInfo target, Thing caster) { return(EffectiveMinRange(VerbUtility.AllowAdjacentShot(target, caster))); }
public static LocalTargetInfo LocalTargetInfoFromNode(XmlNode node, string label, LocalTargetInfo defaultValue) { LoadIDsWantedBank loadIDs = Scribe.loader.crossRefs.loadIDs; if (node != null && Scribe.EnterNode(label)) { try { string innerText = node.InnerText; if (innerText.Length != 0 && innerText[0] == '(') { loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), "thing"); return(new LocalTargetInfo(IntVec3.FromString(innerText))); } loadIDs.RegisterLoadIDReadFromXml(innerText, typeof(Thing), "thing"); return(LocalTargetInfo.Invalid); } finally { Scribe.ExitNode(); } } loadIDs.RegisterLoadIDReadFromXml(null, typeof(Thing), label + "/thing"); return(defaultValue); }
protected void TryCastNextBurstShot() { LocalTargetInfo localTargetInfo = currentTarget; if (Available() && TryCastShot()) { if (verbProps.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(caster.Position, caster.Map, ThingDefOf.Mote_ShotFlash, verbProps.muzzleFlashScale); } if (verbProps.soundCast != null) { verbProps.soundCast.PlayOneShot(new TargetInfo(caster.Position, caster.Map)); } if (verbProps.soundCastTail != null) { verbProps.soundCastTail.PlayOneShotOnCamera(caster.Map); } if (CasterIsPawn) { if (CasterPawn.thinker != null) { CasterPawn.mindState.Notify_EngagedTarget(); } if (CasterPawn.mindState != null) { CasterPawn.mindState.Notify_AttackedTarget(localTargetInfo); } if (CasterPawn.MentalState != null) { CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (TerrainDefSource != null) { CasterPawn.meleeVerbs.Notify_UsedTerrainBasedVerb(); } if (CasterPawn.health != null) { CasterPawn.health.Notify_UsedVerb(this, localTargetInfo); } if (EquipmentSource != null) { EquipmentSource.Notify_UsedWeapon(CasterPawn); } if (!CasterPawn.Spawned) { Reset(); return; } } if (verbProps.consumeFuelPerShot > 0f) { caster.TryGetComp <CompRefuelable>()?.ConsumeFuel(verbProps.consumeFuelPerShot); } burstShotsLeft--; } else { burstShotsLeft = 0; } if (burstShotsLeft > 0) { ticksToNextBurstShot = verbProps.ticksBetweenBurstShots; if (CasterIsPawn && !verbProps.nonInterruptingSelfCast) { CasterPawn.stances.SetStance(new Stance_Cooldown(verbProps.ticksBetweenBurstShots + 1, currentTarget, this)); } return; } state = VerbState.Idle; if (CasterIsPawn && !verbProps.nonInterruptingSelfCast) { CasterPawn.stances.SetStance(new Stance_Cooldown(verbProps.AdjustedCooldownTicks(this, CasterPawn), currentTarget, this)); } if (castCompleteCallback != null) { castCompleteCallback(); } }
public virtual void OnGUI(LocalTargetInfo target) { Texture2D icon = ((!target.IsValid) ? TexCommand.CannotShoot : ((!(UIIcon != BaseContent.BadTex)) ? TexCommand.Attack : UIIcon)); GenUI.DrawMouseAttachment(icon); }
public static bool CanReach(this Pawn pawn, LocalTargetInfo dest, PathEndMode peMode, Danger maxDanger, bool canBash = false, TraverseMode mode = TraverseMode.ByPawn) { return(pawn.Spawned && pawn.Map.reachability.CanReach(pawn.Position, dest, peMode, TraverseParms.For(pawn, maxDanger, mode, canBash))); }
public bool TryStartCastOn(LocalTargetInfo castTarg, bool surpriseAttack = false, bool canHitNonTargetPawns = true) { return(TryStartCastOn(castTarg, LocalTargetInfo.Invalid, surpriseAttack, canHitNonTargetPawns)); }
public virtual void Notify_PawnUsedVerb(Verb verb, LocalTargetInfo target) { }
protected void TryCastNextBurstShot() { LocalTargetInfo localTargetInfo = this.currentTarget; if (this.TryCastShot()) { if (this.verbProps.muzzleFlashScale > 0.0099999997764825821) { MoteMaker.MakeStaticMote(this.caster.Position, this.caster.Map, ThingDefOf.Mote_ShotFlash, this.verbProps.muzzleFlashScale); } if (this.verbProps.soundCast != null) { this.verbProps.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false)); } if (this.verbProps.soundCastTail != null) { this.verbProps.soundCastTail.PlayOneShotOnCamera(this.caster.Map); } if (this.CasterIsPawn) { if (this.CasterPawn.thinker != null) { this.CasterPawn.mindState.Notify_EngagedTarget(); } if (this.CasterPawn.mindState != null) { this.CasterPawn.mindState.Notify_AttackedTarget(localTargetInfo); } if (this.CasterPawn.MentalState != null) { this.CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (!this.CasterPawn.Spawned) { return; } } this.burstShotsLeft--; } else { this.burstShotsLeft = 0; } if (this.burstShotsLeft > 0) { this.ticksToNextBurstShot = this.verbProps.ticksBetweenBurstShots; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.ticksBetweenBurstShots + 1, this.currentTarget, this)); } } else { this.state = VerbState.Idle; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.AdjustedCooldownTicks(this, this.CasterPawn, this.ownerEquipment), this.currentTarget, this)); } if (this.castCompleteCallback != null) { this.castCompleteCallback(); } } }
public void FaceTarget(LocalTargetInfo target) { if (!target.IsValid) { return; } if (target.HasThing) { Thing thing = target.Thing.Spawned ? target.Thing : ThingOwnerUtility.GetFirstSpawnedParentThing(target.Thing); if (thing == null || !thing.Spawned) { return; } bool flag = false; IntVec3 c = default(IntVec3); CellRect cellRect = thing.OccupiedRect(); for (int i = cellRect.minZ; i <= cellRect.maxZ; i++) { for (int j = cellRect.minX; j <= cellRect.maxX; j++) { if (pawn.Position == new IntVec3(j, 0, i)) { Face(thing.DrawPos); return; } } } for (int k = cellRect.minZ; k <= cellRect.maxZ; k++) { for (int l = cellRect.minX; l <= cellRect.maxX; l++) { IntVec3 intVec = new IntVec3(l, 0, k); if (intVec.AdjacentToCardinal(pawn.Position)) { FaceAdjacentCell(intVec); return; } if (intVec.AdjacentTo8Way(pawn.Position)) { flag = true; c = intVec; } } } if (flag) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.6f, "jbthing"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), c.ToVector3Shifted()); } FaceAdjacentCell(c); } else { Face(thing.DrawPos); } } else if (pawn.Position.AdjacentTo8Way(target.Cell)) { if (DebugViewSettings.drawPawnRotatorTarget) { pawn.Map.debugDrawer.FlashCell(pawn.Position, 0.2f, "jbloc"); GenDraw.DrawLineBetween(pawn.Position.ToVector3Shifted(), target.Cell.ToVector3Shifted()); } FaceAdjacentCell(target.Cell); } else if (target.Cell.IsValid && target.Cell != pawn.Position) { Face(target.Cell.ToVector3()); } }
public bool CanReach(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseMode traverseMode, Danger maxDanger) { return(this.CanReach(start, dest, peMode, TraverseParms.For(traverseMode, maxDanger, false))); }
public static bool AllowAdjacentShot(LocalTargetInfo target, Thing caster) { Pawn pawn = target.Thing as Pawn; return(pawn == null || !pawn.HostileTo(caster) || pawn.Downed); }
public bool CanReach(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams) { if (this.working) { Log.ErrorOnce("Called CanReach() while working. This should never happen. Suppressing further errors.", 7312233, false); return(false); } if (traverseParams.pawn != null) { if (!traverseParams.pawn.Spawned) { return(false); } if (traverseParams.pawn.Map != this.map) { Log.Error(string.Concat(new object[] { "Called CanReach() with a pawn spawned not on this map. This means that we can't check his reachability here. Pawn's current map should have been used instead of this one. pawn=", traverseParams.pawn, " pawn.Map=", traverseParams.pawn.Map, " map=", this.map }), false); return(false); } } if (ReachabilityImmediate.CanReachImmediate(start, dest, this.map, peMode, traverseParams.pawn)) { return(true); } if (!dest.IsValid) { return(false); } if (dest.HasThing && dest.Thing.Map != this.map) { return(false); } if (!start.InBounds(this.map) || !dest.Cell.InBounds(this.map)) { return(false); } if ((peMode == PathEndMode.OnCell || peMode == PathEndMode.Touch || peMode == PathEndMode.ClosestTouch) && traverseParams.mode != TraverseMode.NoPassClosedDoorsOrWater && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { Room room = RegionAndRoomQuery.RoomAtFast(start, this.map, RegionType.Set_Passable); if (room != null && room == RegionAndRoomQuery.RoomAtFast(dest.Cell, this.map, RegionType.Set_Passable)) { return(true); } } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings) { TraverseParms traverseParams2 = traverseParams; traverseParams2.mode = TraverseMode.PassDoors; if (this.CanReach(start, dest, peMode, traverseParams2)) { return(true); } } dest = (LocalTargetInfo)GenPath.ResolvePathMode(traverseParams.pawn, dest.ToTargetInfo(this.map), ref peMode); this.working = true; bool result; try { this.pathGrid = this.map.pathGrid; this.regionGrid = this.map.regionGrid; this.reachedIndex += 1u; this.destRegions.Clear(); if (peMode == PathEndMode.OnCell) { Region region = dest.Cell.GetRegion(this.map, RegionType.Set_Passable); if (region != null && region.Allows(traverseParams, true)) { this.destRegions.Add(region); } } else if (peMode == PathEndMode.Touch) { TouchPathEndModeUtility.AddAllowedAdjacentRegions(dest, traverseParams, this.map, this.destRegions); } if (this.destRegions.Count == 0 && traverseParams.mode != TraverseMode.PassAllDestroyableThings && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { this.FinalizeCheck(); result = false; } else { this.destRegions.RemoveDuplicates <Region>(); this.openQueue.Clear(); this.numRegionsOpened = 0; this.DetermineStartRegions(start); if (this.openQueue.Count == 0 && traverseParams.mode != TraverseMode.PassAllDestroyableThings && traverseParams.mode != TraverseMode.PassAllDestroyableThingsNotWater) { this.FinalizeCheck(); result = false; } else { if (this.startingRegions.Any <Region>() && this.destRegions.Any <Region>() && this.CanUseCache(traverseParams.mode)) { BoolUnknown cachedResult = this.GetCachedResult(traverseParams); if (cachedResult == BoolUnknown.True) { this.FinalizeCheck(); return(true); } if (cachedResult == BoolUnknown.False) { this.FinalizeCheck(); return(false); } if (cachedResult != BoolUnknown.Unknown) { } } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings || traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParams.mode == TraverseMode.NoPassClosedDoorsOrWater) { bool flag = this.CheckCellBasedReachability(start, dest, peMode, traverseParams); this.FinalizeCheck(); result = flag; } else { bool flag2 = this.CheckRegionBasedReachability(traverseParams); this.FinalizeCheck(); result = flag2; } } } } finally { this.working = false; } return(result); }
public static bool CanReachImmediate(this Pawn pawn, LocalTargetInfo target, PathEndMode peMode) { return(pawn.Spawned && ReachabilityImmediate.CanReachImmediate(pawn.Position, target, pawn.Map, peMode, pawn)); }
protected virtual bool RemoveAllDesignationsAffects(LocalTargetInfo target) { return(true); }
public static void Look(ref LocalTargetInfo value, bool saveDestroyedThings, string label) { Scribe_TargetInfo.Look(ref value, saveDestroyedThings, label, LocalTargetInfo.Invalid); }
public Designation(LocalTargetInfo target, DesignationDef def) { this.target = target; this.def = def; }
public static void Look(ref LocalTargetInfo value, string label, LocalTargetInfo defaultValue) { Scribe_TargetInfo.Look(ref value, false, label, defaultValue); }
public void Launch(Thing launcher, LocalTargetInfo usedTarget, LocalTargetInfo intendedTarget, ProjectileHitFlags hitFlags, Thing equipment = null) { Launch(launcher, base.Position.ToVector3Shifted(), usedTarget, intendedTarget, hitFlags, equipment); }
public static void Look(ref LocalTargetInfo value, bool saveDestroyedThings, string label, LocalTargetInfo defaultValue) { if (Scribe.mode == LoadSaveMode.Saving) { if (!value.Equals(defaultValue)) { if (value.Thing != null && Scribe_References.CheckSaveReferenceToDestroyedThing(value.Thing, label, saveDestroyedThings)) { return; } Scribe.saver.WriteElement(label, value.ToString()); } } else if (Scribe.mode == LoadSaveMode.LoadingVars) { value = ScribeExtractor.LocalTargetInfoFromNode(Scribe.loader.curXmlParent[label], label, defaultValue); } else if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs) { value = ScribeExtractor.ResolveLocalTargetInfo(value, label); } }
protected void TryCastNextBurstShot() { LocalTargetInfo localTargetInfo = this.currentTarget; if (this.Available() && this.TryCastShot()) { if (this.verbProps.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(this.caster.Position, this.caster.Map, ThingDefOf.Mote_ShotFlash, this.verbProps.muzzleFlashScale); } if (this.verbProps.soundCast != null) { this.verbProps.soundCast.PlayOneShot(new TargetInfo(this.caster.Position, this.caster.Map, false)); } if (this.verbProps.soundCastTail != null) { this.verbProps.soundCastTail.PlayOneShotOnCamera(this.caster.Map); } if (this.CasterIsPawn) { if (this.CasterPawn.thinker != null) { this.CasterPawn.mindState.Notify_EngagedTarget(); } if (this.CasterPawn.mindState != null) { this.CasterPawn.mindState.Notify_AttackedTarget(localTargetInfo); } if (this.CasterPawn.MentalState != null) { this.CasterPawn.MentalState.Notify_AttackedTarget(localTargetInfo); } if (this.TerrainDefSource != null) { this.CasterPawn.meleeVerbs.Notify_UsedTerrainBasedVerb(); } if (!this.CasterPawn.Spawned) { return; } } if (this.verbProps.consumeFuelPerShot > 0f) { CompRefuelable compRefuelable = this.caster.TryGetComp <CompRefuelable>(); if (compRefuelable != null) { compRefuelable.ConsumeFuel(this.verbProps.consumeFuelPerShot); } } this.burstShotsLeft--; } else { this.burstShotsLeft = 0; } if (this.burstShotsLeft > 0) { this.ticksToNextBurstShot = this.verbProps.ticksBetweenBurstShots; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.ticksBetweenBurstShots + 1, this.currentTarget, this)); } } else { this.state = VerbState.Idle; if (this.CasterIsPawn) { this.CasterPawn.stances.SetStance(new Stance_Cooldown(this.verbProps.AdjustedCooldownTicks(this, this.CasterPawn), this.currentTarget, this)); } if (this.castCompleteCallback != null) { this.castCompleteCallback(); } } }
public static void Look(ref LocalTargetInfo value, string label) { Scribe_TargetInfo.Look(ref value, false, label, LocalTargetInfo.Invalid); }
public bool TryFindShootLineFromTo(IntVec3 root, LocalTargetInfo targ, out ShootLine resultingLine) { if (targ.HasThing && targ.Thing.Map != this.caster.Map) { resultingLine = default(ShootLine); return(false); } if (this.verbProps.IsMeleeAttack || this.verbProps.range <= 1.42f) { resultingLine = new ShootLine(root, targ.Cell); return(ReachabilityImmediate.CanReachImmediate(root, targ, this.caster.Map, PathEndMode.Touch, null)); } CellRect cellRect = (!targ.HasThing) ? CellRect.SingleCell(targ.Cell) : targ.Thing.OccupiedRect(); float num = this.verbProps.EffectiveMinRange(targ, this.caster); float num2 = cellRect.ClosestDistSquaredTo(root); if (num2 > this.verbProps.range * this.verbProps.range || num2 < num * num) { resultingLine = new ShootLine(root, targ.Cell); return(false); } if (!this.verbProps.requireLineOfSight) { resultingLine = new ShootLine(root, targ.Cell); return(true); } if (this.CasterIsPawn) { IntVec3 dest; if (this.CanHitFromCellIgnoringRange(root, targ, out dest)) { resultingLine = new ShootLine(root, dest); return(true); } ShootLeanUtility.LeanShootingSourcesFromTo(root, cellRect.ClosestCellTo(root), this.caster.Map, Verb.tempLeanShootSources); for (int i = 0; i < Verb.tempLeanShootSources.Count; i++) { IntVec3 intVec = Verb.tempLeanShootSources[i]; if (this.CanHitFromCellIgnoringRange(intVec, targ, out dest)) { resultingLine = new ShootLine(intVec, dest); return(true); } } } else { CellRect.CellRectIterator iterator = this.caster.OccupiedRect().GetIterator(); while (!iterator.Done()) { IntVec3 current = iterator.Current; IntVec3 dest; if (this.CanHitFromCellIgnoringRange(current, targ, out dest)) { resultingLine = new ShootLine(current, dest); return(true); } iterator.MoveNext(); } } resultingLine = new ShootLine(root, targ.Cell); return(false); }
private bool CheckCellBasedReachability(IntVec3 start, LocalTargetInfo dest, PathEndMode peMode, TraverseParms traverseParams) { IntVec3 foundCell = IntVec3.Invalid; Region[] directRegionGrid = this.regionGrid.DirectGrid; PathGrid pathGrid = this.map.pathGrid; CellIndices cellIndices = this.map.cellIndices; this.map.floodFiller.FloodFill(start, delegate(IntVec3 c) { int num = cellIndices.CellToIndex(c); if ((traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater || traverseParams.mode == TraverseMode.NoPassClosedDoorsOrWater) && c.GetTerrain(this.map).IsWater) { return(false); } if (traverseParams.mode == TraverseMode.PassAllDestroyableThings || traverseParams.mode == TraverseMode.PassAllDestroyableThingsNotWater) { if (!pathGrid.WalkableFast(num)) { Building edifice = c.GetEdifice(this.map); if (edifice == null || !PathFinder.IsDestroyable(edifice)) { return(false); } } } else if (traverseParams.mode != TraverseMode.NoPassClosedDoorsOrWater) { Log.ErrorOnce("Do not use this method for non-cell based modes!", 938476762, false); if (!pathGrid.WalkableFast(num)) { return(false); } } Region region = directRegionGrid[num]; return(region == null || region.Allows(traverseParams, false)); }, delegate(IntVec3 c) { if (ReachabilityImmediate.CanReachImmediate(c, dest, this.map, peMode, traverseParams.pawn)) { foundCell = c; return(true); } return(false); }, int.MaxValue, false, null); if (foundCell.IsValid) { if (this.CanUseCache(traverseParams.mode)) { Region validRegionAt = this.regionGrid.GetValidRegionAt(foundCell); if (validRegionAt != null) { for (int i = 0; i < this.startingRegions.Count; i++) { this.cache.AddCachedResult(this.startingRegions[i].Room, validRegionAt.Room, traverseParams, true); } } } return(true); } if (this.CanUseCache(traverseParams.mode)) { for (int j = 0; j < this.startingRegions.Count; j++) { for (int k = 0; k < this.destRegions.Count; k++) { this.cache.AddCachedResult(this.startingRegions[j].Room, this.destRegions[k].Room, traverseParams, false); } } } return(false); }
public void ReleaseAllForTarget(LocalTargetInfo target) { this.reservations.RemoveAll((PhysicalInteractionReservation x) => x.target == target); }
public static void Look <T>(ref List <T> list, bool saveDestroyedThings, string label, LookMode lookMode = LookMode.Undefined, params object[] ctorArgs) { if (lookMode == LookMode.Undefined) { if (ParseHelper.HandlesType(typeof(T))) { lookMode = LookMode.Value; } else if (typeof(T) == typeof(LocalTargetInfo)) { lookMode = LookMode.LocalTargetInfo; } else if (typeof(T) == typeof(TargetInfo)) { lookMode = LookMode.TargetInfo; } else if (typeof(T) == typeof(GlobalTargetInfo)) { lookMode = LookMode.GlobalTargetInfo; } else if (typeof(Def).IsAssignableFrom(typeof(T))) { lookMode = LookMode.Def; } else { if (!typeof(IExposable).IsAssignableFrom(typeof(T)) || typeof(ILoadReferenceable).IsAssignableFrom(typeof(T))) { Log.Error("LookList call with a list of " + typeof(T) + " must have lookMode set explicitly."); return; } lookMode = LookMode.Deep; } } if (Scribe.EnterNode(label)) { try { if (Scribe.mode == LoadSaveMode.Saving) { if (list == null) { Scribe.saver.WriteAttribute("IsNull", "True"); } else { foreach (T current in list) { if (lookMode == LookMode.Value) { T t = current; Scribe_Values.Look <T>(ref t, "li", default(T), true); } else if (lookMode == LookMode.LocalTargetInfo) { LocalTargetInfo localTargetInfo = (LocalTargetInfo)((object)current); Scribe_TargetInfo.Look(ref localTargetInfo, saveDestroyedThings, "li"); } else if (lookMode == LookMode.TargetInfo) { TargetInfo targetInfo = (TargetInfo)((object)current); Scribe_TargetInfo.Look(ref targetInfo, saveDestroyedThings, "li"); } else if (lookMode == LookMode.GlobalTargetInfo) { GlobalTargetInfo globalTargetInfo = (GlobalTargetInfo)((object)current); Scribe_TargetInfo.Look(ref globalTargetInfo, saveDestroyedThings, "li"); } else if (lookMode == LookMode.Def) { Def def = (Def)((object)current); Scribe_Defs.Look <Def>(ref def, "li"); } else if (lookMode == LookMode.Deep) { T t2 = current; Scribe_Deep.Look <T>(ref t2, saveDestroyedThings, "li", ctorArgs); } else if (lookMode == LookMode.Reference) { ILoadReferenceable loadReferenceable = (ILoadReferenceable)((object)current); Scribe_References.Look <ILoadReferenceable>(ref loadReferenceable, "li", saveDestroyedThings); } } } } else if (Scribe.mode == LoadSaveMode.LoadingVars) { XmlNode curXmlParent = Scribe.loader.curXmlParent; XmlAttribute xmlAttribute = curXmlParent.Attributes["IsNull"]; if (xmlAttribute != null && xmlAttribute.Value.ToLower() == "true") { list = null; } else if (lookMode == LookMode.Value) { list = new List <T>(curXmlParent.ChildNodes.Count); foreach (XmlNode subNode in curXmlParent.ChildNodes) { T item = ScribeExtractor.ValueFromNode <T>(subNode, default(T)); list.Add(item); } } else if (lookMode == LookMode.Deep) { list = new List <T>(curXmlParent.ChildNodes.Count); foreach (XmlNode subNode2 in curXmlParent.ChildNodes) { T item2 = ScribeExtractor.SaveableFromNode <T>(subNode2, ctorArgs); list.Add(item2); } } else if (lookMode == LookMode.Def) { list = new List <T>(curXmlParent.ChildNodes.Count); foreach (XmlNode subNode3 in curXmlParent.ChildNodes) { T item3 = ScribeExtractor.DefFromNodeUnsafe <T>(subNode3); list.Add(item3); } } else if (lookMode == LookMode.LocalTargetInfo) { list = new List <T>(curXmlParent.ChildNodes.Count); int num = 0; foreach (XmlNode node in curXmlParent.ChildNodes) { LocalTargetInfo localTargetInfo2 = ScribeExtractor.LocalTargetInfoFromNode(node, num.ToString(), LocalTargetInfo.Invalid); T item4 = (T)((object)localTargetInfo2); list.Add(item4); num++; } } else if (lookMode == LookMode.TargetInfo) { list = new List <T>(curXmlParent.ChildNodes.Count); int num2 = 0; foreach (XmlNode node2 in curXmlParent.ChildNodes) { TargetInfo targetInfo2 = ScribeExtractor.TargetInfoFromNode(node2, num2.ToString(), TargetInfo.Invalid); T item5 = (T)((object)targetInfo2); list.Add(item5); num2++; } } else if (lookMode == LookMode.GlobalTargetInfo) { list = new List <T>(curXmlParent.ChildNodes.Count); int num3 = 0; foreach (XmlNode node3 in curXmlParent.ChildNodes) { GlobalTargetInfo globalTargetInfo2 = ScribeExtractor.GlobalTargetInfoFromNode(node3, num3.ToString(), GlobalTargetInfo.Invalid); T item6 = (T)((object)globalTargetInfo2); list.Add(item6); num3++; } } else if (lookMode == LookMode.Reference) { List <string> list2 = new List <string>(curXmlParent.ChildNodes.Count); foreach (XmlNode xmlNode in curXmlParent.ChildNodes) { list2.Add(xmlNode.InnerText); } Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(list2, string.Empty); } } else if (Scribe.mode == LoadSaveMode.ResolvingCrossRefs) { if (lookMode == LookMode.Reference) { list = Scribe.loader.crossRefs.TakeResolvedRefList <T>(string.Empty); } else if (lookMode == LookMode.LocalTargetInfo) { if (list != null) { for (int i = 0; i < list.Count; i++) { list[i] = (T)((object)ScribeExtractor.ResolveLocalTargetInfo((LocalTargetInfo)((object)list[i]), i.ToString())); } } } else if (lookMode == LookMode.TargetInfo) { if (list != null) { for (int j = 0; j < list.Count; j++) { list[j] = (T)((object)ScribeExtractor.ResolveTargetInfo((TargetInfo)((object)list[j]), j.ToString())); } } } else if (lookMode == LookMode.GlobalTargetInfo && list != null) { for (int k = 0; k < list.Count; k++) { list[k] = (T)((object)ScribeExtractor.ResolveGlobalTargetInfo((GlobalTargetInfo)((object)list[k]), k.ToString())); } } } } finally { Scribe.ExitNode(); } } else if (Scribe.mode == LoadSaveMode.LoadingVars) { if (lookMode == LookMode.Reference) { Scribe.loader.crossRefs.loadIDs.RegisterLoadIDListReadFromXml(null, label); } list = null; } }