public static int GetGoodwillChange(IEnumerable <IThingHolder> pods, SettlementBase giveTo) { float num = 0f; foreach (IThingHolder current in pods) { ThingOwner directlyHeldThings = current.GetDirectlyHeldThings(); for (int i = 0; i < directlyHeldThings.Count; i++) { float singlePrice; if (directlyHeldThings[i].def == ThingDefOf.Silver) { singlePrice = directlyHeldThings[i].MarketValue; } else { float priceFactorSell_TraderPriceType = (giveTo.TraderKind == null) ? 1f : giveTo.TraderKind.PriceTypeFor(directlyHeldThings[i].def, TradeAction.PlayerSells).PriceMultiplier(); float tradePriceImprovementOffsetForPlayer = giveTo.TradePriceImprovementOffsetForPlayer; singlePrice = TradeUtility.GetPricePlayerSell(directlyHeldThings[i], priceFactorSell_TraderPriceType, 1f, tradePriceImprovementOffsetForPlayer); } num += FactionGiftUtility.GetBaseGoodwillChange(directlyHeldThings[i], directlyHeldThings[i].stackCount, singlePrice, giveTo.Faction); } } return(FactionGiftUtility.PostProcessedGoodwillChange(num, giveTo.Faction)); }
public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan) { if (this.CanTradeNow && CaravanVisitUtility.SettlementVisitedNow(caravan) == this) { yield return(CaravanVisitUtility.TradeCommand(caravan)); } if (CaravanArrivalAction_OfferGifts.CanOfferGiftsTo(caravan, this)) { yield return(FactionGiftUtility.OfferGiftsCommand(caravan, this)); } foreach (Gizmo g in base.GetCaravanGizmos(caravan)) { yield return(g); } if (this.Attackable) { yield return(new Command_Action { icon = SettlementBase.AttackCommand, defaultLabel = "CommandAttackSettlement".Translate(), defaultDesc = "CommandAttackSettlementDesc".Translate(), action = delegate { SettlementUtility.Attack(caravan, this.$this); } }); } }
public static void GiveGift(List <ActiveDropPodInfo> pods, SettlementBase giveTo) { int goodwillChange = FactionGiftUtility.GetGoodwillChange(pods.Cast <IThingHolder>(), giveTo); for (int i = 0; i < pods.Count; i++) { ThingOwner innerContainer = pods[i].innerContainer; for (int j = innerContainer.Count - 1; j >= 0; j--) { FactionGiftUtility.GiveGiftInternal(innerContainer[j], innerContainer[j].stackCount, giveTo.Faction); if (j < innerContainer.Count) { innerContainer.RemoveAt(j); } } } Faction faction = giveTo.Faction; Faction ofPlayer = Faction.OfPlayer; int goodwillChange2 = goodwillChange; string reason = "GoodwillChangedReason_ReceivedGift".Translate(); GlobalTargetInfo?lookTarget = new GlobalTargetInfo?(giveTo); if (!faction.TryAffectGoodwillWith(ofPlayer, goodwillChange2, true, true, reason, lookTarget)) { FactionGiftUtility.SendGiftNotAppreciatedMessage(giveTo.Faction, giveTo); } }
public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan) { if (CanTradeNow && CaravanVisitUtility.SettlementVisitedNow(caravan) == this) { yield return(CaravanVisitUtility.TradeCommand(caravan, base.Faction, TraderKind)); } if ((bool)CaravanArrivalAction_OfferGifts.CanOfferGiftsTo(caravan, this)) { yield return(FactionGiftUtility.OfferGiftsCommand(caravan, this)); } foreach (Gizmo caravanGizmo in base.GetCaravanGizmos(caravan)) { yield return(caravanGizmo); } if (Attackable) { Command_Action command_Action = new Command_Action(); command_Action.icon = AttackCommand; command_Action.defaultLabel = "CommandAttackSettlement".Translate(); command_Action.defaultDesc = "CommandAttackSettlementDesc".Translate(); command_Action.action = delegate { SettlementUtility.Attack(caravan, this); }; yield return(command_Action); } }
public override void Arrived(List <ActiveDropPodInfo> pods, int tile) { for (int i = 0; i < pods.Count; i++) { for (int j = 0; j < pods[i].innerContainer.Count; j++) { Pawn pawn = pods[i].innerContainer[j] as Pawn; if (pawn == null) { continue; } if (pawn.RaceProps.Humanlike) { GenGuest.AddPrisonerSoldThoughts(pawn); } else if (pawn.RaceProps.Animal && pawn.relations != null) { Pawn firstDirectRelationPawn = pawn.relations.GetFirstDirectRelationPawn(PawnRelationDefOf.Bond); if (firstDirectRelationPawn != null && firstDirectRelationPawn.needs.mood != null) { pawn.relations.RemoveDirectRelation(PawnRelationDefOf.Bond, firstDirectRelationPawn); firstDirectRelationPawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.SoldMyBondedAnimalMood); } } } } FactionGiftUtility.GiveGift(pods, settlement); }
public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, SettlementBase settlement) { return(TransportPodsArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_GiveGift>(() => TransportPodsArrivalAction_GiveGift.CanGiveGiftTo(pods, settlement), () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(new object[] { settlement.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign() }), representative, settlement.Tile)); }
public static int GetGoodwillChange(List <Tradeable> tradeables, Faction theirFaction) { float num = 0f; for (int i = 0; i < tradeables.Count; i++) { if (tradeables[i].ActionToDo == TradeAction.PlayerSells) { int count = Mathf.Min(tradeables[i].CountToTransferToDestination, tradeables[i].CountHeldBy(Transactor.Colony)); num += FactionGiftUtility.GetGoodwillChange(tradeables[i].AnyThing, count, tradeables[i].GetPriceFor(TradeAction.PlayerSells), theirFaction); } } return((int)num); }
public override void Arrived(List <ActiveDropPodInfo> pods, int tile) { for (int i = 0; i < pods.Count; i++) { for (int j = 0; j < pods[i].innerContainer.Count; j++) { Pawn pawn = pods[i].innerContainer[j] as Pawn; if (pawn != null && pawn.RaceProps.Humanlike) { GenGuest.AddPrisonerSoldThoughts(pawn); } } } FactionGiftUtility.GiveGift(pods, settlement); }
public static int GetGoodwillChange(IEnumerable <IThingHolder> pods, SettlementBase giveTo) { float num = 0f; foreach (IThingHolder thingHolder in pods) { ThingOwner directlyHeldThings = thingHolder.GetDirectlyHeldThings(); for (int i = 0; i < directlyHeldThings.Count; i++) { float priceFactorSell_TraderPriceType = (giveTo.TraderKind == null) ? 1f : giveTo.TraderKind.PriceTypeFor(directlyHeldThings[i].def, TradeAction.PlayerSells).PriceMultiplier(); float tradePriceImprovementOffsetForPlayer = giveTo.TradePriceImprovementOffsetForPlayer; float pricePlayerSell = TradeUtility.GetPricePlayerSell(directlyHeldThings[i], priceFactorSell_TraderPriceType, 1f, tradePriceImprovementOffsetForPlayer); num += FactionGiftUtility.GetGoodwillChange(directlyHeldThings[i], directlyHeldThings[i].stackCount, pricePlayerSell, giveTo.Faction); } } return((int)num); }
public override IEnumerable <Gizmo> GetCaravanGizmos(Caravan caravan) { _003CGetCaravanGizmos_003Ec__Iterator1 _003CGetCaravanGizmos_003Ec__Iterator = (_003CGetCaravanGizmos_003Ec__Iterator1) /*Error near IL_0040: stateMachine*/; if (CanTradeNow && CaravanVisitUtility.SettlementVisitedNow(caravan) == this) { yield return((Gizmo)CaravanVisitUtility.TradeCommand(caravan)); /*Error: Unable to find new state assignment for yield return*/; } if ((bool)CaravanArrivalAction_OfferGifts.CanOfferGiftsTo(caravan, this)) { yield return((Gizmo)FactionGiftUtility.OfferGiftsCommand(caravan, this)); /*Error: Unable to find new state assignment for yield return*/; } using (IEnumerator <Gizmo> enumerator = base.GetCaravanGizmos(caravan).GetEnumerator()) { if (enumerator.MoveNext()) { Gizmo g = enumerator.Current; yield return(g); /*Error: Unable to find new state assignment for yield return*/; } } if (Attackable) { yield return((Gizmo) new Command_Action { icon = AttackCommand, defaultLabel = "CommandAttackSettlement".Translate(), defaultDesc = "CommandAttackSettlementDesc".Translate(), action = delegate { SettlementUtility.Attack(caravan, _003CGetCaravanGizmos_003Ec__Iterator._0024this); } }); /*Error: Unable to find new state assignment for yield return*/; } yield break; IL_022e: /*Error near IL_022f: Unexpected return in MoveNext()*/; }
public static void GiveGift(List <Tradeable> tradeables, Faction giveTo, GlobalTargetInfo lookTarget) { int goodwillChange = FactionGiftUtility.GetGoodwillChange(tradeables, giveTo); for (int i = 0; i < tradeables.Count; i++) { if (tradeables[i].ActionToDo == TradeAction.PlayerSells) { tradeables[i].ResolveTrade(); } } Faction ofPlayer = Faction.OfPlayer; int goodwillChange2 = goodwillChange; string reason = "GoodwillChangedReason_ReceivedGift".Translate(); GlobalTargetInfo?lookTarget2 = new GlobalTargetInfo?(lookTarget); if (!giveTo.TryAffectGoodwillWith(ofPlayer, goodwillChange2, true, true, reason, lookTarget2)) { FactionGiftUtility.SendGiftNotAppreciatedMessage(giveTo, lookTarget); } }
public override void Arrived(List <ActiveDropPodInfo> pods, int tile) { FactionGiftUtility.GiveGift(pods, this.settlement); }
public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, SettlementBase settlement) { if (settlement.Faction == Faction.OfPlayer) { return(Enumerable.Empty <FloatMenuOption>()); } return(TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => CanGiveGiftTo(pods, settlement), () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(settlement.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign()), representative, settlement.Tile)); }
public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(CompLaunchable representative, IEnumerable <IThingHolder> pods, Settlement settlement) { if (settlement.Faction == Faction.OfPlayer) { return(Enumerable.Empty <FloatMenuOption>()); } return(TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => CanGiveGiftTo(pods, settlement), () => new TransportPodsArrivalAction_GiveGift(settlement), "GiveGiftViaTransportPods".Translate(settlement.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, settlement).ToStringWithSign()), representative, settlement.Tile, delegate(Action action) { TradeRequestComp tradeReqComp = settlement.GetComponent <TradeRequestComp>(); if (tradeReqComp.ActiveRequest && pods.Any((IThingHolder p) => p.GetDirectlyHeldThings().Contains(tradeReqComp.requestThingDef))) { Find.WindowStack.Add(new Dialog_MessageBox("GiveGiftViaTransportPodsTradeRequestWarning".Translate(), "Yes".Translate(), delegate { action(); }, "No".Translate())); } else { action(); } })); }
public override IEnumerable <FloatMenuOption> GetShuttleFloatMenuOptions(IEnumerable <IThingHolder> pods, Action <int, TransportPodsArrivalAction> launchAction) { foreach (FloatMenuOption shuttleFloatMenuOption in base.GetShuttleFloatMenuOptions(pods, launchAction)) { yield return(shuttleFloatMenuOption); } if ((bool)TransportPodsArrivalAction_GiveGift.CanGiveGiftTo(pods, this)) { yield return(new FloatMenuOption("GiveGiftViaTransportPods".Translate(base.Faction.Name, FactionGiftUtility.GetGoodwillChange(pods, this).ToStringWithSign()), delegate { TradeRequestComp tradeReqComp = GetComponent <TradeRequestComp>(); if (tradeReqComp.ActiveRequest && pods.Any((IThingHolder p) => p.GetDirectlyHeldThings().Contains(tradeReqComp.requestThingDef))) { Find.WindowStack.Add(new Dialog_MessageBox("GiveGiftViaTransportPodsTradeRequestWarning".Translate(), "Yes".Translate(), delegate { launchAction(base.Tile, new TransportPodsArrivalAction_GiveGift(this)); }, "No".Translate())); } else { launchAction(base.Tile, new TransportPodsArrivalAction_GiveGift(this)); } })); } if (base.HasMap) { yield break; } foreach (FloatMenuOption floatMenuOption in TransportPodsArrivalActionUtility.GetFloatMenuOptions(() => TransportPodsArrivalAction_AttackSettlement.CanAttack(pods, this), () => new TransportPodsArrivalAction_Shuttle(this), "AttackShuttle".Translate(Label), launchAction, base.Tile)) { yield return(floatMenuOption); } }