Beispiel #1
0
            static void Postfix(ThingDef __instance, List <RecipeDef> __result)
            {
                // already ran; bounce
                if (hasRemovedDupesFromRecipeCache.Contains(__instance.GetHashCode()))
                {
                    return;
                }

                __result.RemoveDuplicates();
                hasRemovedDupesFromRecipeCache.Add(__instance.GetHashCode());
            }
 protected override bool TryCastShot()
 {
     if (base.TryCastShot())
     {
         ThingDef             projectile   = this.GetProjectile();
         ProjectileProperties projectile2  = projectile.projectile;
         ThingDef             equipmentDef = EquipmentSource?.def;
         if (equipmentDef is null)
         {
             Log.Error($"Unable to retrieve weapon def from <color=teal>{GetType()}</color>. Please report to Oskar or Smash Phil.");
             return(true);
         }
         MoteProperties moteProps = equipmentDef.GetModExtension <MoteProperties>();
         if (moteProps is null)
         {
             Log.ErrorOnce($"<color=teal>{GetType()}</color> cannot be used without <color=teal>MoteProperties</color> DefModExtension. Motes will not be thrown.",
                           Gen.HashCombine(projectile.GetHashCode(), "MoteProperties".GetHashCode()));
             return(true);
         }
         float size = moteProps.Size(projectile2.GetDamageAmount(caster, null));
         for (int i = 0; i < moteProps.numTimesThrown; i++)
         {
             float relAngle = Quaternion.LookRotation(CurrentTarget.CenterVector3 - Caster.Position.ToVector3Shifted()).eulerAngles.y;
             SmokeMaker.ThrowMoteDef(moteProps.moteDef, caster.PositionHeld.ToVector3Shifted(), caster.MapHeld, size, moteProps.Velocity, relAngle + moteProps.Angle, moteProps.Rotation);
         }
         return(true);
     }
     return(false);
 }
Beispiel #3
0
        public override int GetHashCode()
        {
            unchecked {
                int a = ThingDef != null?ThingDef.GetHashCode() : 0;

                return((31 * a) * 31 + Gender.GetHashCode());
            }
        }
        private static int RandomRequestCount(ThingDef thingDef, Map map)
        {
            Rand.PushState(Find.TickManager.TicksGame ^ thingDef.GetHashCode() ^ 0x343820DB);
            float num = BaseValueWantedRange.RandomInRange;

            Rand.PopState();
            num *= ValueWantedFactorFromWealthCurve.Evaluate(map.wealthWatcher.WealthTotal);
            return(ThingUtility.RoundedResourceStackCount(Mathf.Max(1, Mathf.RoundToInt(num / thingDef.BaseMarketValue))));
        }
        public override int GetHashCode()
        {
            unchecked {
                int a = thingDef != null?thingDef.GetHashCode() : 0;

                int b = stuffDef != null?stuffDef.GetHashCode() : 0;

                return((31 * a + b) * 31 + gender.GetHashCode());
            }
        }
        public override int GetHashCode()
        {
            unchecked
            {
                var a = ThingDef != null?ThingDef.GetHashCode() : 0;

                var b = StuffDef != null?StuffDef.GetHashCode() : 0;

                return((((31 * a) + b) * 31) + Gender.GetHashCode());
            }
        }
Beispiel #7
0
        public static HaulLocation DefaultHaulLocation(this ThingDef thingDef, bool haulCrates = false)
        {
            // there is a more elegant way to do this, but I'll do that later.

            if (haulCrates && thingDef.IsCrate())
            {
                return(HaulLocation.ToCarriers);
            }

            if (!thingDef.EverHaulable)
            {
                return(HaulLocation.None);
            }

            if (trashThingDefHashes.Contains(thingDef.GetHashCode()))
            {
                return(HaulLocation.ToTrash);
            }

            var categories = thingDef.thingCategories;

            foreach (var cat in categories)
            {
                if (carrierThingCategoryDefHashes.Contains(cat.GetHashCode()))
                {
                    return(HaulLocation.ToCarriers);
                }

                if (trashThingCategoryDefHashes.Contains(cat.GetHashCode()))
                {
                    return(HaulLocation.ToTrash);
                }

                foreach (var parentCat in cat.Parents)
                {
                    if (carrierThingCategoryDefHashes.Contains(parentCat.GetHashCode()))
                    {
                        return(HaulLocation.ToCarriers);
                    }

                    if (trashThingCategoryDefHashes.Contains(parentCat.GetHashCode()))
                    {
                        return(HaulLocation.ToTrash);
                    }
                }
            }

            return(HaulLocation.None);
        }
        public bool ThingsAvailableInventories(ThingDef def, Faction faction)
        {
            int  key = Gen.HashCombine(def.GetHashCode(), faction);
            bool result;

            if (!this.cachedResults.TryGetValue(key, out result))
            {
                result = map.mapPawns.SpawnedPawnsInFaction(faction)
                         .Any(p => p.inventory.GetDirectlyHeldThings().Contains(def));
                //Log.Message($"caching {def}");
                this.cachedResults.Add(key, result);
            }
            //else Log.Message($"Using cache {def}");
            return(result);
        }
        public bool ThingsAvailableInventories(ThingDef def, Pawn pawn)
        {
            int  key = Gen.HashCombine(def.GetHashCode(), pawn.Faction);
            bool result;

            if (!this.cachedResults.TryGetValue(key, out result))
            {
                result = pawn.Map.mapPawns.SpawnedPawnsInFaction(Faction.OfPlayer)
                         .Any(p => p.inventory?.GetDirectlyHeldThings().Any(t => t.def == def) ?? false);
                //Log.Message($"caching {def}");
                this.cachedResults.Add(key, result);
            }
            //else Log.Message($"Using cache {def}");
            return(result);
        }
            public override int GetHashCode()
            {
                var num1 = 7437233;

                if (Thing != null)
                {
                    num1 ^= Thing.GetHashCode() * 712433;
                }
                var num2 = num1 ^ BuildableDef.GetHashCode() * 345111;

                if (StuffDef != null)
                {
                    num2 ^= StuffDef.GetHashCode() * 666613;
                }
                var thingDef = BuildableDef as ThingDef;

                if (thingDef == null)
                {
                    return(num2);
                }

                InfusionSet inf;

                if (Thing != null && Thing.TryGetInfusions(out inf))
                {
                    if (inf.prefix != null)
                    {
                        num2 ^= inf.prefix.GetHashCode();
                    }
                    if (inf.suffix != null)
                    {
                        num2 ^= inf.suffix.GetHashCode();
                    }
                }

                if (thingDef.useHitPoints)
                {
                    num2 = num2 ^ HitPoints * 743273 ^ MaxHitPoints * 7437;
                }
                return(num2);
            }
Beispiel #11
0
        private void DrawIcon(float x, float y, ThingDef thingDef)
        {
            Rect  rect  = new Rect(x, y, 27f, 27f);
            Color color = GUI.color;

            Widgets.ThingIcon(rect, thingDef);
            GUI.color = color;
            TooltipHandler.TipRegion(rect, new TipSignal(() => thingDef.LabelCap + ": " + thingDef.description.CapitalizeFirst(), thingDef.GetHashCode()));
        }
Beispiel #12
0
        public static void DrawIcon(float x, float y, ThingDef thingDef)
        {
            Rect  rect  = new Rect(x, y, 27f, 27f);
            Color color = GUI.color;

            GUI.color = thingDef.graphicData.color;
            GUI.DrawTexture(rect, thingDef.uiIcon);
            GUI.color = color;
            TooltipHandler.TipRegion(rect, new TipSignal(() => thingDef.LabelCap + ": " + thingDef.description, thingDef.GetHashCode()));
        }