public override int GetHashCode() { unchecked { return((position.GetHashCode() * 397) ^ color.GetHashCode()); } }
public static void TestComparison_IVEC3() { IntVec3 a = (IntVec3)RandVec3(); IntVec3 b = (IntVec3)(a.vec * 2.3f); IntVec3 c = (IntVec3) new Vector3(a.x, a.y + .001f, a.z); IntVec3 d = (IntVec3) new Vector3(a.x, a.y, a.z); IntVec3[] arr = ArrayUtility.Fill <IntVec3>(24, (i) => { return(i % 2 == 0 ? a : (IntVec3)RandVec3()); }); Assert.IsFalse(a == b); Assert.IsFalse(a == c); Assert.IsTrue(a == d); Assert.IsFalse(a.GetHashCode() == b.GetHashCode()); Assert.IsFalse(a.GetHashCode() == c.GetHashCode()); Assert.IsTrue(a.GetHashCode() == d.GetHashCode()); Assert.AreEqual(13, arr.Distinct().Count()); }
public static ThingDef GetBaseResource(Map map, IntVec3 cell) { if (!map.Biome.hasBedrock) { return(null); } Rand.PushState(); Rand.Seed = cell.GetHashCode(); ThingDef result = (from rock in Find.World.NaturalRockTypesIn(map.Tile) select rock.building.mineableThing).RandomElement(); Rand.PopState(); return(result); }
public override int GetHashCode() { IntVec3 intVec = cell; int hashCode = intVec.GetHashCode(); hashCode = (hashCode * 397) ^ radius.GetHashCode(); if (forThing != null) { hashCode = (hashCode * 397) ^ forThing.GetHashCode(); } for (int i = 0; i < defs.Count; i++) { hashCode ^= defs[i].GetHashCode(); } return(hashCode); }
public override int GetHashCode() { if (thingInt != null) { return(thingInt.GetHashCode()); } if (cellInt.IsValid) { return(Gen.HashCombine(cellInt.GetHashCode(), mapInt)); } if (worldObjectInt != null) { return(worldObjectInt.GetHashCode()); } if (tileInt >= 0) { return(tileInt); } return(-1); }
public static bool SpreadBuilding(IntVec3 dir, Map map) { if (!HasNoBuildings(dir, map)) { return(false); } var random = new System.Random(dir.GetHashCode()); var mutateChance = random.Next(1, 100); if (30 < mutateChance) { return(false); } random = new System.Random(dir.GetHashCode() + dir.GetHashCode()); var mutateRate = random.Next(1, 100); if (mutateRate >= 0 && mutateRate <= 5) { var gasPump = (Building_GasPump)ThingMaker.MakeThing(PurpleIvyDefOf.GasPump); GenSpawn.Spawn(gasPump, dir, map); return(true); } if (mutateRate >= 6 && mutateRate <= 10) { var genMortar = (Building_Turret)ThingMaker.MakeThing(PurpleIvyDefOf.Turret_GenMortarSeed); GenSpawn.Spawn(genMortar, dir, map); return(true); } if (mutateRate >= 11 && mutateRate <= 15) { var genTurret = (Building_Turret)ThingMaker.MakeThing(PurpleIvyDefOf.GenTurretBase); GenSpawn.Spawn(genTurret, dir, map); return(true); } if (mutateRate >= 16 && mutateRate <= 17) { var eggSac = (Building_EggSac)ThingMaker.MakeThing(PurpleIvyDefOf.EggSac); GenSpawn.Spawn(eggSac, dir, map); return(true); } if (mutateRate >= 18 && mutateRate <= 19) { var eggSac = (Building_EggSac)ThingMaker.MakeThing(PurpleIvyDefOf.EggSacBeta); GenSpawn.Spawn(eggSac, dir, map); return(true); } if (mutateRate >= 20 && mutateRate <= 21) { var eggSac = (Building_EggSac)ThingMaker.MakeThing(PurpleIvyDefOf.EggSacGamma); GenSpawn.Spawn(eggSac, dir, map); return(true); } if (mutateRate < 18 || mutateRate > 23) { return(false); } var parasiteEgg = (Building_EggSac)ThingMaker.MakeThing(PurpleIvyDefOf.ParasiteEgg); GenSpawn.Spawn(parasiteEgg, dir, map); return(true); }
public override int GetHashCode() { return((cell.GetHashCode() * 397) ^ radius.GetHashCode()); }
public override int GetHashCode() { IntVec3 intVec = cell; return((intVec.GetHashCode() * 397) ^ radius.GetHashCode()); }