public virtual bool TryAcceptThing(Thing thing, bool allowSpecialEffects = true) { if (!this.Accepts(thing)) { return(false); } if (thing is Pawn) { Pawn pawn = thing as Pawn; if (pawn.def.race.Humanlike) { if (!DropShipUtility.HasPassengerSeats(this)) { Messages.Message("MessagePassengersFull".Translate(new object[] { pawn.NameStringShort, this.ShipNick }), this, MessageTypeDefOf.RejectInput); return(false); } if (pawn.Spawned) { pawn.DeSpawn(); } if (!this.innerContainer.Contains(pawn)) { //pawn.InContainerEnclosed this.innerContainer.TryAdd(pawn, 1, false); } } else { if (this.innerContainer.TryAdd(thing.SplitOff(thing.stackCount), true)) { return(true); } else { return(false); } } } bool flag; if (thing.holdingOwner != null) { flag = thing.holdingOwner.TryTransferToContainer(thing, this.innerContainer); } else { flag = this.innerContainer.TryAdd(thing.SplitOff(thing.stackCount), true); } if (flag) { return(true); } return(false); }
public Thing FindShip(Pawn pawn) { List <ShipBase> allShips = DropShipUtility.ShipsOnMap(pawn.Map).FindAll(x => DropShipUtility.HasPassengerSeats(x) && x.Faction == pawn.Faction); if (allShips.NullOrEmpty()) { return(null); } return(allShips.RandomElement()); }
public Thing FindShip(Pawn pawn) { List <ShipBase> allShips = DropShipUtility.ShipsOnMap(pawn.Map).FindAll(x => DropShipUtility.HasPassengerSeats(x)); if (allShips.NullOrEmpty()) { return(null); } ShipBase ship = null; Log.Message(allShips.Count.ToString()); return(allShips.RandomElement()); //if (allShips.TryRandomElementByWeight<ShipBase>((ShipBase x) => 100 / x.Position.DistanceToSquared(pawn.Position), out ship)) //{ // Log.Message("Found"); // return ship; //} //else //{ // Log.Message("NotFoundShips"); // return null; //} }