public override void DrawHoverInfo() { string text = "EMPTY"; if (this.contains != (System.Type)null) { text = this.contains.Name; } Graphics.DrawString(text, this.position + new Vec2((float)(-(double)Graphics.GetStringWidth(text) / 2.0), -16f), Color.White, new Depth(0.9f)); if (!(this.contains != (System.Type)null)) { return; } if (this._hoverThing == null || this._hoverThing.GetType() != this.contains) { this._hoverThing = Editor.CreateThing(this.contains) as PhysicsObject; } if (this._hoverThing == null) { return; } Vec2 vec2 = Maths.AngleToVec(Maths.DegToRad(this.direction)) * this.firePower; this._hoverThing.position = this.position + vec2.normalized * 8f; this._hoverThing.hSpeed = vec2.x; this._hoverThing.vSpeed = vec2.y; Vec2 position = this._hoverThing.position; for (int index = 0; index < 100; ++index) { this._hoverThing.UpdatePhysics(); Graphics.DrawLine(position, this._hoverThing.position, Color.Red, 2f, new Depth(1f)); position = this._hoverThing.position; } }
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; }
public override void Update() { if (Level.current.simulatePhysics) { this._spawnWait += 0.0166666f; } if (Level.current.simulatePhysics && Network.isServer && (this._numSpawned < this.spawnNum || this.spawnNum == -1) && (double)this._spawnWait >= (double)this.spawnTime) { if ((double)this.initialDelay > 0.0) { this.initialDelay -= 0.0166666f; } else { Vec2 travel = Maths.AngleToVec(Maths.DegToRad(this.direction)) * this.firePower; Vec2 vec2 = this.position - travel.normalized * 16f; Level.Add((Thing) new QuadLaserBullet(vec2.x, vec2.y, travel)); this._spawnWait = 0.0f; ++this._numSpawned; } } this.angleDegrees = -this.direction; }
public override void DrawHoverInfo() => Graphics.DrawLine(this.position, this.position + Maths.AngleToVec(Maths.DegToRad(this.direction)) * (this.firePower * 5f), Color.Red, 2f, new Depth(1f));