public int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true) { Thing resultingTransferredItem2; int result = TryTransferToContainer(item, otherContainer, stackCount, out resultingTransferredItem2, canMergeWithExistingStacks); resultingTransferredItem = (T)resultingTransferredItem2; return(result); }
public int TryTransferToContainer(Thing item, ThingOwner otherContainer, int stackCount, out T resultingTransferredItem, bool canMergeWithExistingStacks = true) { Thing thing; int result = base.TryTransferToContainer(item, otherContainer, stackCount, out thing, canMergeWithExistingStacks); resultingTransferredItem = (T)((object)thing); return(result); }
private static void NotifyEverythingWhichUsesMapReference(Map map) { List <Map> maps = Find.Maps; int num = maps.IndexOf(map); ThingOwnerUtility.GetAllThingsRecursively(map, MapDeiniter.tmpThings, true, null); for (int i = 0; i < MapDeiniter.tmpThings.Count; i++) { MapDeiniter.tmpThings[i].Notify_MyMapRemoved(); } MapDeiniter.tmpThings.Clear(); for (int j = num; j < maps.Count; j++) { ThingOwner spawnedThings = maps[j].spawnedThings; for (int k = 0; k < spawnedThings.Count; k++) { if (j != num) { spawnedThings[k].DecrementMapIndex(); } } List <Room> allRooms = maps[j].regionGrid.allRooms; for (int l = 0; l < allRooms.Count; l++) { if (j == num) { allRooms[l].Notify_MyMapRemoved(); } else { allRooms[l].DecrementMapIndex(); } } foreach (Region current in maps[j].regionGrid.AllRegions_NoRebuild_InvalidAllowed) { if (j == num) { current.Notify_MyMapRemoved(); } else { current.DecrementMapIndex(); } } } }
public void TryAddRangeOrTransfer(IEnumerable <T> things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false) { if (things == this) { return; } ThingOwner thingOwner = things as ThingOwner; if (thingOwner != null) { thingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks); if (destroyLeftover) { thingOwner.ClearAndDestroyContents(DestroyMode.Vanish); } } else { IList <T> list = things as IList <T>; if (list != null) { for (int i = 0; i < list.Count; i++) { if (!base.TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover) { T t = list[i]; t.Destroy(DestroyMode.Vanish); } } } else { foreach (T t2 in things) { if (!base.TryAddOrTransfer(t2, canMergeWithExistingStacks) && destroyLeftover) { t2.Destroy(DestroyMode.Vanish); } } } } }
public void TryAddRangeOrTransfer(IEnumerable <T> things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false) { if (things != this) { ThingOwner thingOwner = things as ThingOwner; if (thingOwner != null) { thingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks); if (destroyLeftover) { thingOwner.ClearAndDestroyContents(); } } else { IList <T> list = things as IList <T>; if (list != null) { for (int i = 0; i < list.Count; i++) { if (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover) { T val = list[i]; val.Destroy(); } } } else { foreach (T thing in things) { T current = thing; if (!TryAddOrTransfer(current, canMergeWithExistingStacks) && destroyLeftover) { current.Destroy(); } } } } } }
public void TryAddRangeOrTransfer(IEnumerable <T> things, bool canMergeWithExistingStacks = true, bool destroyLeftover = false) { if (things == this) { return; } ThingOwner thingOwner = things as ThingOwner; if (thingOwner != null) { thingOwner.TryTransferAllToContainer(this, canMergeWithExistingStacks); if (destroyLeftover) { thingOwner.ClearAndDestroyContents(); } return; } IList <T> list = things as IList <T>; if (list != null) { for (int i = 0; i < list.Count; i++) { if (!TryAddOrTransfer(list[i], canMergeWithExistingStacks) && destroyLeftover) { list[i].Destroy(); } } return; } foreach (T thing in things) { if (!TryAddOrTransfer(thing, canMergeWithExistingStacks) && destroyLeftover) { thing.Destroy(); } } }
public bool TryTransferEquipmentToContainer(ThingWithComps eq, ThingOwner container) { return(this.equipment.TryTransferToContainer(eq, container, true)); }
public Pawn_CarryTracker(Pawn pawn) { this.pawn = pawn; this.innerContainer = new ThingOwner <Thing>(this, true, LookMode.Deep); }
public Pawn_EquipmentTracker(Pawn newPawn) { this.pawn = newPawn; this.equipment = new ThingOwner <ThingWithComps>(this); }
public static ThingOwner TryGetInnerInteractableThingOwner(this Thing thing) { IThingHolder thingHolder = thing as IThingHolder; ThingWithComps thingWithComps = thing as ThingWithComps; if (thingHolder != null) { ThingOwner directlyHeldThings = thingHolder.GetDirectlyHeldThings(); if (directlyHeldThings != null) { return(directlyHeldThings); } } if (thingWithComps != null) { List <ThingComp> allComps = thingWithComps.AllComps; for (int i = 0; i < allComps.Count; i++) { IThingHolder thingHolder2 = allComps[i] as IThingHolder; if (thingHolder2 != null) { ThingOwner directlyHeldThings2 = thingHolder2.GetDirectlyHeldThings(); if (directlyHeldThings2 != null) { return(directlyHeldThings2); } } } } ThingOwnerUtility.tmpHolders.Clear(); if (thingHolder != null) { thingHolder.GetChildHolders(ThingOwnerUtility.tmpHolders); if (ThingOwnerUtility.tmpHolders.Any <IThingHolder>()) { ThingOwner directlyHeldThings3 = ThingOwnerUtility.tmpHolders[0].GetDirectlyHeldThings(); if (directlyHeldThings3 != null) { return(directlyHeldThings3); } } } if (thingWithComps != null) { List <ThingComp> allComps2 = thingWithComps.AllComps; for (int j = 0; j < allComps2.Count; j++) { IThingHolder thingHolder3 = allComps2[j] as IThingHolder; if (thingHolder3 != null) { thingHolder3.GetChildHolders(ThingOwnerUtility.tmpHolders); if (ThingOwnerUtility.tmpHolders.Any <IThingHolder>()) { ThingOwner directlyHeldThings4 = ThingOwnerUtility.tmpHolders[0].GetDirectlyHeldThings(); if (directlyHeldThings4 != null) { return(directlyHeldThings4); } } } } } ThingOwnerUtility.tmpHolders.Clear(); return(null); }
public void ConstructComponents() { this.spawnedThings = new ThingOwner <Thing>(this); this.cellIndices = new CellIndices(this); this.listerThings = new ListerThings(ListerThingsUse.Global); this.listerBuildings = new ListerBuildings(); this.mapPawns = new MapPawns(this); this.dynamicDrawManager = new DynamicDrawManager(this); this.mapDrawer = new MapDrawer(this); this.tooltipGiverList = new TooltipGiverList(); this.pawnDestinationReservationManager = new PawnDestinationReservationManager(); this.reservationManager = new ReservationManager(this); this.physicalInteractionReservationManager = new PhysicalInteractionReservationManager(); this.designationManager = new DesignationManager(this); this.lordManager = new LordManager(this); this.debugDrawer = new DebugCellDrawer(); this.passingShipManager = new PassingShipManager(this); this.haulDestinationManager = new HaulDestinationManager(this); this.gameConditionManager = new GameConditionManager(this); this.weatherManager = new WeatherManager(this); this.zoneManager = new ZoneManager(this); this.resourceCounter = new ResourceCounter(this); this.mapTemperature = new MapTemperature(this); this.temperatureCache = new TemperatureCache(this); this.areaManager = new AreaManager(this); this.attackTargetsCache = new AttackTargetsCache(this); this.attackTargetReservationManager = new AttackTargetReservationManager(this); this.lordsStarter = new VoluntarilyJoinableLordsStarter(this); this.thingGrid = new ThingGrid(this); this.coverGrid = new CoverGrid(this); this.edificeGrid = new EdificeGrid(this); this.blueprintGrid = new BlueprintGrid(this); this.fogGrid = new FogGrid(this); this.glowGrid = new GlowGrid(this); this.regionGrid = new RegionGrid(this); this.terrainGrid = new TerrainGrid(this); this.pathGrid = new PathGrid(this); this.roofGrid = new RoofGrid(this); this.fertilityGrid = new FertilityGrid(this); this.snowGrid = new SnowGrid(this); this.deepResourceGrid = new DeepResourceGrid(this); this.exitMapGrid = new ExitMapGrid(this); this.linkGrid = new LinkGrid(this); this.glowFlooder = new GlowFlooder(this); this.powerNetManager = new PowerNetManager(this); this.powerNetGrid = new PowerNetGrid(this); this.regionMaker = new RegionMaker(this); this.pathFinder = new PathFinder(this); this.pawnPathPool = new PawnPathPool(this); this.regionAndRoomUpdater = new RegionAndRoomUpdater(this); this.regionLinkDatabase = new RegionLinkDatabase(); this.moteCounter = new MoteCounter(); this.gatherSpotLister = new GatherSpotLister(); this.windManager = new WindManager(this); this.listerBuildingsRepairable = new ListerBuildingsRepairable(); this.listerHaulables = new ListerHaulables(this); this.listerMergeables = new ListerMergeables(this); this.listerFilthInHomeArea = new ListerFilthInHomeArea(this); this.reachability = new Reachability(this); this.itemAvailability = new ItemAvailability(this); this.autoBuildRoofAreaSetter = new AutoBuildRoofAreaSetter(this); this.roofCollapseBufferResolver = new RoofCollapseBufferResolver(this); this.roofCollapseBuffer = new RoofCollapseBuffer(); this.wildAnimalSpawner = new WildAnimalSpawner(this); this.wildPlantSpawner = new WildPlantSpawner(this); this.steadyEnvironmentEffects = new SteadyEnvironmentEffects(this); this.skyManager = new SkyManager(this); this.overlayDrawer = new OverlayDrawer(); this.floodFiller = new FloodFiller(this); this.weatherDecider = new WeatherDecider(this); this.fireWatcher = new FireWatcher(this); this.dangerWatcher = new DangerWatcher(this); this.damageWatcher = new DamageWatcher(); this.strengthWatcher = new StrengthWatcher(this); this.wealthWatcher = new WealthWatcher(this); this.regionDirtyer = new RegionDirtyer(this); this.cellsInRandomOrder = new MapCellsInRandomOrder(this); this.rememberedCameraPos = new RememberedCameraPos(this); this.mineStrikeManager = new MineStrikeManager(); this.storyState = new StoryState(this); this.retainedCaravanData = new RetainedCaravanData(this); this.components.Clear(); this.FillComponents(); }
public virtual int CountProducts(Bill_Production bill) { ThingDefCountClass thingDefCountClass = this.recipe.products[0]; ThingDef thingDef = thingDefCountClass.thingDef; if (thingDefCountClass.thingDef.CountAsResource && !bill.includeEquipped && (bill.includeTainted || !thingDefCountClass.thingDef.IsApparel || !thingDefCountClass.thingDef.apparel.careIfWornByCorpse) && bill.includeFromZone == null && bill.hpRange.min == 0f && bill.hpRange.max == 1f && bill.qualityRange.min == QualityCategory.Awful && bill.qualityRange.max == QualityCategory.Legendary && !bill.limitToAllowedStuff) { return(bill.Map.resourceCounter.GetCount(thingDefCountClass.thingDef) + this.GetCarriedCount(bill, thingDef)); } int num = 0; if (bill.includeFromZone == null) { num = this.CountValidThings(bill.Map.listerThings.ThingsOfDef(thingDefCountClass.thingDef), bill, thingDef); if (thingDefCountClass.thingDef.Minifiable) { List <Thing> list = bill.Map.listerThings.ThingsInGroup(ThingRequestGroup.MinifiedThing); for (int i = 0; i < list.Count; i++) { MinifiedThing minifiedThing = (MinifiedThing)list[i]; if (this.CountValidThing(minifiedThing.InnerThing, bill, thingDef)) { num += minifiedThing.stackCount * minifiedThing.InnerThing.stackCount; } } } num += this.GetCarriedCount(bill, thingDef); } else { foreach (Thing current in bill.includeFromZone.AllContainedThings) { Thing innerIfMinified = current.GetInnerIfMinified(); if (this.CountValidThing(innerIfMinified, bill, thingDef)) { num += innerIfMinified.stackCount; } } } if (bill.includeEquipped) { foreach (Pawn current2 in bill.Map.mapPawns.FreeColonistsSpawned) { List <ThingWithComps> allEquipmentListForReading = current2.equipment.AllEquipmentListForReading; for (int j = 0; j < allEquipmentListForReading.Count; j++) { if (this.CountValidThing(allEquipmentListForReading[j], bill, thingDef)) { num += allEquipmentListForReading[j].stackCount; } } List <Apparel> wornApparel = current2.apparel.WornApparel; for (int k = 0; k < wornApparel.Count; k++) { if (this.CountValidThing(wornApparel[k], bill, thingDef)) { num += wornApparel[k].stackCount; } } ThingOwner directlyHeldThings = current2.inventory.GetDirectlyHeldThings(); for (int l = 0; l < directlyHeldThings.Count; l++) { if (this.CountValidThing(directlyHeldThings[l], bill, thingDef)) { num += directlyHeldThings[l].stackCount; } } } } return(num); }
public static void AppendThingHoldersFromThings(List <IThingHolder> outThingsHolders, ThingOwner container) { if (container == null) { return; } int i = 0; int count = container.Count; while (i < count) { IThingHolder thingHolder = container[i] as IThingHolder; if (thingHolder != null) { outThingsHolders.Add(thingHolder); } ThingWithComps thingWithComps = container[i] as ThingWithComps; if (thingWithComps != null) { List <ThingComp> allComps = thingWithComps.AllComps; for (int j = 0; j < allComps.Count; j++) { IThingHolder thingHolder2 = allComps[j] as IThingHolder; if (thingHolder2 != null) { outThingsHolders.Add(thingHolder2); } } } i++; } }
public Pawn_InventoryTracker(Pawn pawn) { this.pawn = pawn; this.innerContainer = new ThingOwner <Thing>(this, false, LookMode.Deep); }
public Pawn_CarryTracker(Pawn pawn) { this.pawn = pawn; innerContainer = new ThingOwner <Thing>(this, oneStackOnly: true); }
public Pawn_InventoryTracker(Pawn pawn) { this.pawn = pawn; innerContainer = new ThingOwner <Thing>(this, oneStackOnly: false); }
public Corpse() { operationsBillStack = new BillStack(this); innerContainer = new ThingOwner <Pawn>(this, oneStackOnly: true, LookMode.Reference); }
public Corpse() { this.operationsBillStack = new BillStack(this); this.innerContainer = new ThingOwner <Pawn>(this, true, LookMode.Reference); }
private DamageResult ApplyToPawn(DamageInfo dinfo, Pawn pawn) { DamageResult result = DamageResult.MakeNew(); if (dinfo.Amount <= 0) { return(result); } if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfPlayer) { return(result); } Map mapHeld = pawn.MapHeld; bool spawnedOrAnyParentSpawned = pawn.SpawnedOrAnyParentSpawned; if (dinfo.Def.spreadOut) { if (pawn.apparel != null) { List <Apparel> wornApparel = pawn.apparel.WornApparel; for (int num = wornApparel.Count - 1; num >= 0; num--) { this.CheckApplySpreadDamage(dinfo, wornApparel[num]); } } if (pawn.equipment != null && pawn.equipment.Primary != null) { this.CheckApplySpreadDamage(dinfo, pawn.equipment.Primary); } if (pawn.inventory != null) { ThingOwner <Thing> innerContainer = pawn.inventory.innerContainer; for (int num2 = innerContainer.Count - 1; num2 >= 0; num2--) { this.CheckApplySpreadDamage(dinfo, innerContainer[num2]); } } } if (this.ShouldFragmentDamageForDamageType(dinfo)) { int num3 = Rand.RangeInclusive(3, 4); for (int i = 0; i < num3; i++) { DamageInfo dinfo2 = dinfo; dinfo2.SetAmount(dinfo.Amount / num3); this.ApplyDamageToPart(dinfo2, pawn, ref result); } } else { this.ApplyDamageToPart(dinfo, pawn, ref result); this.CheckDuplicateSmallPawnDamageToPartParent(dinfo, pawn, ref result); } if (result.wounded) { DamageWorker_AddInjury.PlayWoundedVoiceSound(dinfo, pawn); pawn.Drawer.Notify_DamageApplied(dinfo); DamageWorker_AddInjury.InformPsychology(dinfo, pawn); } if (result.headshot && pawn.Spawned) { IntVec3 position = pawn.Position; double x = (float)position.x + 1.0; IntVec3 position2 = pawn.Position; float y = (float)position2.y; IntVec3 position3 = pawn.Position; MoteMaker.ThrowText(new Vector3((float)x, y, (float)((float)position3.z + 1.0)), pawn.Map, "Headshot".Translate(), Color.white, -1f); if (dinfo.Instigator != null) { Pawn pawn2 = dinfo.Instigator as Pawn; if (pawn2 != null) { pawn2.records.Increment(RecordDefOf.Headshots); } } } if (result.deflected) { if (pawn.health.deflectionEffecter == null) { pawn.health.deflectionEffecter = EffecterDefOf.ArmorDeflect.Spawn(); } pawn.health.deflectionEffecter.Trigger(pawn, pawn); } else if (spawnedOrAnyParentSpawned) { ImpactSoundUtility.PlayImpactSound(pawn, dinfo.Def.impactSoundType, mapHeld); } return(result); }
public int TryTransferToContainer(Thing item, ThingOwner otherContainer, int count, out Thing resultingTransferredItem, bool canMergeWithExistingStacks = true) { if (!this.Contains(item)) { Log.Error(string.Concat(new object[] { "Can't transfer item ", item, " because it's not here. owner=", this.owner.ToStringSafe <IThingHolder>() }), false); resultingTransferredItem = null; return(0); } if (otherContainer == this && count > 0) { resultingTransferredItem = item; return(item.stackCount); } if (!otherContainer.CanAcceptAnyOf(item, canMergeWithExistingStacks)) { resultingTransferredItem = null; return(0); } if (count <= 0) { resultingTransferredItem = null; return(0); } if (this.owner is Map || otherContainer.owner is Map) { Log.Warning("Can't transfer items to or from Maps directly. They must be spawned or despawned manually. Use TryAdd(item.SplitOff(count))", false); resultingTransferredItem = null; return(0); } int num = Mathf.Min(item.stackCount, count); Thing thing = item.SplitOff(num); if (this.Contains(thing)) { this.Remove(thing); } bool flag = otherContainer.TryAdd(thing, canMergeWithExistingStacks); if (flag) { resultingTransferredItem = thing; return(thing.stackCount); } resultingTransferredItem = null; if (!otherContainer.Contains(thing) && thing.stackCount > 0 && !thing.Destroyed) { int result = num - thing.stackCount; if (item != thing) { item.TryAbsorbStack(thing, false); } else { this.TryAdd(thing, false); } return(result); } return(thing.stackCount); }
public int TryTransferToContainer(Thing item, ThingOwner otherContainer, int count, bool canMergeWithExistingStacks = true) { Thing thing; return(this.TryTransferToContainer(item, otherContainer, count, out thing, canMergeWithExistingStacks)); }
public bool TryTransferToContainer(Thing item, ThingOwner otherContainer, bool canMergeWithExistingStacks = true) { return(this.TryTransferToContainer(item, otherContainer, item.stackCount, canMergeWithExistingStacks) == item.stackCount); }