private void ProcessEvent_Get_Factions(FactionInfoList obj) { // from Request_Get_Factions if (obj != null) { DebugLog("Event_Get_Factions- Faction list. Count: {0}", obj.factions != null ? obj.factions.Count : 0); if (obj.factions != null) { lock (_factionsById) { // TODO: remove deleted factions foreach (Eleon.Modding.FactionInfo factionInfo in obj.factions) { DebugLog("Id: {0}, Abrev: {1}, Name: {2}, Origin: {3}", factionInfo.factionId, factionInfo.abbrev, factionInfo.name, factionInfo.origin); if (!_factionsById.ContainsKey(factionInfo.factionId)) { _factionsById[factionInfo.factionId] = new Faction(this, factionInfo); } else { _factionsById[factionInfo.factionId].UpdateInfo(factionInfo); } } } } } else { var newFormat = DateTime.Now.ToString("R") + " - " + "ProcessEvent_Get_Factions got null object"; _traceSource.TraceEvent(TraceEventType.Warning, 1, newFormat); //$$_traceSource.TraceEvent(TraceEventType.Warning, 1, "ProcessEvent_Get_Factions got null object"); } }
private FactionInfoList GetUpdatedFactionInfoList(Id id) // TODO: Identify what ID this is { FactionInfoList factionInfoList = SyncRequest <FactionInfoList>(CmdId.Request_Get_Factions, CmdId.Event_Get_Factions, new Id(0)); foreach (FactionInfo factionInfo in factionInfoList.factions) { _factionCache[factionInfo.factionId] = factionInfo; } return(factionInfoList); }
private static void CleanupFactionDB(FactionInfoList factions, FactionContext DB) { try { var dictFactions = factions.factions.ToDictionary(K => K.abbrev, K => K); DB.Factions .Where(F => !dictFactions.ContainsKey(F.Abbrev)) .ToList() .ForEach(F => DB.Factions.Remove(F)); DB.SaveChanges(); } catch (System.Exception Error) { System.Console.WriteLine(Error); } }
public override void Initialize(ModGameAPI dediAPI) { DediAPI = dediAPI; LogLevel = LogLevel.Message; Log($"**EmpyrionBackpackExtender: loaded"); LoadConfiuration(); LogLevel = Configuration.Current.LogLevel; ChatCommandManager.CommandPrefix = Configuration.Current.ChatCommandPrefix; TaskTools.Intervall(60000, () => CurrentFactions = Request_Get_Factions(0.ToId()).Result); AddCommandsFor(Configuration.Current.PersonalBackpack, "personal", P => P.steamId); AddCommandsFor(Configuration.Current.FactionBackpack, "faction", P => P.factionId.ToString()); AddCommandsFor(Configuration.Current.OriginBackpack, "origin", P => P.origin.ToString()); AddCommandsFor(Configuration.Current.GlobalBackpack, "global", P => "global"); }