Example #1
0
        private bool SearchFilter(ProtoEntityViewModel entityViewModel)
        {
            var searchTextLowCase = searchText.ToLower();

            return(entityViewModel.TypeLower.Contains(searchTextLowCase) ||
                   entityViewModel.TitleLower.Contains(searchTextLowCase));
        }
Example #2
0
 public ViewModelEntityInformation(string header, ProtoEntityViewModel protoEntityViewModel)
 {
     Header     = header;
     Collection = new ObservableCollection <ProtoEntityViewModel>()
     {
         protoEntityViewModel
     };
     CollectionVisibility = Visibility.Visible;
 }
Example #3
0
 public ViewModelEntityInformation(string header, ProtoEntityViewModel protoEntityViewModel, double intensity)
 {
     if (protoEntityViewModel is ProtoStatusEffectViewModel protoStatusEffectViewModel)
     {
         Header                  = header;
         StatusEffect            = protoStatusEffectViewModel;
         StatusEffectVisibility  = Visibility.Visible;
         ToolTipIntensityPercent = intensity * 100;
         StatusEffectBackground  = protoStatusEffectViewModel.GetBackgroundBrush(intensity);
     }
     else
     {
         Api.Logger.Error("CNEI: Wrong status effect in entity information " + protoEntityViewModel.ProtoEntity);
     }
 }
Example #4
0
        public ViewModelEntityWithCount(ProtoEntityViewModel entityViewModel, int count, int countRandom,
                                        double probability) : this(entityViewModel, count)
        {
            if (countRandom > 0)
            {
                CountString = "(" + count + "-" + (count + countRandom) + ") x";
            }

            if (0 < probability && probability <= 1)
            {
                CountString += " " + (probability * 100) + "%";
            }
            else
            {
                Api.Logger.Warning("CNEI: Wrong probability (" + probability + ") for " + entityViewModel);
            }
        }
Example #5
0
        public void Add(Type type, ProtoEntityViewModel entityViewModel)
        {
            if (GetNameWithoutGenericArity(type.ToString()) == FullName)
            {
                return;
            }

            var localNode = this;
            var tempType  = type.BaseType;

            while (GetNameWithoutGenericArity(type.BaseType?.ToString()) != localNode.FullName)
            {
                while (GetNameWithoutGenericArity(tempType?.BaseType?.ToString()) != localNode.FullName)
                {
                    tempType = tempType?.BaseType;
                }

                var tempNode = localNode.Derivatives
                               .FirstOrDefault(n => n.FullName == GetNameWithoutGenericArity(tempType?.ToString()));
                if (tempNode == null)
                {
                    tempNode = new TypeHierarchy(tempType, localNode);
                    localNode.Derivatives.Add(tempNode);
                    localNode.IsChild = false;
                }

                localNode = tempNode;
                tempType  = type.BaseType;
            }

            var newNode = new TypeHierarchy(type, localNode, entityViewModel);

            localNode.Derivatives.Add(newNode);
            localNode.IsChild = false;
            localNode.EntityViewModelsList.Add(entityViewModel);
            do
            {
                localNode.EntityViewModelsFullList.Add(entityViewModel);
                localNode = localNode.Parent;
            } while (localNode != null);
        }
Example #6
0
        /// <summary>
        /// Constructor for entity with droplist.
        /// Must be used only in InitEntityRelationships phase.
        /// </summary>
        /// <param name="entityViewModel">View Model of entity with droplist.</param>
        /// <param name="droplist">Droplist</param>
        public RecipeViewModel([NotNull] ProtoEntityViewModel entityViewModel, [NotNull] IEnumerable <IProtoItem> droplist)
            : base(entityViewModel.ProtoEntity)
        {
            if (!EntityViewModelsManager.EntityDictonaryCreated)
            {
                throw new Exception("CNEI: Droplist constructor used before all entity VMs sets.");
            }
            InputItemsVMList =
                new List <BaseViewModel>()
            {
                new ViewModelEntityWithCount(entityViewModel)
            }.AsReadOnly();

            HashSet <IProtoItem> uniqueDroplist = new HashSet <IProtoItem>(droplist);

            OutputItemsVMList = uniqueDroplist
                                .Select(item => new ViewModelEntityWithCount(EntityViewModelsManager.GetEntityViewModel(item)))
                                .ToList().AsReadOnly();

            OriginVisibility = Visibility.Collapsed;
            TechVisibility   = Visibility.Collapsed;
        }
Example #7
0
 public TypeHierarchy(Type type, TypeHierarchy parent, ProtoEntityViewModel entityViewModel)
     : this(type, parent)
 {
     EntityViewModel = entityViewModel;
 }
Example #8
0
 public ViewModelEntityWithCount(ProtoEntityViewModel entityViewModel)
 {
     EntityViewModel = entityViewModel;
     CountString     = "";
 }
Example #9
0
 public ViewModelEntityWithCount(ProtoEntityViewModel entityViewModel, int count) : this(entityViewModel)
 {
     CountString += count + " x";
 }