public override void Initialize() { List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables); physicsObjects.RemoveAll((Predicate <System.Type>)(t => t == typeof(Present) || t == typeof(LavaBarrel) || t == typeof(Grapple))); this._contains = physicsObjects[Rando.Int(physicsObjects.Count - 1)]; }
public static System.Type PickType(int chanceGroup, List <TypeProbPair> contains) { ItemBox.GetPhysicsObjects(Editor.Placeables); Random random = new Random((int)((double)Level.GetChanceGroup2(chanceGroup) * 2147483648.0 - 1.0)); Random generator = Rando.generator; Rando.generator = random; IOrderedEnumerable <TypeProbPair> orderedEnumerable = contains.OrderBy <TypeProbPair, float>((Func <TypeProbPair, float>)(x => Rando.Float(1f))); System.Type type = (System.Type)null; float num = 0.0f; foreach (TypeProbPair typeProbPair in (IEnumerable <TypeProbPair>)orderedEnumerable) { if ((double)Rando.Float(1f) > 1.0 - (double)typeProbPair.probability) { type = typeProbPair.type; break; } if ((double)typeProbPair.probability > (double)num) { num = typeProbPair.probability; type = typeProbPair.type; } } Rando.generator = generator; return(type); }
public override PhysicsObject GetSpawnItem() { List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables); physicsObjects.RemoveAll((Predicate <System.Type>)(t => t == typeof(LavaBarrel) || t == typeof(Grapple))); this.contains = physicsObjects[NetRand.Int(physicsObjects.Count - 1)]; PhysicsObject thing = Editor.CreateThing(this.contains) as PhysicsObject; if (Rando.Int(1000) == 1 && thing is Gun && (thing as Gun).CanSpawnInfinite()) { (thing as Gun).infiniteAmmoVal = true; (thing as Gun).infinite.value = true; } return(thing); }
public void Spawn() { if (this.randomSpawn) { List <System.Type> physicsObjects = ItemBox.GetPhysicsObjects(Editor.Placeables); this.contains = physicsObjects[Rando.Int(physicsObjects.Count - 1)]; } this._spawnWait = 0.0f; ++this._numSpawned; if (!(Editor.CreateThing(this.contains) is PhysicsObject thing)) { return; } Vec2 vec2 = Maths.AngleToVec(Maths.DegToRad(this.direction)) * this.firePower; thing.position = this.position + vec2.normalized * 8f; thing.hSpeed = vec2.x; thing.vSpeed = vec2.y; Level.Add((Thing)thing); Level.Add((Thing)SmallSmoke.New(thing.x, thing.y)); Level.Add((Thing)SmallSmoke.New(thing.x, thing.y)); SFX.Play("netGunFire", Rando.Float(0.9f, 1f), Rando.Float(-0.1f, 0.1f)); if (thing is Equipment) { (thing as Equipment).autoEquipTime = 0.5f; } if (thing is ChokeCollar) { (thing as ChokeCollar).ball.hSpeed = thing.hSpeed; (thing as ChokeCollar).ball.vSpeed = thing.vSpeed; } if (!(thing is Sword)) { return; } (thing as Sword)._wasLifted = true; (thing as Sword)._framesExisting = 16; }