public static void AcceptClicked(BirthdayChildPanel bdPanel) { bdPanel.gameObject.SetActive(false); HumanAI oldChild = (HumanAI)AccessTools.Field(typeof(BirthdayChildPanel), "child").GetValue(bdPanel); HumanConfiguration config = new HumanConfiguration(oldChild.humanType, AgeLevel.Child, 0f, oldChild.mother, oldChild.father); Relationship relationship = WorldScripts.Instance.relationshipManager.GetRelationship(oldChild.father, oldChild.mother); HumanAI newChild = WorldScripts.Instance.humanManager.SpawnHuman(config, relationship.GetFirstHuman().GetPosition(), relationship.GetFirstHuman().faction, true, null); newChild.mother.onHadChild.Invoke(newChild); newChild.father.onHadChild.Invoke(newChild); relationship.HadChild(); WorldScripts.Instance.relationshipManager.SetRelationship(RelationshipLevel.Friend, 0.8f, newChild, newChild.mother); WorldScripts.Instance.relationshipManager.SetRelationship(RelationshipLevel.Friend, 0.8f, newChild, newChild.father); String childName = bdPanel.transform.GetChild(0).Find((newChild.gender == Gender.Female ? "GirlPanel" : "BoyPanel")).GetComponentInChildren <InputField>().text; newChild.SetName(childName); WorldScripts.Instance.cameraMovement.PanToPosition(newChild.GetPosition()); PlannedParenthoodMod.InAddChild = false; }
public static bool Prefix(HumanManager __instance, ref HumanAI __result, HumanConfiguration config, Vector3 position, Faction faction, bool alive = true, HumanAI.Serializable serial = null) { if (!PlannedParenthoodMod.InAddChild && config.humanType == HumanType.Colonist && config.ageLevel == AgeLevel.Child && serial == null) { PlannedParenthoodMod.InAddChild = true; GameObject fakeObj = new GameObject(); fakeObj.SetActive(false); HumanMonoBehaviour hMono = fakeObj.AddComponent <HumanMonoBehaviour>(); __result = new HumanAI(hMono, null, config, Int64.MaxValue); __result.mother.children.Remove(__result); __result.father.children.Remove(__result); return(false); } return(true); }
public static void SpawnHuman_Postfix(HumanManager __instance, ref HumanAI __result, HumanConfiguration config, Vector3 position, Faction faction, bool alive = true, HumanAI.Serializable serial = null) { if (UIImprovementsMod.Instance == null || UIImprovementsMod.Instance.AnimalCyclerPanel == null) { return; } if (__result != null && __result.faction != null && !__result.IsHumanoid() && __result.animal != null && __result.faction is ColonyFaction) { HumanType type = __result.humanType; UIImprovementsMod.Instance.AnimalCyclerPanel.UpdateUI(type); } }