Example #1
0
        /// <summary>
        /// Bind the ID through the configuration file, allowing players to customize the ID in the event of conflict
        /// </summary>
        private static void IdBind(Proto proto)
        {
            if (proto is StringProto)
            {
                return;
            }
            int index = ProtoIndex.GetIndex(proto);

            var entry = CustomID.Bind(ProtoIndex.GetProtoName(proto), proto.Name, proto.ID);

            proto.ID = entry.Value;

            if (IDDict[index].ContainsKey(proto.Name))
            {
                LDBToolPlugin.logger.LogError($"[CustomID] ID:{proto.ID} Name:{proto.Name} There is a conflict, please check.");
            }
            else
            {
                IDDict[index].Add(proto.Name, entry);
            }
        }
Example #2
0
        /// <summary>
        /// Bind GridIndex through the configuration file, allowing players to customize GridIndex in the event of conflict
        /// Execute after custom ID
        /// </summary>
        private static void GridIndexBind(Proto proto)
        {
            ConfigEntry <int> entry = null;

            if (proto is ItemProto item)
            {
                entry = CustomGridIndex.Bind(ProtoIndex.GetProtoName(proto), item.ID.ToString(), 0, $"Default Grid Index = {item.GridIndex}\nItem Name = {item.Name}");

                if (entry.Value != 0)
                {
                    item.GridIndex = entry.Value;
                }
            }
            else if (proto is RecipeProto recipe)
            {
                entry = CustomGridIndex.Bind(ProtoIndex.GetProtoName(proto), recipe.ID.ToString(), 0, $"Default Grid Index = {recipe.GridIndex}\nRecipe Name = {recipe.Name}");

                if (entry.Value != 0)
                {
                    recipe.GridIndex = entry.Value;
                }
            }

            if (entry == null)
            {
                return;
            }

            int index = ProtoIndex.GetIndex(proto);

            if (GridIndexDict[index].ContainsKey(proto.Name))
            {
                LDBToolPlugin.logger.LogError($"[CustomGridIndex] ID:{proto.ID} Name:{proto.Name} There is a conflict, please check.");
            }
            else
            {
                GridIndexDict[index].Add(proto.Name, entry);
            }
        }