void ExportGoals(BinaryWriter w) { w.Write(0); foreach (var kvp in m_Goals) { var goal_list = kvp.Value; for (int i = 0; i < goal_list.Count; ++i) { MissionGoal goal = goal_list.Values[i]; if (goal is MissionGoal_Bool) { MissionGoal_Bool _goal = goal as MissionGoal_Bool; w.Write(1); w.Write(_goal.id); w.Write(_goal.missionId); w.Write(_goal.text); w.Write(_goal.achieved); } else if (goal is MissionGoal_Item) { MissionGoal_Item _goal = goal as MissionGoal_Item; w.Write(2); w.Write(_goal.id); w.Write(_goal.missionId); w.Write(_goal.text); w.Write((int)(_goal.item.type)); w.Write(_goal.item.Group); w.Write(_goal.item.Id); w.Write((int)_goal.compare); w.Write(_goal.target); } else if (goal is MissionGoal_Kill) { MissionGoal_Kill _goal = goal as MissionGoal_Kill; w.Write(3); w.Write(_goal.id); w.Write(_goal.missionId); w.Write(_goal.text); w.Write((int)(_goal.monster.type)); w.Write(_goal.monster.Group); w.Write(_goal.monster.Id); w.Write((int)_goal.compare); w.Write(_goal.target); w.Write(_goal.current); } else { w.Write(0); } } } w.Write(-1); }
public void SetItemGoal(int id, string text, int missionId, OBJECT item, ECompare compare, int amount) { if (!m_Scenario.IsMissionActive(missionId)) { return; } if (!m_Goals.ContainsKey(missionId)) { m_Goals[missionId] = new SortedList <int, MissionGoal>(4); } var goal_list = m_Goals[missionId]; if (!goal_list.ContainsKey(id)) { goal_list[id] = new MissionGoal_Item(); goal_list[id].onAchieve = onGoalAchieve; goal_list[id].Init(); } if (!(goal_list[id] is MissionGoal_Item)) { goal_list[id].Free(); goal_list[id] = new MissionGoal_Item(); goal_list[id].onAchieve = onGoalAchieve; goal_list[id].Init(); } var goal = goal_list[id] as MissionGoal_Item; goal.id = id; goal.text = text; goal.missionId = missionId; goal.item = item; goal.compare = compare; goal.target = amount; if (onSetMissionGoal != null) { onSetMissionGoal(id, missionId); } }