using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Net; using ClassicalSharp.Audio; using ClassicalSharp.Commands; using ClassicalSharp.GraphicsAPI; using ClassicalSharp.Model; using ClassicalSharp.Network; using ClassicalSharp.Particles; using ClassicalSharp.Renderers; using ClassicalSharp.Selections; using ClassicalSharp.TexturePack; using OpenTK; namespace ClassicalSharp { public partial class Game : GameWindow { /// Abstracts the underlying 3D graphics rendering API. public IGraphicsApi Graphics; /// Contains the block data and metadata of the player's current world. public Map Map; /// Represents a connection to a multiplayer or a singleplayer server. public INetworkProcessor Network; /// List of all entities in the current map, including the player. public EntityList Players; /// Entity representing the player. public LocalPlayer LocalPlayer; /// Contains extended player listing information for each player in the current world. /// Only used if CPE extension ExtPlayerList is enabled. public CpeListInfo[] CpePlayersList = new CpeListInfo[256]; /// Current camera the player is using to view the world with. /// e.g. first person, thid person, forward third person, etc. public Camera Camera; Camera firstPersonCam, thirdPersonCam, forwardThirdPersonCam; /// Contains the metadata about each currently defined block. /// e.g. blocks light, height, texture IDs, etc. public BlockInfo BlockInfo; /// Total rendering time(in seconds) elapsed since the client was started. public double accumulator; public TerrainAtlas2D TerrainAtlas; public TerrainAtlas1D TerrainAtlas1D; public SkinType DefaultPlayerSkinType; /// Accumulator for the number of chunk updates performed. Reset every second. public int ChunkUpdates; /// Whether the third person camera should have their camera position clipped so as to not intersect blocks. public bool CameraClipping = true; public MapRenderer MapRenderer; public MapBordersRenderer MapBordersRenderer; public EnvRenderer EnvRenderer; public WeatherRenderer WeatherRenderer; public Inventory Inventory; public IDrawer2D Drawer2D; public CommandManager CommandManager; public SelectionManager SelectionManager; public ParticleManager ParticleManager; public PickingRenderer Picking; public PickedPos SelectedPos = new PickedPos(), CameraClipPos = new PickedPos(); public ModelCache ModelCache; internal string skinServer, chatInInputBuffer = null; internal int defaultIb; FpsScreen fpsScreen; internal HudScreen hudScreen; public Events Events = new Events(); public EntityEvents EntityEvents = new EntityEvents(); public MapEvents MapEvents = new MapEvents(); public InputHandler InputHandler; public Chat Chat; public BlockHandRenderer BlockHandRenderer; public AudioPlayer AudioPlayer; public AxisLinesRenderer AxisLinesRenderer; /// Account username of the player. public string Username; /// Verification key used for multiplayer, unique for the username and individual server. public string Mppass; /// IP address of multiplayer server connected to, null if singleplayer. public IPAddress IPAddress; /// Port of multiplayer server connected to, 0 if singleplayer. public int Port; /// Radius of the sphere the player can see around the position of the current camera. public int ViewDistance = 512; internal int MaxViewDistance = 32768, UserViewDistance = 512; /// Field of view for the current camera in degrees. public int FieldOfView = 70; internal int ZoomFieldOfView = 0; /// Strategy used to limit how many frames should be displayed at most each second. public FpsLimitMethod FpsLimit; /// Whether lines should be rendered for each axis. public bool ShowAxisLines; /// Whether players should animate using simple swinging parallel to their bodies. public bool SimpleArmsAnim; /// Whether mouse rotation on the y axis should be inverted. public bool InvertMouse; public long Vertices; public FrustumCulling Culling; int width, height; public AsyncDownloader AsyncDownloader; public Matrix4 View, Projection, HeldBlockProjection; /// How sensitive the client is to changes in the player's mouse position. public int MouseSensitivity = 30; public bool TabAutocomplete; public bool UseClassicGui, UseClassicTabList; public bool AllowCustomBlocks, UseCPE, AllowServerTextures; public int ChatLines = 12; public bool ClickableChat = false, HideGui = false, ShowFPS = true; internal float HotbarScale = 1.0f, ChatScale = 1.0f, InventoryScale = 1.0f; public bool ViewBobbing, ShowBlockInHand; public bool UseSound, UseMusic, LiquidsBreakable; public Vector3 CurrentCameraPos; public Animations Animations; internal int CloudsTexId, RainTexId, SnowTexId, GuiTexId, GuiClassicTexId; internal bool screenshotRequested; internal List WarningScreens = new List(); internal UrlsList AcceptedUrls = new UrlsList( "acceptedurls.txt" ), DeniedUrls = new UrlsList( "deniedurls.txt" ); /// Calculates the amount that the hotbar widget should be scaled by when rendered. /// Affected by both the current resolution of the window, as well as the /// scaling specified by the user (field HotbarScale). public float GuiHotbarScale { get { float scaleX = Width / 640f, scaleY = Height / 480f; return Math.Min( scaleX, scaleY ) * HotbarScale; } } /// Calculates the amount that the block inventory menu should be scaled by when rendered. /// Affected by both the current resolution of the window, as well as the /// scaling specified by the user (field InventoryScale). public float GuiInventoryScale { get { float scaleX = Width / 640f, scaleY = Height / 480f; return Math.Min( scaleX, scaleY ) * InventoryScale; } } /// Calculates the amount that 2D chat widgets should be scaled by when rendered. /// Affected by both the current resolution of the window, as well as the /// scaling specified by the user (field ChatScale). public float GuiChatScale { get { float scaleX = Width / 640f, scaleY = Height / 480f; return Math.Min( scaleX, scaleY ) * ChatScale; } } string defTexturePack = "default.zip"; /// Gets or sets the path of the default texture pack that should be used by the client. /// If the custom default texture pack specified by the user could not be found, /// this method returns "default.zip". public string DefaultTexturePack { get { string texPackDir = TexturePackExtractor.Dir; string path = Path.Combine( Program.AppDirectory, Path.Combine( texPackDir, defTexturePack ) ); return File.Exists( path ) ? defTexturePack : "default.zip"; } set { defTexturePack = value; Options.Set( OptionsKey.DefaultTexturePack, value ); } } } }