public void SendPawn(User user, Pawn pawn) { if (!CheckCanStartTransaction(user)) { return; } RealmPawn realmPawn = RealmPawn.ToRealmPawn(pawn, realmData); int id = ++this.currentUser.lastTransactionId; ColonistTransaction trans = new ColonistTransaction(id, currentUser, user, pawn, realmPawn); realmData.transactions.Add(trans); this.SendPacket(new StartTransactionPacket { transaction = trans }); Messages.Message("Offer sent, waiting for confirmation", MessageSound.Silent); }
// Token: 0x0600001C RID: 28 RVA: 0x0000278C File Offset: 0x0000098C public void SendPawn(User user, Pawn pawn, TransactionType transaction) { if (!CheckCanStartTransaction(user)) { return; } var realmPawn = RealmPawn.ToRealmPawn(pawn, realmData); var user2 = currentUser; var num = user2.lastTransactionId + 1; user2.lastTransactionId = num; var pawnTransaction = new PawnTransaction(num, currentUser, user, pawn, realmPawn, transaction); realmData.transactions.Add(pawnTransaction); SendPacket(new StartTransactionPacket { transaction = pawnTransaction }); Messages.Message("Offer sent, waiting for confirmation", MessageTypeDefOf.SilentInput); }
// Token: 0x06000037 RID: 55 RVA: 0x000029D0 File Offset: 0x00000BD0 public static RealmPawn ToRealmPawn(Pawn pawn, RealmData realmData) { var realmPawn = new RealmPawn(); var array = pawn.Name.ToString().Split(' '); if (array.Length == 3) { array[1] = array[1].Replace("'", ""); } realmPawn.name = array; realmPawn.kindDefName = pawn.kindDef.defName; realmPawn.ageBiologicalTicks = pawn.ageTracker.AgeBiologicalTicks; realmPawn.ageChronologicalTicks = pawn.ageTracker.AgeChronologicalTicks; realmPawn.gender = pawn.gender; if (!pawn.health.hediffSet.HasHediff(PhiHediffDefOf.Phi_Key)) { pawn.health.AddHediff(PhiHediffDefOf.Phi_Key); pawn.health.hediffSet.GetFirstHediffOfDef(PhiHediffDefOf.Phi_Key).Severity = Rand.Range(0f, float.MaxValue); } if (pawn.skills != null) { var list = new List <RealmSkillRecord>(); foreach (var skillRecord in pawn.skills.skills) { list.Add(new RealmSkillRecord { skillDefLabel = skillRecord.def.label, level = skillRecord.Level, passion = skillRecord.passion }); } realmPawn.skills = list; } if (pawn.story != null) { var list2 = new List <RealmTrait>(); foreach (var trait in pawn.story.traits.allTraits) { list2.Add(new RealmTrait { traitDefName = trait.def.defName, degree = trait.Degree }); } realmPawn.traits = list2; var color = pawn.story.hairColor; realmPawn.hairColor = new[] { color.r, color.g, color.b, color.a }; realmPawn.bodyTypeDefName = pawn.story.bodyType.defName; realmPawn.crownType = pawn.story.crownType; realmPawn.hairDefName = pawn.story.hairDef.defName; realmPawn.childhoodKey = pawn.story.childhood.identifier; var realmPawn2 = realmPawn; var adulthood = pawn.story.adulthood; realmPawn2.adulthoodKey = adulthood?.identifier; realmPawn.melanin = pawn.story.melanin; } if (pawn.equipment != null) { var list3 = new List <RealmThing>(); foreach (var thing in pawn.equipment.AllEquipmentListForReading) { list3.Add(realmData.ToRealmThing(thing)); } realmPawn.equipments = list3; } if (pawn.apparel != null) { var list4 = new List <RealmThing>(); foreach (var thing2 in pawn.apparel.WornApparel) { list4.Add(realmData.ToRealmThing(thing2)); } realmPawn.apparels = list4; } if (pawn.inventory != null) { var list5 = new List <RealmThing>(); foreach (var thing3 in pawn.inventory.innerContainer) { list5.Add(realmData.ToRealmThing(thing3)); } realmPawn.inventory = list5; } var list6 = new List <RealmHediff>(); foreach (var hediff in pawn.health.hediffSet.hediffs) { var immunityRecord = pawn.health.immunity.GetImmunityRecord(hediff.def); var bodyPartIndex = -1; var part = hediff.Part; if (part?.def != null) { if (!pawn.RaceProps.body.AllParts.Contains(hediff.Part)) { var format = "Skipping bodypart {0}, not found in body."; var part2 = hediff.Part; object arg; if (part2 == null) { arg = null; } else { var def = part2.def; arg = def?.defName; } Log.Error(string.Format(format, arg)); continue; } bodyPartIndex = pawn.RaceProps.body.GetIndexOfPart(hediff.Part); } var list7 = list6; var realmHediff = new RealmHediff { hediffDefName = hediff.def.defName, bodyPartIndex = bodyPartIndex, immunity = immunityRecord?.immunity ?? float.NaN }; var source = hediff.source; realmHediff.sourceDefName = source?.defName; realmHediff.ageTicks = hediff.ageTicks; realmHediff.severity = hediff.Severity; list7.Add(realmHediff); realmPawn.hediffs = list6; } var unused = pawn.health.State; var dictionary = new Dictionary <string, int>(); if (pawn.training != null) { var list8 = new List <RealmTrainingRecord>(); foreach (var trainableDef in TrainableUtility.TrainableDefsInListOrder) { list8.Add(new RealmTrainingRecord { trainingDefLabel = trainableDef.defName, learned = pawn.training.HasLearned(trainableDef), wanted = pawn.training.GetWanted(trainableDef) }); } realmPawn.training = list8; } if (pawn.workSettings == null) { return(realmPawn); } foreach (var workTypeDef in DefDatabase <WorkTypeDef> .AllDefs) { dictionary.Add(workTypeDef.defName, pawn.workSettings.GetPriority(workTypeDef)); } return(realmPawn); }