Exemplo n.º 1
0
        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;
            }
        }
 public static bool isMob(EntityRenderModel type)
 {
     return(!(type == EntityRenderModel.None || type == EntityRenderModel.Minecart || type == EntityRenderModel.Boat || type == EntityRenderModel.Painting || type == EntityRenderModel.Falling_Block || type == EntityRenderModel.Lightning_Bolt));
 }