Beispiel #1
0
        public Client(IFabricable factory)
        {
            Vehicule voiture1 = factory.CreerVoiture();
            Vehicule scooter1 = factory.CreerScooter();

            MesCatalogue = new List <Vehicule> {
                voiture1, scooter1
            };
        }
        public static void LoadPlugins()
        {
            GameEngine.SayToServer(" - Scanning for plugins...");
            foreach (string dll in Directory.GetFiles(".", "*.dll"))
            {
                // Prevent snagging on self when running as deployed executable
                if (dll.Contains(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name))
                {
                    continue;
                }

                Assembly asm = Assembly.LoadFrom(dll);
                foreach (Type type in asm.GetTypes())
                {
                    if (type.GetInterface("IPluggable") == typeof(IPluggable))
                    {
                        IPluggable thisPlugin = Activator.CreateInstance(type) as IPluggable;
                        GameEngine.SayToServer($"{thisPlugin.Name}...");
                        AllPlugins.Add(thisPlugin);
                        if (type.GetInterface("IMappable") == typeof(IMappable))
                        {
                            IMappable mapPlugin = Activator.CreateInstance(type) as IMappable;
                            Mappers.Add(mapPlugin);
                        }
                        if (type.GetInterface("ISpawnable") == typeof(ISpawnable))
                        {
                            ISpawnable spawnPlugin = Activator.CreateInstance(type) as ISpawnable;
                            Spawners.Add(spawnPlugin);
                        }
                        if (type.GetInterface("IPlayerModifiable") == typeof(IPlayerModifiable))
                        {
                            IPlayerModifiable playerPlugin = Activator.CreateInstance(type) as IPlayerModifiable;
                            PlayerMods.Add(playerPlugin);
                        }
                        if (type.GetInterface("ICanOverrideAttackMethod") == typeof(ICanOverrideAttackMethod))
                        {
                            ICanOverrideAttackMethod combatPlugin = Activator.CreateInstance(type) as ICanOverrideAttackMethod;
                            AttackMod = combatPlugin;
                        }
                        if (type.GetInterface("ISpeakable") == typeof(ISpeakable))
                        {
                            ISpeakable speechMod = Activator.CreateInstance(type) as ISpeakable;
                            SpeechMods.Add(speechMod);
                        }
                        if (type.GetInterface("IFabricable") == typeof(IFabricable))
                        {
                            IFabricable templateMod = Activator.CreateInstance(type) as IFabricable;
                            TemplateMods.Add(templateMod);
                        }
                    }
                }
            }
            GameEngine.SayToServer("done.\n");
        }