public Pebble(PebbleType type, Vector3 position, Vector3 rotation) : base(position)
        {
            Type     = type;
            Rotation = rotation;

            Mesh = new MeshDot(position, new Vector3(type.PixelColor), type.PixelSize); //TODO: Use alpha value of pebble type
            Pebbles.Add(this);
            AllowRotation = false;
        }
Exemple #2
0
        private static void ParsePebbleType(string path)
        {
            lua = new Lua();
            lua.RegisterFunction("StartPebbleConfig", null, typeof(HWData).GetMethod("StartPebbleConfig"));
            lua.DoFile(path);

            string name = Path.GetFileNameWithoutExtension(path).ToLower();

            float   pixelSize  = 1;
            Vector4 pixelColor = Vector4.Zero;

            foreach (KeyValuePair <object, object> de in pebbleConfig)
            {
                switch (de.Key.ToString())
                {
                case "pixelSize":
                    string text = de.Value.ToString();
                    text      = text.Replace(",", ".");
                    pixelSize = float.Parse(text, InvariantCulture);
                    break;

                case "pixelColour":
                    pixelColor = LuaMap.LuaTableToVector4((LuaTable)de.Value);
                    break;
                }
            }

            PebbleType existingType = null;

            foreach (PebbleType type in PebbleType.PebbleTypes)
            {
                if (type.Name == name)
                {
                    existingType = type;
                    break;
                }
            }

            //Check if a type with that name already exists (because of multiple data paths)
            if (existingType == null)
            {
                new PebbleType(name, pixelSize, pixelColor);
            }
            else
            {
                //Overwrite existing style
                existingType.Name       = name;
                existingType.PixelSize  = pixelSize;
                existingType.PixelColor = pixelColor;
            }
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                PebbleType type = PebbleType.GetTypeFromName((string)value);

                if (type != null)
                {
                    return(type);
                }
                else
                {
                    return(PebbleType.PebbleTypes[0]);
                }
            }
            return(base.ConvertFrom(context, culture, value));
        }
Exemple #4
0
        public static void AddPebble(string type, LuaTable position, float rotX, float rotY, float rotZ)
        {
            //Log.WriteLine("Adding pebble of type \"" + type + "\".");

            Vector3 pos = LuaTableToVector3(position);
            Vector3 rot = new Vector3(rotX, rotY, rotZ);

            string     newType    = type.ToLower();
            PebbleType pebbleType = PebbleType.GetTypeFromName(newType);

            if (pebbleType == null)
            {
                new Problem(ProblemTypes.WARNING, "Pebble type \"" + newType + "\" not found. Skipping pebble.");
                return;
            }

            new Pebble(pebbleType, pos, rot);
        }