private static readonly string txtRecruitSuccess = "MessageRecruitSuccess".Translate(); // from core #endregion Fields #region Methods public static bool TryGuestImproveRelationship(Pawn recruiter, Pawn guest) { if (recruiter == null || guest == null || guest.guest == null) return false; recruiter.skills.Learn(SkillDefOf.Social, 25f); float chance = recruiter.GetStatValue(statOffendGuestChance); bool result = false; if (Rand.Value <= chance) { //Log.Message("textAnger"); Messages.Message(string.Format(txtImproveFactionAnger, recruiter.Nickname, guest.Faction.name, chance.ToStringPercent()), MessageSound.Negative); float impact = -(Rand.Range(3, 8) * (1 - 0.0375f * recruiter.skills.GetSkill(SkillDefOf.Social).level)); //Social skill level 20 reduces negative impact by 75%, Skilllevel 0 results in full impact; linear guest.Faction.AffectGoodwillWith(Faction.OfColony, impact); guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestOffendedRelationship")); //Log.Message("Goodwill changed by : " + impact); } else { //Log.Message("textPlease"); Messages.Message(string.Format(txtImproveFactionPlease, recruiter.Nickname, guest.Faction.name, (1 - chance).ToStringPercent()), MessageSound.Benefit); guest.Faction.AffectGoodwillWith(Faction.OfColony, 0.1f + 0.045f * recruiter.skills.GetSkill(SkillDefOf.Social).level); //Social skilllevel 20 results in +1 relationship, Skilllevel 0 results in +0.1 change, linear guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestPleasedRelationship")); result = true; //Log.Message("Goodwill changed by : " + (0.1f + 0.05f * recruiter.skills.GetSkill(SkillDefOf.Social).level)); } if (Rand.Value <= GuestUtility.GetDismissiveChance(guest)) { //Log.Message("DismissiveChance SUCCESS - " + guest.Name + " will not talk with you for a while!"); //Message einbauen guest.needs.mood.thoughts.TryGainThought(ThoughtDef.Named("GuestDismissiveAttitude")); } //else Log.Message("DismissiveChance FAILED - " + guest.Name + " will continue to talk with you!"); return result; }
public static Thing FindFreeSupplyShipCryptosleepBay(Pawn rescuer) { List<Thing> leftBaysList = Find.ListerThings.ThingsOfDef(OG_Util.SupplyShipCryptosleepBayLeftDef); for (int bayIndex = 0; bayIndex < leftBaysList.Count; bayIndex++) { Thing potentialBay = leftBaysList[bayIndex]; if ((potentialBay.Faction != null) && (potentialBay.Faction == rescuer.Faction)) { Building_SupplyShipCryptosleepBay bay = potentialBay as Building_SupplyShipCryptosleepBay; if ((bay.GetContainer().Count == 0) && (rescuer.CanReserveAndReach(bay, PathEndMode.InteractionCell, Danger.Deadly))) { return bay; } } } List<Thing> rightBaysList = Find.ListerThings.ThingsOfDef(OG_Util.SupplyShipCryptosleepBayRightDef); for (int bayIndex = 0; bayIndex < rightBaysList.Count; bayIndex++) { Thing potentialBay = rightBaysList[bayIndex]; if ((potentialBay.Faction != null) && (potentialBay.Faction == rescuer.Faction)) { Building_SupplyShipCryptosleepBay bay = potentialBay as Building_SupplyShipCryptosleepBay; if ((bay.GetContainer().Count == 0) && (rescuer.CanReserveAndReach(bay, PathEndMode.InteractionCell, Danger.Deadly))) { return bay; } } } return null; }
public static void PawnSpawned(Pawn pawn) { if( OnPawnSpawned != null ) { OnPawnSpawned(pawn); } }
protected override ThoughtState CurrentStateInternal( Pawn p ) { return( ( p.IsPrisonerOfColony )&& ( !p.IsSlaveOfColony() ) ); }
public override Job JobOnThing( Pawn pawn, Thing t ) { if( !pawn.CanReserveAndReach( ( TargetInfo )t.Position, PathEndMode.Touch, DangerUtility.NormalMaxDanger( pawn ), 1 ) ) { return (Job) null; } var hopperSgp = t as ISlotGroupParent; if( hopperSgp == null ) { return (Job) null; } var resource = HopperGetCurrentResource( t.Position, hopperSgp ); if( ( resource == null )|| ( resource.stackCount <= ( resource.def.stackLimit / 2 ) ) ) { return WorkGiver_FillHopper.HopperFillJob( pawn, hopperSgp, resource ); } JobFailReason.Is( "AlreadyFilledLower".Translate() ); return (Job) null; }
public static void PawnDead(Pawn pawn) { if( OnPawndead != null ) { OnPawndead(pawn); } }
public static void PawnDestroyed(Pawn pawn) { if( OnPawnDestroyed != null ) { OnPawnDestroyed(pawn); } }
public static void AttackStateStart(Pawn pawn) { if( OnAttackStateStart != null ) { OnAttackStateStart(pawn); } }
public static void CurrentEnemyUnset(Pawn pawn) { if( OnCurrentEnemyUnset != null ) { OnCurrentEnemyUnset(pawn); } }
public virtual void EjectContents() { foreach (Thing current in this.container.Contents) { Pawn pawn = current as Pawn; if (pawn != null) { if (pawn.health.hediffSet.HasHediff(HediffDefOf.Hypothermia)) { Hediff hypo = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Hypothermia); pawn.health.hediffSet.HealHediff(hypo, 1); } if (pawn.health.hediffSet.HasHediff(HediffDefOf.Heatstroke)) { Hediff hypo = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.Heatstroke); pawn.health.hediffSet.HealHediff(hypo, 1); } //pawn.needs.mood.thoughts.DistinctThoughtDefs.Clear(); } } ReEnterCouter = 100; this.container.TryDropAll(this.InteractionCell, ThingPlaceMode.Direct); if (!base.Destroyed) { SoundDef.Named("CryptosleepCasketEject").PlayOneShot(SoundInfo.InWorld(base.Position, MaintenanceType.None)); } InContainer = null; }
public static void AttackStateEnd(Pawn pawn) { if( OnAttackStateEnd != null ) { OnAttackStateEnd(pawn); } }
public override bool HasJobOnThing(Pawn pawn, Thing t) { Fire fire = t as Fire; if (fire == null) { return false; } Area outpostArea = OG_Util.FindOutpostArea(); Pawn pawn2 = fire.parent as Pawn; if (pawn2 != null) { if (pawn2 == pawn) { return false; } if ((pawn2.Faction == pawn.Faction || pawn2.HostFaction == pawn.Faction || pawn2.HostFaction == pawn.HostFaction) && ((outpostArea == null) || (outpostArea.ActiveCells.Contains(t.Position) == false)) && IntVec3Utility.ManhattanDistanceFlat(pawn.Position, pawn2.Position) > 15) { return false; } } else if ((outpostArea == null) || (outpostArea.ActiveCells.Contains(t.Position) == false)) { return false; } return ((pawn.Position - fire.Position).LengthHorizontalSquared <= 225f || pawn.CanReserve(fire, 1)) && !WorkGiver_FightFiresOutpost.FireIsBeingHandled(fire, pawn); }
// disable initial readyness for trade and remove all but one muffalo, transferring all goods there public void ModifycaravanGroup(ref List<Pawn> pawns) { var muffaloChosen = false; var firstMuffalo = new Pawn(); var removeList = new List<Pawn>(); foreach (var pawn in pawns) { // disable initial readyness to trade pawn.mindState.wantsToTradeWithColony = false; // transfer all items from other muffaloes to the main one if (pawn.kindDef == PawnKindDef.Named("PackMuffalo")) { if (!muffaloChosen) { firstMuffalo = pawn; muffaloChosen = true; } else { for (var i = 0; i < pawn.inventory.container.Count; i++) { firstMuffalo.inventory.container.TryAdd(pawn.inventory.container[i]); } pawn.Destroy(); removeList.Add(pawn); } } } pawns = new List<Pawn>(pawns.Except(removeList)); }
public static Toil SipWater(Pawn drinker, Need_Water pawnNeed, CompWaterContainer waterContainer, bool wornByActor) { var toil = new Toil(); toil.defaultCompleteMode = ToilCompleteMode.Delay; toil.defaultDuration = sipTicks; toil.initAction = delegate { bool fromThing = toil.actor.jobs.curJob.GetTarget(TargetIndex.A).HasThing; if (fromThing) { toil.FailOnForbidden(TargetIndex.A); if (!wornByActor) { toil.FailOnDespawned(TargetIndex.A); } } float wantDrink = Math.Min(pawnNeed.HydrationWantedLitres, sipLitres); float didDrink = pawnNeed.DrinkFrom(waterContainer, wantDrink); }; toil.FailOn(() => waterContainer.IsEmpty); // TODO: toil.WithEffect(); toil.WithSustainer(delegate { if (drinker.RaceProps.Humanlike) { return DefDatabase<SoundDef>.GetNamed(drinkSoundName); } return null; }); return toil; }
// logic for accepting pawn by bodysize // RimWorld.Building_CryptosleepCasket public static new Building_CryptosleepCasket FindCryptosleepCasketFor(Pawn p, Pawn traveler) { try { IEnumerable<ThingDef> enumerable = from def in DefDatabase<ThingDef>.AllDefs where typeof(Fluffy.Building_CryptosleepCasket).IsAssignableFrom(def.thingClass) select def; foreach (ThingDef current in enumerable) { Predicate<Thing> validator = (Thing x) => ((Building_CryptosleepCasket)x).GetContainer().Count == 0 && ((Building_CryptosleepCasket)x).TryGetComp<CompAnimalCrypto>().props.maxSizeAllowance >= traveler.BodySize; Building_CryptosleepCasket building_CryptosleepCasket = (Building_CryptosleepCasket)GenClosest.ClosestThingReachable(p.Position, ThingRequest.ForDef(current), PathEndMode.InteractionCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, null, -1, false); if (building_CryptosleepCasket != null) { return building_CryptosleepCasket; } } return null; } finally { #if DEBUG Log.Message("Something odd happened."); #endif } }
public override bool HasJobOnThing( Pawn pawn, Thing thing ) { if ( thing.Faction != pawn.Faction ) return false; if ( pawn.Faction == Faction.OfColony && !Find.AreaHome[thing.Position] ) return false; if ( thing.IsBurning() ) return false; if ( Find.DesignationManager.DesignationOn( thing, DesignationDefOf.Deconstruct ) != null ) return false; ThingWithComps twc = thing as ThingWithComps; if ( twc == null ) return false; var comp = twc.TryGetComp<CompBreakdownable>(); if ( comp == null ) return false; if ( !MapComponent_Durability.RequiresMaintenance( comp ) ) return false; if ( !pawn.CanReserveAndReach( thing, PathEndMode.Touch, pawn.NormalMaxDanger() ) ) return false; return true; }
/** * Event: Interact */ public void OnInteract(Pawn pawn = null) { if(this.conversation.Value != null) { ConversationManager.StartConversation(this.conversation.Value); } }
public Dialog_RenamePet(Pawn pet) { _pet = pet; _curName = pet.Name.ToString(); closeOnEscapeKey = true; absorbInputAroundWindow = true; }
public override bool filter(Pawn p) { if (state == FilterType.None) return true; if (state == FilterType.False && p.gender == Gender.Male) return true; if (state == FilterType.True && p.gender == Gender.Female) return true; return false; }
public static Corpse FindClosestCorpseFor(Predicate<Thing> pred, Pawn getter) { Predicate<Thing> predicate1 = (Thing c) => !c.IsForbidden(Faction.OfColony) && getter.AwareOf(c) && getter.CanReserve(c); Predicate<Thing> predicate = (Thing t) => pred(t) && predicate1(t); ThingRequest thingReq = ThingRequest.ForGroup(ThingRequestGroup.Corpse); return (Corpse)GenClosest.ClosestThingReachable(getter.Position, thingReq, PathEndMode.ClosestTouch, TraverseParms.For(getter), 9999f, predicate, null); }
public void UsedBy(Pawn pawn) { Find.ResearchManager.currentProj = researchDef; Find.ResearchManager.InstantFinish(Find.ResearchManager.currentProj); Destroy(); }
public override Job JobOnThing( Pawn pawn, Thing t ) { var warden = pawn; var slave = t as Pawn; if( ( slave == null )|| ( slave.guest == null )|| ( slave.guest.interactionMode != Data.PIM.FreeSlave )|| ( slave.Downed )|| ( !slave.Awake() )|| ( !warden.CanReserveAndReach( slave, PathEndMode.ClosestTouch, warden.NormalMaxDanger(), 1 ) ) ) { return null; } var collar = slave.WornCollar(); if( collar == null ) { // Slave isn't wearing a collar, wut? return null; } IntVec3 result; if( !RCellFinder.TryFindPrisonerReleaseCell( slave, warden, out result ) ) { return null; } var job = new Job( Data.JobDefOf.FreeSlave, slave, collar, result ); job.maxNumToCarry = 1; return job; }
public override bool ActualUse(Pawn target) { foreach (AmmoBoxPicker abp in ammoList) { target.GetComponent<InventoryManager> ().AddAmmo (abp.ammo, abp.amount); } return base.ActualUse(target); }
public override bool BlocksPawn( Pawn p ) { if( isOpen ) return false; else return !WillOpenFor(p); }
public override Job JobOnThing(Pawn pawn, Thing t) { Building_RepairStation rps = ListerDroids.ClosestRepairStationFor(pawn,t); Job job = new Job(ReactivateDroidJobDef, t, rps); job.maxNumToCarry = 1; return job; }
public override bool HasJobOnThing(Pawn pawn, Thing t) { if ((t is Building_AquacultureBasin) == false) { return false; } Building_AquacultureBasin aquacultureBasin = t as Building_AquacultureBasin; if (pawn.Dead || pawn.Downed || pawn.IsBurning()) { return false; } if (pawn.CanReserveAndReach(aquacultureBasin, this.PathEndMode, Danger.Some) == false) { return false; } if (aquacultureBasin.breedingIsFinished) { return true; } return false; }
// search things throught designations is faster than searching designations through all things public static List<TargetInfo> AvailableTargets(Pawn pawn) { return Find.ListerThings.AllThings.FindAll(thing => thing is Frame) .Where(thing => thing.Faction == pawn.Faction && GenConstruct.CanConstruct(thing, pawn) && (thing as Frame).MaterialsNeeded().Count == 0 && pawn.CanReserveAndReach(thing, PathEndMode.Touch, pawn.NormalMaxDanger())).Select(thing => new TargetInfo(thing)).ToList(); }
public static Building_MAD FindMADFor(Pawn sleeper, Pawn traveler, bool sleeperWillBePrisoner, bool checkSocialProperness, bool forceCheckMedBed = false) { Predicate<Thing> MADValidator = delegate(Thing t) { if (!traveler.CanReserveAndReach(t, PathEndMode.OnCell, Danger.Some, 1)) { return false; } Building_MAD Building_MAD3 = (Building_MAD)t; if (Building_MAD3.HasAnyContents) { return false; } else { if (Building_MAD3.Faction != traveler.Faction) { return false; } } return (!Building_MAD3.IsForbidden(traveler) && !Building_MAD3.IsBurning()); }; Predicate<Thing> validator = (Thing b) => MADValidator(b); Building_MAD building_MAD = (Building_MAD)GenClosest.ClosestThingReachable(sleeper.Position, ThingRequest.ForDef(DefDatabase<ThingDef>.GetNamed("MindAlteringDevice")), PathEndMode.OnCell, TraverseParms.For(traveler, Danger.Deadly, TraverseMode.ByPawn, false), 9999f, validator, null, -1, false); if (building_MAD != null) { return building_MAD; } return null; }
public override Job NonScanJob(Pawn pawn) { if (ToolsForHaulUtility.TryGetBackpack(pawn) != null) return ToolsForHaulUtility.HaulWithTools(pawn); JobFailReason.Is(NoBackpack); return (Job)null; }
protected override Job TryGiveTerminalJob(Pawn pawn) { Pawn mindStateTarget = pawn.mindState.enemyTarget as Pawn; if (mindStateTarget == null) { return null; } // Check if target is still valid if (mindStateTarget.Destroyed || mindStateTarget.Downed || Find.TickManager.TicksGame - pawn.mindState.lastEngageTargetTick > EnemyForgetTime || (pawn.Position - mindStateTarget.Position).LengthHorizontalSquared > (MaxSearchDistance * MaxSearchDistance) || !GenSight.LineOfSight(pawn.Position, mindStateTarget.Position, false)) { pawn.mindState.enemyTarget = null; return null; } if (pawn.story != null && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) { return null; } Job job = new Job(JobDefOf.AttackMelee, mindStateTarget) { maxNumMeleeAttacks = 1, expiryInterval = Rand.Range(EnemyForgetTime, MaxMeleeChaseTicksMax) }; return job; }
public override void DoEffect(Pawn user) { ThingDef tempPod = null; IntVec3 currentPos = parent.PositionHeld; Map map = parent.Map; CompAbilityUserMagic comp = user.TryGetComp <CompAbilityUserMagic>(); if (parent.def != null && comp != null && comp.customClass != null) { if (comp.customClass.tornScript != null) { tempPod = comp.customClass.tornScript; } else { tempPod = comp.customClass.fullScript; } this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.InnerFire)) { tempPod = ThingDef.Named("Torn_BookOfInnerFire"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.HeartOfFrost)) { tempPod = ThingDef.Named("Torn_BookOfHeartOfFrost"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.StormBorn)) { tempPod = ThingDef.Named("Torn_BookOfStormBorn"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Arcanist)) { tempPod = ThingDef.Named("Torn_BookOfArcanist"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Paladin)) { tempPod = ThingDef.Named("Torn_BookOfValiant"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Summoner)) { tempPod = ThingDef.Named("Torn_BookOfSummoner"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Druid)) { tempPod = ThingDef.Named("Torn_BookOfNature"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Necromancer) || user.story.traits.HasTrait(TorannMagicDefOf.Lich))) { tempPod = ThingDef.Named("Torn_BookOfUndead"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Priest)) { tempPod = ThingDef.Named("Torn_BookOfPriest"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.TM_Bard)) { tempPod = ThingDef.Named("Torn_BookOfBard"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.Succubus) || user.story.traits.HasTrait(TorannMagicDefOf.Warlock))) { tempPod = ThingDef.Named("Torn_BookOfDemons"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Geomancer)) { tempPod = ThingDef.Named("Torn_BookOfEarth"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Technomancer)) { tempPod = TorannMagicDefOf.Torn_BookOfMagitech; this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.BloodMage)) { tempPod = TorannMagicDefOf.Torn_BookOfHemomancy; this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Enchanter)) { tempPod = TorannMagicDefOf.Torn_BookOfEnchanter; this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.Chronomancer)) { tempPod = TorannMagicDefOf.Torn_BookOfChronomancer; this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && user.story.traits.HasTrait(TorannMagicDefOf.ChaosMage)) { tempPod = TorannMagicDefOf.Torn_BookOfChaos; this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else if (parent.def != null && (user.story.traits.HasTrait(TorannMagicDefOf.TM_Gifted) || user.story.traits.HasTrait(TorannMagicDefOf.TM_Wanderer))) { tempPod = ThingDef.Named("BookOfQuestion"); this.parent.SplitOff(1).Destroy(DestroyMode.Vanish); } else { Messages.Message("NotGiftedPawn".Translate( user.LabelShort ), MessageTypeDefOf.RejectInput); } if (tempPod != null) { SihvSpawnThings.SpawnThingDefOfCountAt(tempPod, 1, new TargetInfo(currentPos, map)); } }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { return(JobMaker.MakeJob(JobDefOf.OperateScanner, t, 1500, checkOverrideOnExpiry: true)); }
public override Danger MaxPathDanger(Pawn pawn) { return(Danger.Deadly); }
void Update() { if (_uiInvalid) { updateUI(_initialUpdateUI); _uiInvalid = false; _initialUpdateUI = false; } if (_paused) { return; } if (_gameState == GameState.WaitingPutPawn) { bool waitInput = false; if (_turn == Side.Opposite) { if (_waitingForOppoSide) { return; } stepBegin(); if (_gameMode == GameMode.AI) { performAIMove(); } else if (_gameMode == GameMode.Self){ waitInput = true; } } else { waitInput = true; } if (waitInput) { if (_pawns.Count == 0) { stepEnd(); return; } else if (_pawns.Count >= _grids.Length) { gameOver(); return; } if (Input.GetMouseButtonDown(0)) { Vector2 gridIndice; if (_chessBoard.getGridIndexByScreenPosition(Input.mousePosition, out gridIndice)) { Pawn pawn = getPawnAtPos((int)gridIndice.x, (int)gridIndice.y); Debug.Log("select grid pos " + gridIndice + ", pawn" + pawn); if (pawn != null) { if (_selectingPawn == pawn) { if (!_selectingPawn.dragging) { _selectingPawn.selected = false; _selectingPawn = null; } } else { if (_selectingPawn != null) { _selectingPawn.selected = false; _selectingPawn.dragging = true; } _selectingPawn = pawn; _selectingPawn.selected = true; _selectingPawn.dragging = true; _selectTimeStamp = Time.time; SoundHub.instance().play("MoveBegin"); } } else { putSelectingPawn(gridIndice); } } else { if (_selectingPawn != null) { _selectingPawn.selected = false; _selectingPawn.dragging = false; _selectingPawn = null; } } } else if (Input.GetMouseButton(0)) { if (Time.time - _selectTimeStamp < 0.1) { return; } if (_selectingPawn != null && _selectingPawn.dragging) { Vector3 posInBoard = _chessBoard.screenPosToPosInBoard(Input.mousePosition); posInBoard.z = 0; _selectingPawn.setLocalPosition(posInBoard); } } else if (Input.GetMouseButtonUp(0)) { if (_selectingPawn != null && _selectingPawn.dragging) { Vector2 gridIndice; if (_chessBoard.getGridIndexByScreenPosition(Input.mousePosition, out gridIndice)) { Pawn pawn = getPawnAtPos((int)gridIndice.x, (int)gridIndice.y); if (pawn != null) { cancelDrag(); } else { putSelectingPawn(gridIndice); } } else { cancelDrag(); } } } } } else if (_gameState == GameState.SelectingPawnToTrash) { if (Input.GetMouseButtonDown(0)) { Vector2 gridIndice; if (_chessBoard.getGridIndexByScreenPosition(Input.mousePosition, out gridIndice)) { Pawn pawn = getPawnAtPos((int)gridIndice.x, (int)gridIndice.y); if (pawn != null) { if (_selectingPawn == pawn) { if (!_selectingPawn.dragging) { _selectingPawn.selected = false; _selectingPawn = null; } } else { if (_selectingPawn != null) { _selectingPawn.selected = false; _selectingPawn.dragging = true; } _selectingPawn = pawn; _selectingPawn.selected = true; _selectingPawn.dragging = true; _selectTimeStamp = Time.time; SoundHub.instance().play("MoveBegin"); } } } else if (_selectingPawn != null) { putPawnToTrash(); } } else if (Input.GetMouseButton(0)) { if (Time.time - _selectTimeStamp < 0.1) { return; } if (_selectingPawn != null && _selectingPawn.dragging) { Vector3 posInBoard = _chessBoard.screenPosToPosInBoard(Input.mousePosition); posInBoard.z = 0; _selectingPawn.setLocalPosition(posInBoard); } } else if (Input.GetMouseButtonUp(0)) { if (_selectingPawn != null && _selectingPawn.dragging) { Vector2 gridIndice; if (_chessBoard.getGridIndexByScreenPosition(Input.mousePosition, out gridIndice)) { cancelDrag(); } else { putPawnToTrash(); } } } } else if (_gameState == GameState.GameOver) { } }
public override bool ShouldSkip(Pawn pawn, bool forced = false) { return(pawn.Map.areaManager.SnowClear.TrueCount == 0); }
public override IEnumerable <IntVec3> PotentialWorkCellsGlobal(Pawn pawn) { return(pawn.Map.areaManager.SnowClear.ActiveCells); }
public static bool IsValidMarriageSpotFor(IntVec3 cell, Pawn firstFiance, Pawn secondFiance, StringBuilder outFailReason = null) { if (!firstFiance.Spawned || !secondFiance.Spawned) { Log.Warning("Can't check if a marriage spot is valid because one of the fiances isn't spawned."); return(false); } if (firstFiance.Map != secondFiance.Map) { return(false); } if (!MarriageSpotUtility.IsValidMarriageSpot(cell, firstFiance.Map, outFailReason)) { return(false); } if (!cell.Roofed(firstFiance.Map)) { if (!JoyUtility.EnjoyableOutsideNow(firstFiance, outFailReason)) { return(false); } if (!JoyUtility.EnjoyableOutsideNow(secondFiance, outFailReason)) { return(false); } } if (cell.GetDangerFor(firstFiance, firstFiance.Map) != Danger.None) { if (outFailReason != null) { outFailReason.Append("MarriageSpotDangerous".Translate(new object[] { firstFiance.LabelShort })); } return(false); } if (cell.GetDangerFor(secondFiance, secondFiance.Map) != Danger.None) { if (outFailReason != null) { outFailReason.Append("MarriageSpotDangerous".Translate(new object[] { secondFiance.LabelShort })); } return(false); } if (cell.IsForbidden(firstFiance)) { if (outFailReason != null) { outFailReason.Append("MarriageSpotForbidden".Translate(new object[] { firstFiance.LabelShort })); } return(false); } if (cell.IsForbidden(secondFiance)) { if (outFailReason != null) { outFailReason.Append("MarriageSpotForbidden".Translate(new object[] { secondFiance.LabelShort })); } return(false); } if (!firstFiance.CanReserve(cell, 1, -1, null, false) || !secondFiance.CanReserve(cell, 1, -1, null, false)) { if (outFailReason != null) { outFailReason.Append("MarriageSpotReserved".Translate()); } return(false); } if (!firstFiance.CanReach(cell, PathEndMode.OnCell, Danger.None, false, TraverseMode.ByPawn)) { if (outFailReason != null) { outFailReason.Append("MarriageSpotUnreachable".Translate(new object[] { firstFiance.LabelShort })); } return(false); } if (!secondFiance.CanReach(cell, PathEndMode.OnCell, Danger.None, false, TraverseMode.ByPawn)) { if (outFailReason != null) { outFailReason.Append("MarriageSpotUnreachable".Translate(new object[] { secondFiance.LabelShort })); } return(false); } if (!firstFiance.IsPrisoner && !secondFiance.IsPrisoner) { Room room = cell.GetRoom(firstFiance.Map, RegionType.Set_Passable); if (room != null && room.isPrisonCell) { if (outFailReason != null) { outFailReason.Append("MarriageSpotInPrisonCell".Translate()); } return(false); } } return(true); }
public static bool IsClean(Pawn pawn, BodyPartRecord part) { return(!pawn.Dead && !(from x in pawn.health.hediffSet.hediffs where x.Part == part select x).Any()); }
public static bool CanDeploy(Pawn pawn, IShield shield) { return(pawn.RaceProps.baseBodySize >= shield.DeploymentSize); }
public override string GetLabelWhenUsedOn(Pawn pawn, BodyPartRecord part) { return(recipe.LabelCap + " (" + BloodTypeUtility.BloodType(pawn).GetLabel() + ")" + ((BloodItemUtility.ExtractionWillKill(pawn, BloodExtractType.Wine)) ? " (" + ("ROMV_DeadlyOperationShort".Translate()).RawText + ")" : "")); }
protected override void Notify_DesignationAdded(Pawn pawn) { SlaughterDesignatorUtility.CheckWarnAboutBondedAnimal(pawn); }
/// <summary> /// Checks for cover along the flight path of the bullet, doesn't check for walls or trees, only intended for cover with partial fillPercent /// </summary> /// <param name="target">The target of which to find cover of</param> /// <param name="cover">Output parameter, filled with the highest cover object found</param> /// <returns>True if cover was found, false otherwise</returns> private bool GetHighestCoverAndSmokeForTarget(LocalTargetInfo target, out Thing cover, out float smokeDensity) { Map map = caster.Map; Thing targetThing = target.Thing; Thing highestCover = null; float highestCoverHeight = 0f; smokeDensity = 0; // Iterate through all cells on line of sight and check for cover and smoke var cells = GenSight.PointsOnLineOfSight(target.Cell, caster.Position).ToArray(); if (cells.Length < 3) { cover = null; return(false); } for (int i = 0; i <= cells.Length / 2; i++) { var cell = cells[i]; if (cell.AdjacentTo8Way(caster.Position)) { continue; } // Check for smoke var gas = cell.GetGas(map); if (gas != null) { smokeDensity += gas.def.gas.accuracyPenalty; } // Check for cover in the second half of LoS if (i <= cells.Length / 2) { Pawn pawn = cell.GetFirstPawn(map); Thing newCover = pawn == null?cell.GetCover(map) : pawn; float newCoverHeight = new CollisionVertical(newCover).Max; // Cover check, if cell has cover compare collision height and get the highest piece of cover, ignore if cover is the target (e.g. solar panels, crashed ship, etc) if (newCover != null && (targetThing == null || !newCover.Equals(targetThing)) && (highestCover == null || highestCoverHeight < newCoverHeight) && newCover.def.Fillage == FillCategory.Partial && !newCover.IsPlant()) { highestCover = newCover; highestCoverHeight = newCoverHeight; if (Controller.settings.DebugDrawTargetCoverChecks) { map.debugDrawer.FlashCell(cell, highestCoverHeight, highestCoverHeight.ToString()); } } } } cover = highestCover; //Report success if found cover return(cover != null); }
protected override string GetTip(Pawn pawn) { return("DesignatorSlaughterDesc".Translate()); }
//ERROR MESSAGES public void Error_TriedDecayNullRelationship(Pawn pawn, Pawn other, PawnRelationDef pawnRelationDef) { this.Logger.Error("Tried to decay a null relationship {2} between {0} and {1}".Formatted(pawn.Name.ToStringShort, other.Name.ToStringShort, pawnRelationDef.defName)); }
public virtual void PrePreTraded(TradeAction action, Pawn playerNegotiator, ITrader trader) { }
protected override bool HasCheckbox(Pawn pawn) { return(pawn.RaceProps.Animal && pawn.RaceProps.IsFlesh && pawn.Faction == Faction.OfPlayer && pawn.SpawnedOrAnyParentSpawned); }
private static bool <ExposeData> m__0(Pawn x) { return(x.Destroyed); }
public virtual void PostIngested(Pawn ingester) { }
public void addPawnOwnership(Pawn pawn) { pawns.Add(pawn); pawn.setCurrentChunk(this); }
public virtual IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn selPawn) { yield break; }
public static void EatVirtualPlants(Pawn p) { float num = ThingDefOf.Plant_Grass.GetStatValueAbstract(StatDefOf.Nutrition) * VirtualPlantNutritionRandomFactor.RandomInRange; p.needs.food.CurLevel += num; }
public void removePawnOwnership(Pawn pawn) { pawns.Remove(pawn); pawn.setCurrentChunk(null); }
public static bool CanEatVirtualPlantsNow(Pawn p) { return(CanEatVirtualPlants(p, GenTicks.TicksAbs)); }
public BattleLogEntry_DamageTaken(Pawn recipient, RulePackDef ruleDef, Pawn initiator = null) { initiatorPawn = initiator; recipientPawn = recipient; this.ruleDef = ruleDef; }
internal bool <> m__0(Thing t) { Pawn pawn = (Pawn)t; return(pawn.Downed && pawn.Faction == this.pawn.Faction && !pawn.InBed() && this.pawn.CanReserve(pawn, 1, -1, null, false) && !pawn.IsForbidden(this.pawn) && !GenAI.EnemyIsNear(pawn, 25f)); }
public static bool CanEatVirtualPlants(Pawn p, int ticksAbs) { return(p.Tile >= 0 && !p.Dead && p.IsWorldPawn() && CanEverEatVirtualPlants(p) && EnvironmentAllowsEatingVirtualPlantsAt(p.Tile, ticksAbs)); }
public virtual bool InspirationCanOccur(Pawn pawn) { if (!this.def.allowedOnAnimals && pawn.RaceProps.Animal) { return(false); } if (!this.def.allowedOnNonColonists && !pawn.IsColonist) { return(false); } if (this.def.requiredNonDisabledStats != null) { for (int i = 0; i < this.def.requiredNonDisabledStats.Count; i++) { if (this.def.requiredNonDisabledStats[i].Worker.IsDisabledFor(pawn)) { return(false); } } } if (this.def.requiredSkills != null) { for (int j = 0; j < this.def.requiredSkills.Count; j++) { if (!this.def.requiredSkills[j].PawnSatisfies(pawn)) { return(false); } } } if (!this.def.requiredAnySkill.NullOrEmpty <SkillRequirement>()) { bool flag = false; for (int k = 0; k < this.def.requiredAnySkill.Count; k++) { if (this.def.requiredAnySkill[k].PawnSatisfies(pawn)) { flag = true; break; } } if (!flag) { return(false); } } if (this.def.requiredNonDisabledWorkTypes != null) { for (int l = 0; l < this.def.requiredNonDisabledWorkTypes.Count; l++) { if (pawn.story == null || pawn.story.WorkTypeIsDisabled(this.def.requiredNonDisabledWorkTypes[l])) { return(false); } } } if (!this.def.requiredAnyNonDisabledWorkType.NullOrEmpty <WorkTypeDef>()) { bool flag2 = false; for (int m = 0; m < this.def.requiredAnyNonDisabledWorkType.Count; m++) { if (pawn.story != null && !pawn.story.WorkTypeIsDisabled(this.def.requiredAnyNonDisabledWorkType[m])) { flag2 = true; break; } } if (!flag2) { return(false); } } if (this.def.requiredCapacities != null) { for (int n = 0; n < this.def.requiredCapacities.Count; n++) { if (!pawn.health.capacities.CapableOf(this.def.requiredCapacities[n])) { return(false); } } } if (pawn.story != null) { for (int num = 0; num < pawn.story.traits.allTraits.Count; num++) { Trait trait = pawn.story.traits.allTraits[num]; if (trait.CurrentData.disallowedInspirations != null && trait.CurrentData.disallowedInspirations.Contains(this.def)) { return(false); } } } return(true); }
public static bool CanEverEatVirtualPlants(Pawn p) { return(p.RaceProps.Eats(FoodTypeFlags.Plant)); }
public override int Compare(Pawn a, Pawn b) { return(Genes.GetGene(a, statDef).CompareTo(Genes.GetGene(b, statDef))); }
// Token: 0x06000077 RID: 119 RVA: 0x00004568 File Offset: 0x00002768 internal static void HediffEffect(HediffDef hediffdef, float SeverityToApply, Pawn pawn, BodyPartRecord part, out bool immune) { immune = false; if (pawn.RaceProps.IsMechanoid || hediffdef == null) { return; } if (!ImmuneTo(pawn, hediffdef)) { if (pawn.health.WouldDieAfterAddingHediff(hediffdef, part, SeverityToApply)) { return; } var health = pawn.health; Hediff hediff; if (health == null) { hediff = null; } else { var hediffSet = health.hediffSet; hediff = hediffSet?.GetFirstHediffOfDef(hediffdef); } var hashediff = hediff; if (hashediff != null) { hashediff.Severity += SeverityToApply; return; } var addhediff = HediffMaker.MakeHediff(hediffdef, pawn, part); addhediff.Severity = SeverityToApply; pawn.health.AddHediff(addhediff, part); } else { immune = true; } }