public void InitItems() { Items.Clear(); CompoundItem renderStats = new CompoundItem() { Name = "Rendering Stats" }; { renderStats.Items.Add(new PrimitiveItem <float>() { Name = "FPS", GetValue = LauncherWrapper.GetFPS, Description = "Average frames per second" }); renderStats.Items.Add(new PrimitiveItem <int>() { Name = "Visible Entities", GetValue = LauncherWrapper.GetEntitiesOnScreen, Description = "Number of entities being rendered on the screen" }); } Items.Add(renderStats); CompoundItem playerStats = new CompoundItem() { Name = "Player Stats", Description = "Stats about the local player" }; { CompoundValueItem <Vec3> playerPositionStats = new CompoundValueItem <Vec3>() { Name = "Position", GetValue = LauncherWrapper.GetPlayerPosition, Description = "Position of the player using world coordinates", IsExpanded = false }; { playerPositionStats.Items.Add(new PrimitiveItem <Vec3>() { Name = "Block", GetValue = LauncherWrapper.GetPlayerBlockPosition, Description = "Position of the player to the nearest block" }); playerPositionStats.Items.Add(new PrimitiveItem <Vec3>() { Name = "Chunk", GetValue = LauncherWrapper.GetPlayerChunkPosition, Description = "Position of the player to the nearest chunk" }); } playerStats.Items.Add(playerPositionStats); CompoundValueItem <Vec2> rotationStats = new CompoundValueItem <Vec2>() { Name = "Rotation", GetValue = LauncherWrapper.GetPlayerRotation, Description = "The rotation of the player", IsExpanded = false }; { rotationStats.Items.Add(new PrimitiveItem <float>() { Name = "Pitch", GetValue = LauncherWrapper.GetPlayerPitch, Description = "Up/down rotation" }); rotationStats.Items.Add(new PrimitiveItem <float>() { Name = "Yaw", GetValue = LauncherWrapper.GetPlayerYaw, Description = "Y-Axis rotation" }); rotationStats.Items.Add(new EnumItem <BlockFace>() { Name = "Facing", GetValue = LauncherWrapper.GetPlayerFacingDirection, Description = "Direction the player is facing" }); } playerStats.Items.Add(rotationStats); playerStats.Items.Add(new PrimitiveItem <int>() { Name = "Age", GetValue = LauncherWrapper.GetPlayerAge, Description = "How old the player is (measured in game ticks)" }); playerStats.Items.Add(new PrimitiveItem <float>() { Name = "Distance Travelled", GetValue = LauncherWrapper.GetPlayerDistanceTravelled, Description = "Distance the player travelled on foot while playing the level" }); playerStats.Items.Add(new StructItem <IntVec2>() { Name = "Sky/Block Light", GetValue = LauncherWrapper.GetLightValues, Description = "Sky and block light values for the block the player is looking at (Not always accurate)" }); CompoundItem itemInHandStats = new CompoundEnumItem <DataValue>() { Name = "Item In Hand", GetValue = LauncherWrapper.GetItemIdEnum, Description = "Information about the item the player is holding", IsExpanded = false }; { itemInHandStats.Items.Add(new PrimitiveItem <short>() { Name = "Id", GetValue = LauncherWrapper.GetItemId, Description = "The Id of the item" }); itemInHandStats.Items.Add(new PrimitiveItem <short>() { Name = "Damage", GetValue = LauncherWrapper.GetItemDamage, Description = "Extra data or damage used to define the item" }); itemInHandStats.Items.Add(new PrimitiveItem <short>() { Name = "Count", GetValue = LauncherWrapper.GetItemAmount, Description = "How much of the item the player has" }); } playerStats.Items.Add(itemInHandStats); CompoundValueItem <HitResult> lookingAtInfo = new CompoundValueItem <HitResult>() { Name = "Looking At", GetValue = LauncherWrapper.GetHitResultType, Description = "The object the player is currently looking at", IsExpanded = false }; { lookingAtInfo.Items.Add(new StructItem <Vec3>() { Name = "Position", GetValue = LauncherWrapper.GetPlayerLookingAt, Description = "Position of where the player is looking" }); lookingAtInfo.Items.Add(new HitResultItem() { Name = "Info", GetValue = LauncherWrapper.GetHitResultType, Description = "Extra data about the object the player is looking at" }); } playerStats.Items.Add(lookingAtInfo); int totalAttributes = LauncherWrapper.GetPlayerAttributesLength(); if (totalAttributes > 0 && totalAttributes != 31) { CompoundItem attributeStats = new CompoundItem() { Name = "Attributes", Description = "Player attributes", IsExpanded = false }; { for (int ind = 0; ind < totalAttributes; ind++) { StringBuilder attributeName = new StringBuilder(31); int length = LauncherWrapper.GetPlayerAttributeName(ind, attributeName); string name = attributeName.ToString(); if (String.IsNullOrEmpty(name)) { continue; } int strInd = name.IndexOf(".") + 1; name = name.Substring(strInd, length - strInd); name = char.ToUpper(name[0]) + name.Substring(1); attributeStats.Items.Add(new AttributeItem() { Name = name, Index = ind, GetValue = LauncherWrapper.GetPlayerAttributValues, Description = EntityUtils.getAttributeDescription(name) }); } } playerStats.Items.Add(attributeStats); } } Items.Add(playerStats); CompoundItem levelStats = new CompoundItem() { Name = "Level Stats", Description = "Stats about the current level" }; { levelStats.Items.Add(new StringItem() { Name = "Level Name", GetValue = LauncherWrapper.GetLevelName, GetLength = LauncherWrapper.GetLevelNameLength, MaxLength = 40, Description = "The name of the current level" }); levelStats.Items.Add(new TimeItem() { Name = "Time", GetValueA = LauncherWrapper.GetLevelTime, GetValueB = LauncherWrapper.GetLevelTimeOfDay, Description = "Number of ticks since the world was started; used in-game to keep track of time" }); /* * CompoundItem weatherStats = new CompoundItem() { Name = "Weather", Description = "Stats about the weather" }; * { * * } */ } Items.Add(levelStats); }
private void updateHitStats(HitResult newValue) { Items.Clear(); switch (newValue) { case HitResult.Block: //Items = blockStats; Items.Add(new StructItem <IntVec3>() { Name = "Block Position", GetValue = LauncherWrapper.GetHitBlockPosition, Description = "Grid location of the block the player is looking at" }); Items.Add(new EnumItem <BlockFace>() { Name = "Block Face", GetValue = LauncherWrapper.GetHitFace, Description = "Which side of the block the player is looking at" }); break; case HitResult.Entity: //Items = entityStats; Items.Add(new EnumItem <EntityRenderModel>() { Name = "Type", GetValue = LauncherWrapper.GetEntityRenderModel, Description = "What type the entity is" }); Items.Add(new PrimitiveItem <Vec3>() { Name = "Position", GetValue = LauncherWrapper.GetEntityPosition, Description = "The location of the entity" }); Items.Add(new PrimitiveItem <Vec3>() { Name = "Velocity", GetValue = LauncherWrapper.GetEntityVelocity, Description = "How fast the entity is moving" }); Items.Add(new PrimitiveItem <Vec2>() { Name = "Rotation", GetValue = LauncherWrapper.GetEntityRotation, Description = "The rotation of the entity's body" }); Items.Add(new PrimitiveItem <int>() { Name = "Age", GetValue = LauncherWrapper.GetEntityAge, Description = "How old the entity is (measured in game ticks)" }); Items.Add(new PrimitiveItem <float>() { Name = "Distance Travelled", GetValue = LauncherWrapper.GetEntityDistanceTravelled, Description = "How far the entity has travelled since joining the world" }); EntityRenderModel type = LauncherWrapper.GetEntityRenderModel(); IntVec3 color = LauncherWrapper.GetEntityColor(); if (color.x + color.y + color.z > 0) { Items.Add(new ColorItem() { Name = "Color", GetValue = LauncherWrapper.GetEntityColor, Description = "The color of the entity" }); } // Horribly Slow if (EntityUtils.isMob(type)) { int totalAttributes = LauncherWrapper.GetHitEntityAttributesLength(); if (totalAttributes > 0) { CompoundItem attributeStats = new CompoundItem() { Name = "Attributes" }; { for (int ind = 0; ind < totalAttributes; ind++) { StringBuilder attributeName = new StringBuilder(31); int length = LauncherWrapper.GetHitEntityAttributeName(ind, attributeName); string name = attributeName.ToString(); if (String.IsNullOrEmpty(name)) { continue; } int strInd = name.IndexOf(".") + 1; name = name.Substring(strInd, length - strInd); name = char.ToUpper(name[0]) + name.Substring(1); attributeStats.Items.Add(new AttributeItem() { Name = name, Index = ind, GetValue = LauncherWrapper.GetHitEntityAttributValues, Description = EntityUtils.getAttributeDescription(name) }); } } Items.Add(attributeStats); } } break; default: break; } }