void HandleObjective(ObjectiveDefinition.GetObjectiveData data, int index) { try { if (data.Success == false || data.Objective == null || !data.Objective.IsValid) { Log.Write("Error fetching QuestDefinition for QuestVisibility script for quest on object " + ObjectPrivate.Name); return; } Status status = null; if (!PerUserStatus.TryGetValue(data.Objective.Agent, out status)) { PerUserStatus[data.Objective.Agent] = new Status(); } ObjectiveStateChange(data.Objective.GetState(), data.Objective.Agent, index); status.Unsubscribe += data.Objective.Subscribe(ObjectiveState.Active, (stateData) => ObjectiveStateChange(stateData, index)).Unsubscribe; status.Unsubscribe += data.Objective.Subscribe(ObjectiveState.Completed, (stateData) => ObjectiveStateChange(stateData, index)).Unsubscribe; status.Unsubscribe += data.Objective.Subscribe(ObjectiveState.None, (stateData) => ObjectiveStateChange(stateData, index)).Unsubscribe; status.Unsubscribe += data.Objective.Subscribe(ObjectiveState.Locked, (stateData) => ObjectiveStateChange(stateData, index)).Unsubscribe; } catch (Exception) { Log.Write(LogLevel.Error, "Error subscribing to quest state changes."); } }
void CollectObjectiveData(ObjectiveDefinition.GetObjectiveData data, SessionId session, int index) { try { if (data.Success) { OnAddAgentData(data.Objective, session); CollectObjectiveData(data.Objective, session, index); } else { QLog(LogLevel.Warning, "Failed to get objective.", session); } } catch (Exception e) { QLog(LogLevel.Warning, "Exception getting objective. " + e.GetType().Name, session); } }