예제 #1
0
        public void AfterSelectedWorld()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Texture Mapping Loaded----------------------");
            var i = 0;

            foreach (var item in LoadedAssembalies)
            {
                if (Activator.CreateInstance(item) is ICSTextureMapping texture &&
                    !string.IsNullOrEmpty(texture.name))
                {
                    ItemTypesServer.SetTextureMapping(texture.name, new ItemTypesServer.TextureMapping(texture.JsonSerialize()));
                    sb.Append($"{texture.name}, ");
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
        public void ColonyCreated(Colony c)
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Happiness Effects Loaded----------------------");
            var i = 0;

            foreach (var item in LoadedAssembalies)
            {
                if (Activator.CreateInstance(item) is IHappinessEffect effect)
                {
                    c.HappinessData.HappinessEffects.Add(effect);
                    sb.Append($"{effect.GetType().Name}, ");
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
예제 #3
0
        public void OnAddResearchables()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Panda Quests Loaded----------------------");
            var i = 0;

            foreach (var quest in LoadedAssembalies)
            {
                if (Activator.CreateInstance(quest) is IPandaQuest pandaQuest &&
                    !(pandaQuest is IPandaQuest) &&
                    !string.IsNullOrEmpty(pandaQuest.QuestKey))
                {
                    sb.Append($"{pandaQuest.QuestKey}, ");
                    Questing.QuestingSystem.QuestPool[pandaQuest.QuestKey] = pandaQuest;
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("------------------------------------------------------");
        }
예제 #4
0
        public void AfterItemTypesDefined()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Roaming Job Objective Loaded----------------------");
            var i = 0;

            foreach (var s in LoadedAssembalies)
            {
                if (Activator.CreateInstance(s) is IRoamingJobObjective roamingJobObjective &&
                    !string.IsNullOrEmpty(roamingJobObjective.ItemIndex))
                {
                    sb.Append($"{roamingJobObjective.ItemIndex}, ");
                    RoamingJobManager.RegisterObjectiveType(roamingJobObjective);
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
예제 #5
0
        public override void OnActionExecuted(HttpActionExecutedContext filterContext)
        {
            try
            {
                MiniSessionManager.Instance.CommitChanges(filterContext.Exception);
                if (AllowPartialResponse)
                {
                    TryToCreatePartialResponse(filterContext);
                }
            }
            catch (Exception x)
            {
                filterContext.Exception = x;
            }
            HandleException(filterContext);
            var timer = (Stopwatch)filterContext.Request.Properties["logtimer"];

            timer.Stop();
            _elapsed = timer.Elapsed;
            if (!LogEnabled)
            {
                return;
            }
            IdentityHelper.LogAction(
                filterContext.ActionContext.ActionDescriptor.ControllerDescriptor.ControllerName,
                filterContext.ActionContext.ActionDescriptor.ActionName,
                filterContext.Exception == null,
                filterContext.Exception?.Message);
            if (!(bool)filterContext.Request.Properties["requestIsLogged"])
            {
                APILogger?.LogExposedAPIAccess(_id, filterContext.ActionContext, _elapsed, false);
                filterContext.Request.Properties["requestIsLogged"] = true;
            }
        }
예제 #6
0
        public void AfterItemTypesDefined()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Tutorials Loaded----------------------");
            var i = 0;

            foreach (var s in LoadedAssembalies)
            {
                if (Activator.CreateInstance(s) is ITutorial tutorial &&
                    !string.IsNullOrEmpty(tutorial.Name))
                {
                    sb.Append($"{tutorial.Name}, ");
                    TutorialFactory.Tutorials[tutorial.Name] = tutorial;
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
예제 #7
0
        public static void OnSavingColony(Colony c, JSONNode n)
        {
            try
            {
                lock (Objectives)
                {
                    if (Objectives.ContainsKey(c))
                    {
                        if (n.HasChild(GameInitializer.NAMESPACE + ".Objectives"))
                        {
                            n.RemoveChild(GameInitializer.NAMESPACE + ".Objectives");
                        }

                        var objectiveNode = new JSONNode(NodeType.Array);

                        foreach (var node in Objectives[c])
                        {
                            foreach (var catNode in node.Value)
                            {
                                objectiveNode.AddToArray(catNode.Value.ToJsonNode());
                            }
                        }

                        n[GameInitializer.NAMESPACE + ".Objectives"] = objectiveNode;
                    }
                }
            }
            catch (Exception ex)
            {
                APILogger.LogError(ex);
            }
        }
예제 #8
0
        public override void OnResearchComplete(ColonyScienceState manager, EResearchCompletionReason reason)
        {
            base.OnResearchComplete(manager, reason);

            try
            {
                foreach (var p in manager.Colony.Owners)
                {
                    p.GetTempValues(true).Set(TmpValueKey, Value);
                    p.GetTempValues(true).Set(LevelKey, Level);
                }

                manager.Colony.TemporaryData.SetAs(TmpValueKey, Value);
                manager.Colony.TemporaryData.SetAs(LevelKey, Level);

                if (ResearchComplete != null)
                {
                    ResearchComplete(this, new ResearchCompleteEventArgs(this, manager));
                }
            }
            catch (Exception ex)
            {
                APILogger.LogError(ex, $"Error OnResearchComplete for {TmpValueKey} Level: {Level}.");
            }
        }
예제 #9
0
        public void AfterWorldLoad()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Panda Zombies Loaded----------------------");
            var i = 0;

            foreach (var monster in LoadedAssembalies)
            {
                if (Activator.CreateInstance(monster) is IPandaZombie pandaZombie &&
                    !(pandaZombie is IPandaBoss) &&
                    !string.IsNullOrEmpty(pandaZombie.name))
                {
                    sb.Append($"{pandaZombie.name}, ");
                    PandaMonsterSpawner.PandaZombies.Add(pandaZombie);
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("------------------------------------------------------");
        }
예제 #10
0
        public static ColonistInventory Get(NPCBase npc)
        {
            ColonistInventory inv = null;

            if (npc == null)
            {
                return(inv);
            }

            if (npc.CustomData == null)
            {
                npc.CustomData = new JSONNode();
            }

            try
            {
                if (!npc.CustomData.TryGetAs(GameInitializer.SETTLER_INV, out inv) || inv == null)
                {
                    inv = new ColonistInventory(npc);
                    npc.CustomData.SetAs(GameInitializer.SETTLER_INV, inv);
                }
            }
            catch (Exception ex)
            {
                APILogger.LogError(ex);
            }

            if (inv == null)
            {
                inv = new ColonistInventory(npc);
            }

            return(inv);
        }
        public void AfterModsLoaded(List <ModLoader.ModDescription> list)
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Connected Block CalculationType Loaded----------------------");
            var i = 0;

            foreach (var s in LoadedAssembalies)
            {
                if (Activator.CreateInstance(s) is IConnectedBlockCalculationType connectedBlockCalcType &&
                    !string.IsNullOrEmpty(connectedBlockCalcType.name))
                {
                    sb.Append($"{connectedBlockCalcType.name}, ");
                    ConnectedBlockCalculator.CalculationTypes[connectedBlockCalcType.name] = connectedBlockCalcType;
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
        public void OnRegisterUpgrades(UpgradesManager upgrades)
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Colony Upgrades Loaded----------------------");
            var i = 0;

            foreach (var item in LoadedAssembalies)
            {
                if (Activator.CreateInstance(item) is IPandaUpgrade upgrade)
                {
                    upgrades.RegisterUpgrade(upgrade);

                    sb.Append($"{upgrade.UniqueKey}, ");
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
예제 #13
0
        public bool StartAPILogging(string cacheID, string InstanceID, bool version)
        {
            if (cacheID != null)
            {
                try
                {
                    _forcefullStoppedLogging = false;
                    if (_apiLogger == null)
                    {
                        APILogger = new APIServerLogger();
                    }
                    APILogger.AddInstanceInformation(InstanceID.ToLower());

                    if (APILogging.APILogManager.APILogManger == null && APILogger != null && !APILogger.IsLoggingEnabled(InstanceID.ToLower()))
                    {
                        APILogging.APILogManager logmanger = new APILogging.APILogManager();
                        logmanger.StartLogging(cacheID, version);
                        APILogging.APILogManager.APILogManger = logmanger;
                        AppUtil.LogEvent("API logging sucessfully started on cache " + cacheID, EventLogEntryType.Information);
                        return(true);
                    }
                    else
                    {
                        return(APILogManager.EnableLogging);
                    }
                }
                catch
                {
                    return(false);
                }
            }
            return(false);
        }
예제 #14
0
        public RecipeUnlockReward(string itemName, string rewardKey, string localizationKey = null, LocalizationHelper localizationHelper = null)
        {
            RecipeKey          = itemName;
            RewardKey          = rewardKey;
            LocalizationHelper = localizationHelper;
            LocalizationKey    = localizationKey;

            if (ServerManager.RecipeStorage.TryGetRecipe(new Recipes.RecipeKey(itemName), out var recipe))
            {
                Recipe = recipe;
                ServerManager.RecipeStorage.AddScienceRequirement(Recipe);
            }
            else
            {
                APILogger.Log(ChatColor.red, "Item " + itemName + " recipe not found. unable to create RecipeUnlockReward for reward key " + rewardKey);
            }

            if (LocalizationHelper == null)
            {
                LocalizationHelper = new LocalizationHelper(GameInitializer.NAMESPACE, "Quests");
            }

            if (string.IsNullOrEmpty(LocalizationKey))
            {
                LocalizationKey = nameof(RecipeUnlockReward);
            }
        }
예제 #15
0
        public void AfterWorldLoad()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Bosses Loaded----------------------");
            var i = 0;

            foreach (var monster in LoadedAssembalies)
            {
                if (Activator.CreateInstance(monster) is IPandaBoss pandaBoss &&
                    !string.IsNullOrEmpty(pandaBoss.name))
                {
                    sb.Append($"{pandaBoss.name}, ");
                    MonsterManager.AddBoss(pandaBoss);
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("------------------------------------------------------");
        }
예제 #16
0
        public static void OnAssemblyLoaded(string path)
        {
            var     settings = GameInitializer.GetJSONSettingPaths(GameInitializer.NAMESPACE + ".MenuFile");
            JObject jObject  = new JObject();

            foreach (var info in settings)
            {
                try
                {
                    foreach (var jsonNode in info.Value)
                    {
                        try
                        {
                            jObject.Merge(JsonConvert.DeserializeObject <JObject>(File.ReadAllText(info.Key + "/" + jsonNode)), new JsonMergeSettings()
                            {
                                MergeArrayHandling = MergeArrayHandling.Union, MergeNullValueHandling = MergeNullValueHandling.Ignore, PropertyNameComparison = StringComparison.InvariantCultureIgnoreCase
                            });
                        }
                        catch (Exception ex)
                        {
                            APILogger.LogError(ex, "Error loading settings node " + jsonNode);
                        }
                    }
                }
                catch (Exception ex)
                {
                    APILogger.LogError(ex, "Error loading settings file " + info.Key + " values " + string.Join(", ", info.Value.ToArray()));
                }
            }

            LoadedMenus = JSON.DeserializeString(JsonConvert.SerializeObject(jObject));
        }
예제 #17
0
        public Hashtable GetAPILogging(string cacheID, string instanceID)
        {
            Hashtable data = new Hashtable();
            List <Alachisoft.NCache.Common.Monitoring.APILogging.APIRuntimeLogItem> apiLogData = null;

            try
            {
                if (cacheID != null)
                {
                    if (_forcefullStoppedLogging || _apiLogger == null)
                    {
                        throw new APILoggingException("Logging has been stopped due to connection lost");
                    }
                    if (APILogging.APILogManager.APILogManger != null)
                    {
                        long startTime = APILogger.GetInstanceStartTime(instanceID.ToLower());
                        if (startTime != -1)
                        {
                            apiLogData = APILogging.APILogManager.APILogManger.GetEntry(ref startTime);
                        }
                        lock (_lock)
                        {
                            data.Add("items", apiLogData);
                        }
                        APILogger.UpdateInstanceStartTime(instanceID.ToLower(), startTime);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(data);
        }
예제 #18
0
        public static bool GetBestWeapon(NPC.NPCBase npc, int limit)
        {
            var hasItem = false;

            try
            {
                if (npc != null)
                {
                    var inv   = ColonistInventory.Get(npc);
                    var stock = npc.Colony.Stockpile;

                    hasItem = !inv.Weapon.IsEmpty();
                    IWeapon bestWeapon = null;

                    if (hasItem)
                    {
                        bestWeapon = WeaponFactory.WeaponLookup[inv.Weapon.Id];
                    }

                    foreach (var wep in WeaponFactory.WeaponLookup.Values.Where(w => w as IPlayerMagicItem == null && w is WeaponMetadata weaponMetadata && weaponMetadata.ItemType != null).Cast <WeaponMetadata>())
                    {
                        if (stock.Contains(wep.ItemType.ItemIndex) && bestWeapon == null ||
                            stock.Contains(wep.ItemType.ItemIndex) && bestWeapon != null &&
                            bestWeapon.Damage.TotalDamage() < wep.Damage.TotalDamage() &&
                            stock.AmountContained(ItemId.GetItemId(bestWeapon.name)) > limit)
                        {
                            bestWeapon = wep;
                        }
                    }

                    if (bestWeapon != null)
                    {
                        var wepId = ItemId.GetItemId(bestWeapon.name);
                        if (hasItem && inv.Weapon.Id != wepId || !hasItem)
                        {
                            hasItem = true;
                            stock.TryRemove(wepId);

                            if (!inv.Weapon.IsEmpty())
                            {
                                stock.Add(inv.Weapon.Id);
                            }

                            inv.Weapon = new ItemState
                            {
                                Id         = wepId,
                                Durability = bestWeapon.WepDurability
                            };
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                APILogger.LogError(ex);
            }

            return(hasItem);
        }
예제 #19
0
        public void OnAddResearchables()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Research Loaded----------------------");
            var i = 0;

            foreach (var s in LoadedAssembalies)
            {
                if (Activator.CreateInstance(s) is IPandaResearch pandaResearch &&
                    !string.IsNullOrEmpty(pandaResearch.name))
                {
                    sb.Append(pandaResearch.name + ", ");
                    pandaResearch.BeforeRegister();

                    for (var l = 1; l <= pandaResearch.NumberOfLevels; l++)
                    {
                        var research = new PandaResearchable(pandaResearch, l);
                        research.ResearchComplete += pandaResearch.ResearchComplete;

                        foreach (var item in research.Recipes)
                        {
                            if (item.UnlockType == Science.ERecipeUnlockType.Recipe)
                            {
                                if (ServerManager.RecipeStorage.TryGetRecipe(new Recipes.RecipeKey(item.Identifier), out var recipe))
                                {
                                    ServerManager.RecipeStorage.AddScienceRequirement(recipe);
                                }
                            }
                            else
                            {
                                if (ServerManager.RecipeStorage.TryGetRecipes(item.Identifier, out var recipe))
                                {
                                    for (int r = 0; r < recipe.Count; r++)
                                    {
                                        ServerManager.RecipeStorage.AddScienceRequirement(recipe[r]);
                                    }
                                }
                            }
                        }

                        research.Register();
                    }

                    pandaResearch.OnRegister();
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
예제 #20
0
        public void AfterItemTypesDefined()
        {
            StringBuilder sb = new StringBuilder();

            APILogger.LogToFile("-------------------Recipes Loaded----------------------");
            var i = 0;

            foreach (var item in LoadedAssembalies)
            {
                if (Activator.CreateInstance(item) is ICSRecipe recipe &&
                    !string.IsNullOrEmpty(recipe.name))
                {
                    var requirements = new List <InventoryItem>();
                    var results      = new List <RecipeResult>();
                    recipe.JsonSerialize();

                    foreach (var ri in recipe.requires)
                    {
                        if (ItemTypes.IndexLookup.TryGetIndex(ri.type, out var itemIndex))
                        {
                            requirements.Add(new InventoryItem(itemIndex, ri.amount));
                        }
                    }

                    foreach (var ri in recipe.results)
                    {
                        results.Add(ri);
                    }

                    var newRecipe = new Recipe(recipe.name, requirements, results, recipe.defaultLimit, 0, (int)recipe.defaultPriority);

                    ServerManager.RecipeStorage.AddLimitTypeRecipe(recipe.Job, newRecipe);

                    if (recipe.JobBlock != null && recipe.JobBlock.Count != 0)
                    {
                        foreach (var block in recipe.JobBlock)
                        {
                            if (!ServerManager.RecipeStorage.BlockNameToLimitTypeMapping.ContainsKey(block))
                            {
                                ServerManager.RecipeStorage.AddBlockToRecipeMapping(block, recipe.Job);
                            }
                        }
                    }

                    sb.Append($"{recipe.name}, ");
                    i++;

                    if (i > 5)
                    {
                        i = 0;
                        sb.AppendLine();
                    }
                }
            }

            APILogger.LogToFile(sb.ToString());
            APILogger.LogToFile("---------------------------------------------------------");
        }
예제 #21
0
        //Ref menu is added for change LocalStorage -> avoid client error
        public static bool LoadItem(JSONNode item, ref NetworkMenu menu, Players.Player player, out List <IItem> menuItem)
        {
            string itemType = item.GetAs <string>("type").Trim().ToLower();
            bool   found    = false;

            menuItem = null;

            switch (itemType)
            {
            case "patchnotes":
                if (item.TryGetAsOrDefault <string>("mod", out string mod, ""))
                {
                    var info = default(JSONNode);

                    foreach (var modJson in GameInitializer.AllModInfos.Values)
                    {
                        if (modJson.TryGetAs("name", out string modName) && string.Equals(mod, modName, StringComparison.InvariantCultureIgnoreCase))
                        {
                            info = modJson;
                            break;
                        }
                    }

                    if (info.TryGetAs <JSONNode>("patchnotes", out var patchNotesJson))
                    {
                        int i = 0;
                        menuItem = new List <IItem>();

                        foreach (var node in patchNotesJson.LoopArray())
                        {
                            i++;

                            node.TryGetAsOrDefault("version", out string version, "Undefined");
                            menuItem.Add(new Label(new LabelData("Version " + version, UnityEngine.TextAnchor.MiddleLeft, 24, LabelData.ELocalizationType.None)));

                            if (node.TryGetAs <JSONNode>("notes", out var versionNotesJson))
                            {
                                foreach (var note in versionNotesJson.LoopArray())
                                {
                                    menuItem.Add(new Label(new LabelData("    * " + note.ToString().Replace("\"", ""), UnityEngine.TextAnchor.MiddleLeft, 14, LabelData.ELocalizationType.None)));
                                }
                            }

                            if (i > 10)
                            {
                                break;
                            }
                        }
                    }
                }
                else
                {
                    APILogger.Log(ChatColor.red, "found patchnotes wiki item but mod property was not found");
                }

                found = true;
                break;
예제 #22
0
        public static IRoamingJobObjective GetCallbacks(string objectiveName)
        {
            if (ObjectiveCallbacks.ContainsKey(objectiveName))
            {
                return(ObjectiveCallbacks[objectiveName]);
            }

            APILogger.Log($"Unknown objective {objectiveName}.");
            return(null);
        }
예제 #23
0
        public static void OnUpdate()
        {
            if (GameInitializer.WorldLoaded && _nextUpdate < Time.SecondsSinceStartDouble)
            {
                lock (Objectives)
                {
                    foreach (var machine in Objectives)
                    {
                        foreach (var category in machine.Value)
                        {
                            var invalidKeys = new List <Vector3Int>();

                            foreach (var state in category.Value)
                            {
                                try
                                {
                                    if (!state.Value.PositionIsValid())
                                    {
                                        invalidKeys.Add(state.Key);
                                    }
                                    else
                                    {
                                        state.Value.RoamingJobSettings.DoWork(machine.Key, state.Value);

                                        foreach (var objectiveLoad in state.Value.ActionEnergy)
                                        {
                                            if (objectiveLoad.Value <= 0 &&
                                                state.Value.RoamingJobSettings.ActionCallbacks.TryGetValue(objectiveLoad.Key, out var objectiveAction))
                                            {
                                                Indicator.SendIconIndicatorNear(state.Value.Position.Add(0, 1, 0).Vector,
                                                                                new IndicatorState(OBJECTIVE_REFRESH,
                                                                                                   objectiveAction.ObjectiveLoadEmptyIcon.Id,
                                                                                                   true,
                                                                                                   false));
                                            }
                                        }
                                    }
                                }
                                catch (Exception ex)
                                {
                                    APILogger.LogError(ex);
                                }
                            }

                            foreach (var key in invalidKeys)
                            {
                                category.Value.Remove(key);
                            }
                        }
                    }
                }

                _nextUpdate = Time.SecondsSinceStartDouble + OBJECTIVE_REFRESH;
            }
        }
예제 #24
0
 public WrapperCache(Cache cache)
 {
     _webCache = cache;
     try
     {
         _debugConfigurations = new DebugAPIConfiguraions();
         _apiLogger           = new APILogger(cache.CacheId, _debugConfigurations);
     }
     catch (Exception)
     { }
 }
예제 #25
0
        public PandaResearchable(IPandaResearch pandaResearch, int currentLevel)
        {
            Conditions    = new List <IResearchableCondition>();
            RecipeUnlocks = new List <RecipeUnlock>();
            Dependencies  = new List <string>();

            try
            {
                List <IResearchableCondition> researchableConditions;

                if (pandaResearch.Conditions != null && (pandaResearch.Conditions.TryGetValue(currentLevel, out researchableConditions) || pandaResearch.Conditions.TryGetValue(0, out researchableConditions)))
                {
                    Conditions.AddRange(researchableConditions);
                }

                List <string> dependancies = null;

                if (pandaResearch.Dependancies != null && !pandaResearch.Dependancies.TryGetValue(currentLevel, out dependancies))
                {
                    pandaResearch.Dependancies.TryGetValue(0, out dependancies);
                }

                Initialize(currentLevel, pandaResearch.name, pandaResearch.BaseValue, pandaResearch.IconDirectory, dependancies, pandaResearch.BaseIterationCount, pandaResearch.AddLevelToName);

                List <InventoryItem> inventoryItems;

                if (pandaResearch.RequiredItems != null && (pandaResearch.RequiredItems.TryGetValue(currentLevel, out inventoryItems) || pandaResearch.RequiredItems.TryGetValue(0, out inventoryItems)))
                {
                    AddCraftingCondition(inventoryItems, currentLevel);
                }

                List <RecipeUnlock> listUnlocks;
                if (pandaResearch.Unlocks != null && (pandaResearch.Unlocks.TryGetValue(currentLevel, out listUnlocks) || pandaResearch.Unlocks.TryGetValue(0, out listUnlocks)))
                {
                    RecipeUnlocks.AddRange(listUnlocks);
                }

                Register(currentLevel, pandaResearch.name);
            }
            catch (NullReferenceException nullRef)
            {
                APILogger.LogToFile(nullRef.StackTrace);
                APILogger.LogToFile(nullRef.Message);
                APILogger.LogError(nullRef);
            }
            catch (Exception ex)
            {
                APILogger.LogError(ex);
            }
        }
예제 #26
0
 public static void OnCreatedColony(Colony c)
 {
     foreach (var extension in GetCallbacks <IOnColonyCreatedExtender>())
     {
         try
         {
             extension.ColonyCreated(c);
         }
         catch (Exception ex)
         {
             APILogger.LogError(ex);
         }
     }
 }
예제 #27
0
 public static void AddItemTypes(Dictionary <string, ItemTypesServer.ItemTypeRaw> itemTypes)
 {
     foreach (var extension in GetCallbacks <IAddItemTypesExtender>())
     {
         try
         {
             extension.AddItemTypes(itemTypes);
         }
         catch (Exception ex)
         {
             APILogger.LogError(ex);
         }
     }
 }
예제 #28
0
 public static void OnChangedBlock(ModLoader.OnTryChangeBlockData tryChangeBlockData)
 {
     foreach (var extension in GetCallbacks <IOnChangedBlockExtender>())
     {
         try
         {
             extension.OnChangedBlock(tryChangeBlockData);
         }
         catch (Exception ex)
         {
             APILogger.LogError(ex);
         }
     }
 }
예제 #29
0
 public static void OnSendAreaHighlights(Players.Player player, List <AreaJobTracker.AreaHighlight> list, List <ushort> showWhileHoldingTypes)
 {
     foreach (var extension in GetCallbacks <IOnSendAreaHighlightsExtender>())
     {
         try
         {
             extension.OnSendAreaHighlights(player, list, showWhileHoldingTypes);
         }
         catch (Exception ex)
         {
             APILogger.LogError(ex);
         }
     }
 }
예제 #30
0
 public void OnLoadModJSONFiles(List <ModLoader.LoadModJSONFileContext> contexts)
 {
     foreach (var extension in GetCallbacks <IOnLoadModJSONFilesExtender>())
     {
         try
         {
             extension.OnLoadModJSONFiles(contexts);
         }
         catch (Exception ex)
         {
             APILogger.LogError(ex);
         }
     }
 }