/* * When the Command is Dispatched */ public static void CommandGeneticsBase(string command, string[] args) { // Get input length switch (args.Length) { case 0: ModEntry.MONITOR.Log("Must specify a <gender> and an <NPC>.", LogLevel.Error); return; case 1: case 2: { // Get the inputted child Child child = ChildDat.GetByName(args[0]); if (/* Child must be an existing Child */ child == null) { ModEntry.MONITOR.Log($"Could not location a <Child> named \"{args[0]}\".", LogLevel.Error); } else if (/* Child cannot be another players */ child.idOfParent.Value != Game1.player.UniqueMultiplayerID && (!Context.IsMainPlayer)) { ModEntry.MONITOR.Log($"That <Child> \"{args[0]}\" does not belong to you.", LogLevel.Error); } else if (args.Length == 1) { ModEntry.MONITOR.Log($"{child.Name}'s parent is {ChildDat.Of(child).ParentName}.", LogLevel.Info); } else { // Get the inputted spouse NPC parent = Game1.getCharacterFromName(args[1], true); if (/* Parent must be an existing NPC */ parent == null) { ModEntry.MONITOR.Log($"Specified <Parent> \"{args[1]}\" could not be located.", LogLevel.Error); } else if (/* NPC must be an Adult NPC */ !Blender.IsOfAge(parent)) { ModEntry.MONITOR.Log($"Specified <Parent> must be an adult!", LogLevel.Error); } else { ChildDat data = ChildDat.Of(child, parent); if (!data.Save(true)) { Game1.addHUDMessage(new HUDMessage("Host is not using mod \"NotFarFromTheTree\". Updated Children will not save.", HUDMessage.error_type)); } ModEntry.MONITOR.Log($"{data.ChildName} now takes after {data.ParentName}", LogLevel.Info); } } return; } default: { ModEntry.MONITOR.Log("Too many parameters.", LogLevel.Error); return; } } }
/* * Event Handlers */ public static void OnMessageNotification(object sender, ModMessageReceivedEventArgs e) { if (e.FromModID != ModEntry.MOD_ID) { return; } switch (e.Type) { case "ChildUpdate": { ChildDat childDat = e.ReadAs <ChildDat>(); childDat?.Save(Context.IsMainPlayer); break; } } }