public static string GenerateSaveStringFor(MisisonGoal goal) { var modGoal = goal as GoalInstance; if (modGoal != null) { return(modGoal.SaveString); } var name = goal.GetType().Name; var result = "<vanillaMissionGoal interfaceId=\"" + name.Remove(name.LastIndexOf("Mission")) + "\" "; foreach (var f in goal.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public)) { if (f.FieldType == typeof(Hacknet.OS) || f.FieldType == typeof(Hacknet.Folder)) { continue; } const string t = "target"; var val = f.GetValue(goal); var computer = val as Hacknet.Computer; name = f.Name != t && f.Name.Contains(t) ? f.Name.Substring(f.Name.IndexOf(t) + t.Length) : f.Name; result += name + "=\"" + computer?.ip ?? val; } return(result + "/>"); }
internal static bool TryLoadCustomGoal(string type, out MisisonGoal customGoal) { if (CustomGoals.TryGetValue(type, out var goalType)) { customGoal = (MisisonGoal)Activator.CreateInstance(goalType); return(true); } customGoal = null; return(false); }
public Instance AddGoal(MisisonGoal goal) { Interface.OnGoalAdd(this, goal); dynamicGoals.Add(goal); var moddedGoal = goal as GoalInstance; if (moddedGoal != null) { moddedGoal.Mission = this; } return(this); }
public void OnGoalAdd(Instance instance, MisisonGoal goal) { }