Ejemplo n.º 1
0
        private DarkNetTrader InitTrader(DarkNetTraderDef def)
        {
            DarkNetTrader newTrder = (DarkNetTrader)Activator.CreateInstance(def.workerClass);

            newTrder.def = def;
            newTrder.FirstInit();

            return(newTrder);
        }
Ejemplo n.º 2
0
        public static EmailMessage FormMessageFromDarkNet(string text, string subject, DarkNetTraderDef trader)
        {
            Faction  darkNetFaction = Find.FactionManager.FirstFactionOfDef(FactionDefOfLocal.DarkNetTraders);
            EmailBox Owner          = QuestsManager.Communications.PlayerBox;

            EmailMessage message = new EmailMessage();

            message.Faction     = darkNetFaction;
            message.To          = Owner.Owner.Name;
            message.From        = $"{darkNetFaction?.Name} ({trader.LabelCap})";
            message.Subject     = subject;
            message.Message     = text;
            message.SendTick    = Find.TickManager.TicksGame;
            message.MessageRead = false;

            return(message);
        }
Ejemplo n.º 3
0
        public static bool TryGetPriceModificator(Thing useItem, DarkNetTraderDef traderDef, out PriceModificatorDef modificator)
        {
            Thing item = useItem;

            modificator = null;

            MinifiedThing minifiedThing = item as MinifiedThing;

            if (minifiedThing != null)
            {
                item = minifiedThing.InnerThing;
            }

            if (traderDef.AllowedPriceModificatorsFilter == null || traderDef.AllowedPriceModificatorsFilter.AllowedPriceModificators == null)
            {
                return(false);
            }

            List <PriceModificatorDef> allowedModificators = traderDef.AllowedPriceModificatorsFilter.AllowedPriceModificators.Where(delegate(PriceModificatorDef x)
            {
                if (x.SpecialThings != null && x.SpecialThings.Contains(item.def))
                {
                    return(true);
                }

                if (x.LinkedCategory != null && item.def.thingCategories != null)
                {
                    foreach (var category in x.LinkedCategory)
                    {
                        if (item.def.thingCategories.Contains(category))
                        {
                            return(true);
                        }
                    }
                }

                if (x.TradeCategories != null && item.def.tradeTags != null)
                {
                    foreach (var category in x.TradeCategories)
                    {
                        if (item.def.tradeTags.Contains(category))
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }).ToList();

            if (allowedModificators.Count == 0)
            {
                return(false);
            }

            if (allowedModificators.TryRandomElementByWeight(x => x.Commonality, out modificator))
            {
                return(true);
            }

            return(false);
        }