public override void Paint(Level level) { base.Paint(level); var spot = new Dot(Rnd.Int(Left + 2, Right - 2), Rnd.Int(Top + 2, Bottom - 2)); try { ChestRegistry.PlaceRandom(spot * 16 + new Vector2(8, 12), level.Area); } catch (Exception e) { Log.Error(e); } for (var x = Left + 1; x < Right - 1; x++) { for (var y = Top + 1; y < Bottom - 1; y++) { if (Rnd.Chance(30)) { continue; } var prop = new BreakableProp { Sprite = infos[Rnd.Int(infos.Length)] }; level.Area.Add(prop); prop.BottomCenter = new Vector2(x + 0.5f, y + 1f) * 16 + Rnd.Vector(-4, 4); } } Painter.Set(level, spot, Tile.FloorD); }
public static void Spawn(string modelname) { var owner = ConsoleSystem.Caller?.Pawn; if (ConsoleSystem.Caller == null) { return; } //Finds point where the player is looking at var tr = Trace.Ray(owner.EyePos, owner.EyePos + owner.EyeRot.Forward * 500) .UseHitboxes() .Ignore(owner) .Size(2) .Run(); //Spawns new prop var ent = new BreakableProp(); //sets prop position and rotation to where player is looking ent.Position = tr.EndPos; ent.Rotation = Rotation.From(new Angles(0, owner.EyeRot.Angles().yaw, 0)) * Rotation.FromAxis(Vector3.Up, 180); //set model of the prop ent.SetModel(modelname); // Drop to floor if (ent.PhysicsBody != null && ent.PhysicsGroup.BodyCount == 1) { var p = ent.PhysicsBody.FindClosestPoint(tr.EndPos); var delta = p - tr.EndPos; ent.PhysicsBody.Position -= delta; //DebugOverlay.Line( p, tr.EndPos, 10, false ); } var tr2 = Trace.Ray(owner.EyePos, owner.EyePos + owner.EyeRot.Forward * 500) .UseHitboxes() .Ignore(owner) .Size(2) .Run(); var oldSurface = tr2.Surface; Log.Info($"spawned prop with surface {oldSurface.Name}"); switch (oldSurface.Name) { case "wood.sheet": ent.PhysicsGroup.SetSurface("flood_wood"); break; } var tr3 = Trace.Ray(owner.EyePos, owner.EyePos + owner.EyeRot.Forward * 500) .UseHitboxes() .Ignore(owner) .Size(2) .Run(); Log.Info($"swapped surface to {tr3.Surface.Name}"); ent.surface = tr3.Surface; }
public override void Paint(Level level) { base.Paint(level); TrashGoblin.Place(GetTileCenter() * 16 + new Vector2(8, 8), level.Area); for (var x = Left + 1; x < Right - 1; x++) { for (var y = Top + 1; y < Bottom - 1; y++) { if (Rnd.Chance(50)) { continue; } var prop = new BreakableProp { Sprite = infos[Rnd.Int(infos.Length)] }; level.Area.Add(prop); prop.BottomCenter = new Vector2(x + 0.5f, y + 1f) * 16 + Rnd.Vector(-4, 4); } } }