Ejemplo n.º 1
0
        void ParseSignInfo(TileEntitySign SignEntity, int X, int Y, int Z, ChunkRef Chunk)
        {
            // *** Try to create a sign from the entity.  NULL will be returned if the sign doesn't map to anything.
            SignBase Sign = CreateSign(SignEntity.Text1);

            if (Sign == null)
            {
                return;
            }

            // *** Pre-set the Location var...
            Sign.Location = new Point(SignEntity.X, SignEntity.Z);

            // *** ...and pass control to the sign's validation/setup function.
            if (!Sign.CreateFrom(SignEntity))
            {
                return;
            }

            // *** Now scan for and process any "rider" signs that might add additional information.
            TileEntity Ent;

            // *** This is kind of ugly but oh well
            do
            {
                Ent = Chunk.Blocks.SafeGetTileEntity(X, --Y, Z);
            } while (Y > 0 && Ent is TileEntitySign && Sign.AddSign((TileEntitySign)Ent));

            if (Sign.IsValid())
            {
                _ExportableSigns.Add(Sign);
            }
        }
Ejemplo n.º 2
0
        static Dictionary <String, Type> CreateSignMap()
        {
            Dictionary <String, Type> Map = new Dictionary <String, Type>();
            List <Type> Plugins           = new List <Type>();
            string      FolderPath        = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Path.DirectorySeparatorChar + "Signs";

            if (!Directory.Exists(FolderPath))
            {
                return(Map);
            }
            foreach (FileInfo DllFile in new DirectoryInfo(FolderPath).GetFiles("*.dll"))
            {
                try
                {
                    foreach (Type ClassDef in Assembly.LoadFrom(DllFile.FullName).GetTypes().Where(classType => typeof(SignBase).IsAssignableFrom(classType)))
                    {
                        try
                        {
                            Plugins.Add(ClassDef);
                        }
                        catch
                        {
                            // *** Handle a broken or incompatible Class - by skipping it.
                            continue;
                        }
                    }
                }
                catch
                {
                    // *** Handle a broken or incompatible DLL - by skipping it.
                    continue;
                }
            }

            foreach (Type ClassDef in Plugins)
            {
                try
                {
                    SignBase Sign = (SignBase)Activator.CreateInstance(ClassDef, true);
                    Map.Add("[" + Sign.SignType() + "]", ClassDef);
                    Console.WriteLine("Registered sign type " + ClassDef.Name);
                } catch (Exception Ex) {
                    Console.WriteLine("Failure registering plugin class " + ClassDef.AssemblyQualifiedName);
                    Console.WriteLine("    " + Ex.Message);
                }
            }

            return(Map);
        }