// -- constructor

        public ImportPipeline(OptionsBase options, FactoryBase factory, RuntimeBase runtime)
        {
            Arguments = new Dictionary <SimulationTypes, ArgumentsBase>();
            Options   = options;
            Factory   = factory;
            Runtime   = runtime;
        }
        public static IEnumerable <ResourceElement> GetResourceElements(string fullPath)
        {
            string pathOrig = Path.Combine(fullPath, Constants.OutputDirOriginal);
            string pathEdit = Path.Combine(fullPath, Constants.OutputDirEdit);

            //loop through all folders
            foreach (string directory in Directory.GetDirectories(pathOrig))
            {
                //get factory for this folder
                string      cat = directory.Split(Path.DirectorySeparatorChar).Last();
                FactoryBase b   = Factories.Single(f => f.Category == cat);

                Logger.Info($"Packing {b.Category} files...");

                //loop through files and read them from disk
                foreach (string filePath in Directory.GetFiles(directory))
                {
                    string fileName = Path.GetFileName(filePath);
                    Logger.Debug($"Reading resource {fileName}");

                    //get change path to edit folder if possible
                    string edit = filePath.Replace(pathOrig, pathEdit);

                    //read the file using the approperiate name
                    ResourceBase res = b.ReadResource(File.OpenRead(File.Exists(edit) ? edit : filePath));

                    //if ResourceName is not set, take the file name and remove the extensions
                    //then, serialize it back into an IResourceData and return it
                    yield return(new ResourceElement {
                        Name = res.ResourceName ?? fileName.Remove(fileName.Length - res.FileExtension.Length),
                        ResourceData = res.Serialize()
                    });
                }
            }
        }
    public void SelectTile(TaskableBase tile)
    {
        DeselectTile();

        selectedObject = tile;
        selectedIcon.SetActive(true);
        selectedIcon.transform.parent   = selectedObject.transform;
        selectedIcon.transform.position = selectedObject.transform.position;

        BuildingBase buildingObject = tile.GetComponent <BuildingBase>();
        WallBase     wallObject     = tile.GetComponent <WallBase>();
        HaulableBase haulObject     = tile.GetComponent <HaulableBase>();

        if (buildingObject)
        {
            if (buildingObject.currentTask)
            {
                taskActionBarInstance = Instantiate(taskActionBarPrefab, transform);
                taskActionBarInstance.Setup(buildingObject);
            }
            else
            {
                buildingActionBarInstance = Instantiate(buildingActionBarPrefab, transform);
                buildingActionBarInstance.Setup(buildingObject);

                FactoryBase factoryObject = buildingObject.GetComponent <FactoryBase>();
                if (factoryObject)
                {
                    factoryActionBarInstance = Instantiate(factoryActionBarPrefab, transform);
                    factoryActionBarInstance.Setup(factoryObject);
                }
            }
        }
        else if (wallObject)
        {
            if (wallObject.currentTask)
            {
                taskActionBarInstance = Instantiate(taskActionBarPrefab, transform);
                taskActionBarInstance.Setup(wallObject);
            }
            else
            {
                wallActionBarInstance = Instantiate(wallActionBarPrefab, transform);
                wallActionBarInstance.Setup(wallObject);
            }
        }
        else if (haulObject)
        {
            if (haulObject.currentTask)
            {
                taskActionBarInstance = Instantiate(taskActionBarPrefab, transform);
                taskActionBarInstance.Setup(haulObject);
            }
            else
            {
                haulableActionBarInstance = Instantiate(haulableActionBarPrefab, transform);
                haulableActionBarInstance.Setup(haulObject);
            }
        }
    }
Exemple #4
0
        public static Reflector CreateReflectorB()
        {
            int[] mapping = FactoryBase.ConvertMapping(REFLECTOR_B);

            var result = new Reflector(mapping);

            return(result);
        }
Exemple #5
0
        public static ThinReflector CreateThinReflectorC()
        {
            int[] mapping = FactoryBase.ConvertMapping(REFLECTOR_C_THIN);

            var result = new ThinReflector(mapping);

            return(result);
        }
Exemple #6
0
        public static ThinRotor CreateRotorGamma()
        {
            int[] mapping = FactoryBase.ConvertMapping(ROTOR_GAMMA);

            var result = new ThinRotor(mapping, 0);

            return(result);
        }
Exemple #7
0
        private static void GetAUser()
        {
            Console.Write("Please enter the User ID: ");
            int      id = int.Parse(Console.ReadLine());
            IUserDTO retrievedUserDTO = FactoryBase.CreateDTOInstance <IUserDTO>();

            retrievedUserDTO = userBDC.GetAUser(id);
            PrintJSONifyUserDTO(retrievedUserDTO);
        }
Exemple #8
0
        public static Rotor CreateRotorIV()
        {
            int[] mapping        = FactoryBase.ConvertMapping(ROTOR_IV);
            int[] notchPositions = new[] { 'J' - 'A' };

            var result = new Rotor(mapping, notchPositions, 0);

            return(result);
        }
    private void Start()
    {
        FactoryBase factory1 = Factory.Create(0);

        Debug.Log(factory1.Title);
        FactoryBase factory2 = Factory.Create(1);

        Debug.Log(factory2.Title);
    }
Exemple #10
0
        public static Rotor CreateRotorVIII()
        {
            int[] mapping        = FactoryBase.ConvertMapping(ROTOR_VIII);
            int[] notchPositions = new[] { ('Z' - 'A'), ('M' - 'A') };

            var result = new Rotor(mapping, notchPositions, 0);

            return(result);
        }
Exemple #11
0
        public IUserDTO GetAUser(int id)
        {
            IUserDTO userDTO = FactoryBase.CreateDTOInstance <IUserDTO>();

            using (UserStoryEntities context = new UserStoryEntities())
            {
                User user = context.Users.Find(id);
                EntityConverter.FillDTOFromEntity(userDTO, user);
            }
            return(userDTO);
        }
Exemple #12
0
        public static LabelBase GetInstance(string labelName)
        {
            var type     = FactoryBase.GetType(GetClassNames(labelName).ToArray());
            var instance = FactoryBase.CreateInstance <LabelBase>(type, null);

            if (instance != null)
            {
                instance.LabelName = labelName;
            }
            return(instance);
        }
Exemple #13
0
    private void Awake()
    {
        enemyFactory    = NPCFactory.GetFactory(NPCType.ENEMY);
        friendlyFactory = NPCFactory.GetFactory(NPCType.FRIEND);

        flyingEnemy  = enemyFactory.GetEnemy(EnemyType.FLYING);
        walkingEnemy = enemyFactory.GetEnemy(EnemyType.WALKING);

        flyingFriend  = friendlyFactory.GetFriendly(FriendType.FLYING);
        walkingFriend = friendlyFactory.GetFriendly(FriendType.WALKING);
    }
Exemple #14
0
        public ChemicalGroup(FactoryBase chemicalFactory, bool canBeUnlocked = true)
        {
            if (chemicalFactory == null)
            {
                throw new ArgumentNullException();
            }

            IsLocked      = false;
            CanBeUnlocked = canBeUnlocked;
            m_elements    = new List <ChemicalElement>();
            Factory       = chemicalFactory;
        }
Exemple #15
0
    private void Start()
    {
        factory = GetComponentInParent <FactoryBase <T> >();

        viewModel = factory.Get(Preferences == ViewModelPreferences.Current ? 0 : ViewModelID);

        if (Preferences == ViewModelPreferences.Current)
        {
            ViewModelSubscriptionHandler.Instance.Subscribe(typeof(T), OnViewModelChanged);
        }

        Init();
    }
    public void Setup(FactoryBase factory)
    {
        this.factory = factory;
        int i = 0;

        foreach (FactoryTask factoryTask in factory.factoryTaskPrefabs)
        {
            buttonList[i].Setup(factoryTask, () => factory.CreateTask(factoryTask));
            i++;
        }

        RefreshUI();
    }
Exemple #17
0
        public List <IUserDTO> GetAllUsers()
        {
            List <IUserDTO>   usersDTO = new List <IUserDTO>();
            UserStoryEntities context  = new UserStoryEntities();

            using (context)
            {
                foreach (User user in context.Users)
                {
                    IUserDTO userDTO = FactoryBase.CreateDTOInstance <IUserDTO>();
                    EntityConverter.FillDTOFromEntity(userDTO, user);
                    usersDTO.Add(userDTO);
                }
            }
            return(usersDTO);
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    Info info = new Info();
                    info.price = uint.Parse(fields[1], NumberFormatInfo.InvariantInfo);
                    info.x = float.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                    info.y = float.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                    info.z = float.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                    info.map = byte.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                    warps.Add(ushort.Parse(fields[0], NumberFormatInfo.InvariantInfo), info);
                }
            }
        }
        protected override void ParseAsCsvStream(System.IO.Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');
                    Type additiontype = typeof(AdditionsBonus);

                    uint AdditionId = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);
                    uint[] Functions = new uint[] { (uint)Enum.Parse( additiontype, fields[1] ), (uint)Enum.Parse( additiontype, fields[2] ), (uint)Enum.Parse( additiontype, fields[3] ),
                                                    (uint)Enum.Parse( additiontype, fields[4] ), (uint)Enum.Parse( additiontype, fields[5] ), (uint)Enum.Parse( additiontype, fields[6] ),
                                                    (uint)Enum.Parse( additiontype, fields[7] ), (uint)Enum.Parse( additiontype, fields[8] ), (uint)Enum.Parse( additiontype, fields[9] ),
                                                    (uint)Enum.Parse( additiontype, fields[10] )};

                    int[] Values = new int[] {  int.Parse( fields[11],  NumberFormatInfo.InvariantInfo ),
                                                    int.Parse( fields[12], NumberFormatInfo.InvariantInfo ),
                                                    int.Parse( fields[13], NumberFormatInfo.InvariantInfo ),
                                                    int.Parse( fields[14],  NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[15],  NumberFormatInfo.InvariantInfo ),
                                                    int.Parse( fields[16], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[17],  NumberFormatInfo.InvariantInfo ),
                                                    int.Parse( fields[18], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[19], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[20], NumberFormatInfo.InvariantInfo)};

                    Info info = Info.From(addition_table, Functions, Values);
                    if (info != null)
                    {
                        _additions.Add(AdditionId, info);
                    }
                }
            }
        }
        public static FieldParameter GetInstance(string labelName, string parameterName)
        {
            var type = FactoryBase.GetType(GetClassNames(labelName, parameterName).ToArray());

            return(FactoryBase.CreateInstance <FieldParameter>(type, new FieldParameter()));
        }
 public HasFactoryBase(FactoryBase factory)
 {
     this.factory = factory;
 }
 public FactorySurrogateSelector(FactoryBase factory)
 {
     this.factory = factory;
 }
    // Called on events that should refresh the menu
    void RefreshMenus(TaskableBase taskable)
    {
        if (taskable && taskable == selectedObject)
        {
            if (taskable.currentTask)
            {
                // Create or update task action bar
                if (taskActionBarInstance)
                {
                    taskActionBarInstance.RefreshUI();
                }
                else
                {
                    taskActionBarInstance = Instantiate(taskActionBarPrefab, transform);
                    taskActionBarInstance.Setup(selectedObject);
                }

                // clean up building and wall action bars
                if (buildingActionBarInstance)
                {
                    Destroy(buildingActionBarInstance.gameObject);
                }
                if (wallActionBarInstance)
                {
                    Destroy(wallActionBarInstance.gameObject);
                }
                if (factoryActionBarInstance)
                {
                    Destroy(factoryActionBarInstance.gameObject);
                }
                if (haulableActionBarInstance)
                {
                    Destroy(haulableActionBarInstance.gameObject);
                }
            }
            else
            {
                // Clean up task action bar
                if (taskActionBarInstance)
                {
                    Destroy(taskActionBarInstance.gameObject);
                }

                // refresh building and wall action bars
                BuildingBase buildingObject = taskable.GetComponent <BuildingBase>();
                WallBase     wallObject     = taskable.GetComponent <WallBase>();
                HaulableBase haulObject     = taskable.GetComponent <HaulableBase>();
                if (buildingObject)
                {
                    if (buildingActionBarInstance)
                    {
                        buildingActionBarInstance.RefreshUI();
                    }
                    else
                    {
                        buildingActionBarInstance = Instantiate(buildingActionBarPrefab, transform);
                        buildingActionBarInstance.Setup(buildingObject);
                    }
                    FactoryBase factoryObject = buildingObject.GetComponent <FactoryBase>();
                    if (factoryObject)
                    {
                        if (factoryActionBarInstance)
                        {
                            factoryActionBarInstance.RefreshUI();
                        }
                        else
                        {
                            factoryActionBarInstance = Instantiate(factoryActionBarPrefab, transform);
                            factoryActionBarInstance.Setup(factoryObject);
                        }
                    }
                }
                else if (wallObject)
                {
                    if (wallActionBarInstance)
                    {
                        wallActionBarInstance.RefreshUI();
                    }
                    else
                    {
                        wallActionBarInstance = Instantiate(wallActionBarPrefab, transform);
                        wallActionBarInstance.Setup(wallObject);
                    }
                }
                else if (haulObject)
                {
                    if (haulableActionBarInstance)
                    {
                        haulableActionBarInstance.RefreshUI();
                    }
                    else
                    {
                        haulableActionBarInstance = Instantiate(haulableActionBarPrefab, transform);
                        haulableActionBarInstance.Setup(haulObject);
                    }
                }
            }
        }
    }
        /// <summary>
        /// Default included event that invokes a csv based stream.
        /// </summary>
        /// <param name="stream">Stream to read data from</param>
        /// <param name="ProgressReport">Class to report the state of reading</param>
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    //LOAD A HEIGHTMAP
                    HeightMap heightmap = new HeightMap();
                    HeightMap.HeightMapInfo info = new HeightMap.HeightMapInfo();

                    try
                    {
                        //FILL OUT HEIGHTMAP INFORMATION
                        string filename = Path.Combine(Environment.CurrentDirectory, dirHeightmap);
                        if (fields[10].Length > 0)
                        {
                            info.location[0] = float.Parse(fields[12], NumberFormatInfo.InvariantInfo);
                            info.location[1] = float.Parse(fields[13], NumberFormatInfo.InvariantInfo);
                            info.location[2] = float.Parse(fields[14], NumberFormatInfo.InvariantInfo);
                            info.scale[0] = int.Parse(fields[15], NumberFormatInfo.InvariantInfo);
                            info.scale[1] = int.Parse(fields[16], NumberFormatInfo.InvariantInfo);
                            info.scale[2] = int.Parse(fields[17], NumberFormatInfo.InvariantInfo);
                            info.size = int.Parse(fields[11], NumberFormatInfo.InvariantInfo);
                            filename = Path.Combine(filename, fields[10]);

                            //IF HEIGHTMAP IS NOT LOADED PROCEED
                            HeightMap.LoadFromFile(filename, info, out heightmap);
                        }

                        float catheleyax = float.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                        float catheleyay = float.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                        float catheleyaz = float.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                        float promisex = float.Parse(fields[6], NumberFormatInfo.InvariantInfo);
                        float promisey = float.Parse(fields[7], NumberFormatInfo.InvariantInfo);
                        float promizez = float.Parse(fields[8], NumberFormatInfo.InvariantInfo);
                        byte catheleyamap = byte.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                        byte promisemap = byte.Parse(fields[9], NumberFormatInfo.InvariantInfo);
                        uint regioncode = uint.Parse(fields[19], NumberFormatInfo.InvariantInfo);
                        uint zoneid = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);
                        ZoneType zonetype = (ZoneType)Enum.Parse(typeof(ZoneType), fields[18], true);
                        Zone zone;

                        if (TryFindZoneString(fields[1], out zone))
                        {
                            SetMembers(zone, (byte)zoneid, heightmap, zonetype,
                                catheleyamap, new Point(catheleyax, catheleyay, catheleyaz),
                                promisemap, new Point(promisex, promisey, promizez),
                                regioncode);

                            maps.Add(zoneid, zone);
                        }
                    }
                    catch (Exception e)
                    {
                        HostContext.AddUnhandeldException(e);
                    }
                }
            }
        }
 public Foo(FactoryBase factory)
     : base(factory)
 {
     this.Bars = new List <Bar>();
 }
        /// <summary>
        /// Default included event that invokes a csv based stream.
        /// </summary>
        /// <param name="stream">Stream to read data from</param>
        /// <param name="ProgressReport">Class to report the state of reading</param>
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    uint weapontype = uint.Parse(fields[0], NumberFormatInfo.InvariantInfo);

                    Dictionary<uint, Info> temp;
                    bool isnew = weapons.TryGetValue(weapontype, out temp);
                    if (isnew == false) temp = new Dictionary<uint, Info>();

                    uint key = uint.Parse(fields[1], NumberFormatInfo.InvariantInfo);
                    uint maxdura = uint.Parse(fields[2], NumberFormatInfo.InvariantInfo);
                    ushort minshortatk = ushort.Parse(fields[3], NumberFormatInfo.InvariantInfo);
                    ushort maxshortatk = ushort.Parse(fields[4], NumberFormatInfo.InvariantInfo);
                    ushort minrangeatk = ushort.Parse(fields[5], NumberFormatInfo.InvariantInfo);
                    ushort maxrangeatk = ushort.Parse(fields[6], NumberFormatInfo.InvariantInfo);
                    ushort minmagicatk = ushort.Parse(fields[7], NumberFormatInfo.InvariantInfo);
                    ushort maxmagicatk = ushort.Parse(fields[8], NumberFormatInfo.InvariantInfo);
                    uint weaponskill = uint.Parse(fields[10], NumberFormatInfo.InvariantInfo);
                    uint unknown = uint.Parse(fields[9], NumberFormatInfo.InvariantInfo);

                    temp.Add(key, new Info(
                            maxdura, minshortatk, maxshortatk,
                            minrangeatk, maxrangeatk, minmagicatk,
                            maxmagicatk, weaponskill, unknown
                            ));

                    if (isnew == false)
                        weapons.Add(weapontype, temp);
                }
            }
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    Zone zone;
                    byte count = byte.Parse(fields[5], System.Globalization.NumberFormatInfo.InvariantInfo);
                    if (Singleton.Zones.TryGetZone(uint.Parse(fields[1], NumberFormatInfo.InvariantInfo), out zone))
                    {
                        for (int i = 0; i < count; i++)
                        {
                            float x = float.Parse(fields[2], System.Globalization.NumberFormatInfo.InvariantInfo);
                            float y = float.Parse(fields[3], System.Globalization.NumberFormatInfo.InvariantInfo);
                            float z = float.Parse(fields[4], System.Globalization.NumberFormatInfo.InvariantInfo);
                            int spawnrange = int.Parse(fields[6], System.Globalization.NumberFormatInfo.InvariantInfo);
                            uint modelid = uint.Parse(fields[0], System.Globalization.NumberFormatInfo.InvariantInfo);

                            MapObject regionObject;
                            Point location = GeneratePointInRange(new Point(x, y, z), spawnrange);
                            bool isspawned = Singleton.Templates.SpawnNpcInstance(modelid, location, rand.Next(0, ushort.MaxValue), zone, out regionObject);
                            if (!isspawned)
                            {
                                if (mobspawnsaswarnings.Enabled)
                                    WriteWarning("WorldObjectsFactory (multi)", "Cannot initialize {1} {0}", fields[0], "npc");
                                else
                                    WriteError("WorldObjectsFactory (multi)", "Cannot initialize {1} {0}", fields[0], "npc");
                            }
                        }
                    }
                }
            }
        }
 public Bar(FactoryBase factory) : base(factory)
 {
 }
        protected override void ParseAsXmlStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (XmlTextReader reader = new XmlTextReader(stream))
            {
                Info current = null;
                string value = null;
                while (reader.Read())
                {
                    try
                    {
                        ProgressReport.Invoke();
                        switch (reader.NodeType)
                        {
                            case XmlNodeType.Element:
                                if (reader.Name.ToUpperInvariant() == "SKILL") current = new Info();
                                value = null;
                                break;

                            case XmlNodeType.Text:
                                value = reader.Value;
                                break;

                            case XmlNodeType.EndElement:
                                string[] values;
                                switch (reader.Name.ToUpperInvariant())
                                {
                                    case "SKILL": goto Add;
                                    case "SKILLID": current.skillid = uint.Parse(value, NumberFormatInfo.InvariantInfo); current.skill = FindSkillHandler(current.skillid, methods); break;
                                    case "SKILLTYPE": current.skilltype = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "MAXSKILLEXP": current.maximumexperience = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "GROWLEVEL": current.maximumgrowlevel = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "MINRANGE": current.minimumrange = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "MAXRANGE": current.maximumrange = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "TARGET": current.target = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "CASTTIME": current.casttime = int.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "DELAY": current.delay = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "SP": current.SP = int.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "SPECIAL": current.special = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "SPECIALLVREQUIREMENT": current.specialJlvl = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "RACE": current.race = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "STANCE": current.stance = ConsoleUtils.ParseToUintArray(value); break;
                                    case "ADDITION": current.addition = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "HATEONCAST": current.requiredlp = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "HATE": current.hate = short.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "ATTACKTYPE": current.attacktype = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "ELEMENTTYPE": current.elementtype = byte.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                    case "WEAPONREQUIREMENT":
                                        values = value.Split(',');
                                        current.requiredWeapons = new byte[]
                                    {
                                        byte.Parse(values[0], NumberFormatInfo.InvariantInfo),  //HAND
                                        byte.Parse(values[1], NumberFormatInfo.InvariantInfo),  //SHORTSWORD
                                        byte.Parse(values[2], NumberFormatInfo.InvariantInfo),  //LONGSWORD
                                        byte.Parse(values[3], NumberFormatInfo.InvariantInfo),  //SWORDSTICK
                                        byte.Parse(values[4], NumberFormatInfo.InvariantInfo),  //DAMPTFLINTE
                                        byte.Parse(values[5], NumberFormatInfo.InvariantInfo),  //BOW
                                        byte.Parse(values[6], NumberFormatInfo.InvariantInfo),  //DAMPTSCHWERTZ
                                        byte.Parse(values[7], NumberFormatInfo.InvariantInfo),  //KATANA
                                        byte.Parse(values[8], NumberFormatInfo.InvariantInfo),  //SPECIALIST
                                    };
                                        break;

                                    case "JOBREQUIREMENT":
                                        values = value.Split(',');
                                        current.requiredJobs = new byte[]
                                    {
                                        byte.Parse(values[0], NumberFormatInfo.InvariantInfo),  //NOVICE
                                        byte.Parse(values[1], NumberFormatInfo.InvariantInfo),  //SWORDSMAN
                                        byte.Parse(values[3], NumberFormatInfo.InvariantInfo),  //RECRUIT
                                        byte.Parse(values[2], NumberFormatInfo.InvariantInfo),  //THIEF
                                        byte.Parse(values[4], NumberFormatInfo.InvariantInfo),  //ENCHANTER
                                        byte.Parse(values[5], NumberFormatInfo.InvariantInfo),  //CLOWN
                                        byte.Parse(values[6], NumberFormatInfo.InvariantInfo),  //KNIGHT
                                        byte.Parse(values[7], NumberFormatInfo.InvariantInfo),  //ASSASIN
                                        byte.Parse(values[8], NumberFormatInfo.InvariantInfo),  //SPECIALIST
                                        byte.Parse(values[9], NumberFormatInfo.InvariantInfo),  //SAGE
                                        byte.Parse(values[10], NumberFormatInfo.InvariantInfo), //GAMBLER
                                        byte.Parse(values[11], NumberFormatInfo.InvariantInfo), //FALCATA
                                        byte.Parse(values[12], NumberFormatInfo.InvariantInfo), //FPRSYTHIE
                                        byte.Parse(values[13], NumberFormatInfo.InvariantInfo), //NEMOPHILA
                                        byte.Parse(values[14], NumberFormatInfo.InvariantInfo)  //VEILCHENBLAU
                                    };
                                        break;
                                }
                                break;
                        }
                    }
                    catch (Exception e)
                    {
                        throw new SystemException(string.Format("File caused a error at fileline: {0}", reader.LineNumber), e);
                    }
                    continue;
                Add:
                    try
                    {
                        current.skill = FindSkillHandler(current.skillid, methods);
                        this.spells.Add(current.skillid, current);
                    }
                    catch (Exception)
                    {
                        Console.WriteLine("Duplicate Id detected {0}", current.skillid);
                    }
                }
            }
        }
Exemple #30
0
 public Client(FactoryBase factory)
 {
     _element = factory.CreateElement();
 }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    maps.Add(

                        //ASSOCIATE MAP-ID WITH ZONE INSTANCE
                        byte.Parse(fields[1], NumberFormatInfo.InvariantInfo),

                        //CREATE NEW CHARACTER INFO
                        new Info
                        (
                            ushort.Parse(fields[2], NumberFormatInfo.InvariantInfo),
                            ushort.Parse(fields[3], NumberFormatInfo.InvariantInfo),
                            ushort.Parse(fields[4], NumberFormatInfo.InvariantInfo)
                        )
                    );
                }
            }
        }
Exemple #32
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FactoryBase obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
Exemple #33
0
 private static void LoadFromAssemblies(List <TypeViewer> viewers)
 {
     FactoryBase.LoadFactoriesFromAssemblies <TypeViewer>(viewers);
 }
Exemple #34
0
        public static Field GetInstance(string labelName, string fieldName)
        {
            var type = FactoryBase.GetType(GetClassNames(labelName, fieldName).ToArray());

            return(FactoryBase.CreateInstance <Field>(type, new Field()));
        }
        protected override void ParseAsCsvStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    //REPORT PROGRESS
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    try
                    {
                        int Flags = 0;
                        byte eventid = Convert.ToByte(fields[0]);            //Unique id of the event
                        byte UseDate = Convert.ToByte(fields[6]);            //1   - Use a date to check
                        byte UseTime = Convert.ToByte(fields[7]);            //2   - Use a timespan to check
                        byte EnableMonday = Convert.ToByte(fields[8]);       //4   - Is active on monday
                        byte EnableThuesday = Convert.ToByte(fields[9]);     //8   - Is active on thuesday
                        byte EnableWednesday = Convert.ToByte(fields[10]);   //16  - Is active on wednessday
                        byte EnableThursday = Convert.ToByte(fields[11]);    //32  - Is active on thursday
                        byte EnableFriday = Convert.ToByte(fields[12]);      //64  - Is active on friday
                        byte EnableSaturday = Convert.ToByte(fields[13]);    //128 - Is active on saturday
                        byte EnableSunday = Convert.ToByte(fields[14]);      //256 - Is active on sunday
                        string EventName = fields[1];                        //Name of the event

                        if (UseDate == 1)
                            Flags |= 1;
                        if (UseTime == 1)
                            Flags |= 2;
                        if (EnableMonday == 1)
                            Flags |= 4;
                        if (EnableThuesday == 1)
                            Flags |= 8;
                        if (EnableWednesday == 1)
                            Flags |= 16;
                        if (EnableThursday == 1)
                            Flags |= 32;
                        if (EnableFriday == 1)
                            Flags |= 64;
                        if (EnableSaturday == 1)
                            Flags |= 128;
                        if (EnableSunday == 1)
                            Flags |= 256;

                        DateTime eventstart = DateTime.Parse(fields[2], CultureInfo.InvariantCulture);
                        DateTime eventend = DateTime.Parse(fields[3], CultureInfo.InvariantCulture);
                        TimeSpan timestart = TimeSpan.Parse(fields[4]);
                        TimeSpan timetend = TimeSpan.Parse(fields[5]);

                        EventDateTime date = new EventDateTime();
                        date.end = eventend.Add(timetend);
                        date.start = eventstart.Add(timestart);
                        date.eventname = EventName;
                        date.Flags = Flags;
                        if (CanCheckTimespan(date))
                            date.IsActive = IsActiveToday(date) && IsBetweenDateTime(date) && IsBetweenTimeStamp(date);
                        else
                            date.IsActive = true;

                        _eventdates.Add(eventid, date);
                    }
                    catch (Exception e)
                    {
                        HostContext.AddUnhandeldException(e);
                    }
                }
            }
        }
        protected override void ParseAsXmlStream(Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (XmlTextReader reader = new XmlTextReader(stream))
            {
                Info info = null;
                uint AdditionId = 0;
                uint Interval = 0;
                uint EffectDuration = 0;
                string value = null;
                uint[] Functions = null;
                int[] Values = null;
                String[] fields = null;
                Type additiontype = typeof(AdditionsBonus);

                while (reader.Read())
                {
                    ProgressReport.Invoke();
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            value = null;
                            if (reader.Name.ToUpperInvariant() == "ROW")
                            {
                                Functions = null;
                                Values = null;
                                fields = null;
                                AdditionId = 0;
                                Interval = 0;
                                EffectDuration = 0;
                            }
                            break;

                        case XmlNodeType.Text:
                            value = reader.Value;
                            break;

                        case XmlNodeType.EndElement:
                            switch (reader.Name.ToUpperInvariant())
                            {
                                case "ROW": goto Add;
                                case "ID":
                                    AdditionId = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                case "TYPE": break;
                                case "DISPOSITION": break;
                                case "INTERVAL":
                                    Interval = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                case "EFFECTDURATION":
                                    EffectDuration = uint.Parse(value, NumberFormatInfo.InvariantInfo); break;
                                case "FUNCTION":
                                    fields = value.Split(',');
                                    Functions = new uint[] { (uint)Enum.Parse( additiontype, fields[0] ),
                                                    (uint)Enum.Parse( additiontype, fields[1] ),
                                                    (uint)Enum.Parse( additiontype, fields[2] ),
                                                    (uint)Enum.Parse( additiontype, fields[3] ),
                                                    (uint)Enum.Parse( additiontype, fields[4] ),
                                                    (uint)Enum.Parse( additiontype, fields[5] ),
                                                    (uint)Enum.Parse( additiontype, fields[6] ),
                                                    (uint)Enum.Parse( additiontype, fields[7] ),
                                                    (uint)Enum.Parse( additiontype, fields[8] ),
                                                    (uint)Enum.Parse( additiontype, fields[9])};
                                    break;

                                case "VALUE":
                                    fields = value.Split(',');
                                    Values = new int[] {  int.Parse( fields[0],  NumberFormatInfo.InvariantInfo ),
                                                    int.Parse( fields[1], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[2], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[3], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[4], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[5], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[6], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[7], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[8], NumberFormatInfo.InvariantInfo),
                                                    int.Parse( fields[9], NumberFormatInfo.InvariantInfo)};
                                    break;
                            }
                            break;
                    }
                    continue;
                Add:
                    try
                    {
                        info = Info.From(addition_table, Functions, Values);
                        if (info != null)
                        {
                            info.Addition = AdditionId;
                            info.Interval = Interval;
                            info.EffectDuration = EffectDuration;
                            _additions.Add(AdditionId, info);
                        }
                    }
                    catch (ArgumentException)
                    {
                        WriteError("AdditionFactory", "Duplicate id detected: {0}", AdditionId);
                        return;
                    }

                    continue;
                }
            }
        }
Exemple #37
0
        private static void Main(string[] args)
        {
            //Set managers
            ManagerBase2.SetTraceLog(generaltracelog);
            CoreService.SetTraceLog(generaltracelog);

            //GET THE ASSEMBLY'S DIRECTORY
            string file  = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string fname = Path.GetFileNameWithoutExtension(file);

            //TRACELOG
            Trace.AutoFlush  = true;
            Trace.IndentSize = 4;
            if (System.Diagnostics.Trace.Listeners.Count <= 1 && (System.Diagnostics.Trace.Listeners["Default"] == null ||
                                                                  System.Diagnostics.Trace.Listeners["Default"].GetType() == typeof(System.Diagnostics.DefaultTraceListener)))
            {
                DelimitedListTraceListener del = new System.Diagnostics.DelimitedListTraceListener((fname + ".log.csv"), "text");
                del.Delimiter = ",";
                System.Diagnostics.Trace.Listeners.Add(del);
            }

            Trace.WriteLine("#############################################################################");
            Trace.WriteLine(string.Format("Saga Map Server starting on: {0}", DateTime.Now));
            Trace.WriteLine(string.Format("OS Information: {0}", Environment.OSVersion));
            Trace.WriteLine(string.Format("Number of Processors: {0}", Environment.ProcessorCount));
            Trace.WriteLine(string.Format("CLR Version: {0}", Environment.Version));
            Trace.WriteLine(string.Format("Working set: {0}", Environment.WorkingSet));
            Trace.WriteLine(string.Format("OS Bit Version: {0} Bit", IntPtr.Size * 8));
            Trace.WriteLine("#############################################################################");

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //Do initial configuration
            FirstRunConfiguration();

            _ConsoleCommands               = ManagerBase2.ProvideManager <ConsoleCommands>("Saga.Manager.ConsoleSettings");
            _NetworkService                = ManagerBase2.ProvideManager <NetworkService>("Saga.Manager.NetworkSettings");
            _WorldTasks                    = ManagerBase2.ProvideManager <WorldTasks>("Saga.Manager.WorldTasks");
            _Database                      = ManagerBase2.ProvideManager <Database>("Saga.Manager.Database");
            _Quests                        = ManagerBase2.ProvideManager <Saga.Managers.Quests>("Saga.Manager.Quest");
            _ScriptCompiler                = ManagerBase2.ProvideManager <ScriptCompiler>("Saga.Manager.Scripting");
            _EventManager                  = FactoryBase.ProvideManager <EventManager>("Saga.Factory.Events");
            _Additions                     = FactoryBase.ProvideManager <Additions>("Saga.Factory.Addition");
            _Portals                       = FactoryBase.ProvideManager <Portals>("Saga.Factory.Portals");
            _Spells                        = FactoryBase.ProvideManager <Saga.Factory.Spells>("Saga.Factory.Spells");
            _StatusByLevel                 = FactoryBase.ProvideManager <Saga.Factory.StatusByLevel>("Saga.Factory.StatusByLevel");
            _Warps                         = FactoryBase.ProvideManager <Warps>("Saga.Factory.Warps");
            _Zones                         = FactoryBase.ProvideManager <Zones>("Saga.Factory.Zones");
            _ItemFactory                   = FactoryBase.ProvideManager <ItemsFactory>("Saga.Factory.Items");
            _Weaponary                     = FactoryBase.ProvideManager <Weaponary>("Saga.Factory.Weaponary");
            _SpawnTemplates                = FactoryBase.ProvideManager <SpawnTemplate>("Saga.Factory.SpawnTemplate");
            _SpawnWorldObjects             = FactoryBase.ProvideManager <SpawnWorldObjects>("Saga.Factory.SpawnWorldObjects");
            _SpawnMultiWorldObjectSettings = FactoryBase.ProvideManager <SpawnMultiWorldObjects>("Saga.Factory.SpawnMultiWorldObjects");
            _CharacterConfiguration        = FactoryBase.ProvideManager <CharacterConfiguration>("Saga.Factory.CharacterConfiguration");
            _ItemDrops                     = FactoryBase.ProvideManager <ItemsDrops>("Saga.Factory.ItemDrops");

            try
            {
                ManagerCollection section = (ManagerCollection)ConfigurationManager.GetSection("Saga.Managers");
                if (section != null)
                {
                    foreach (SingletonManagerElement element in section)
                    {
                        ManagerBase2 managerBase = ManagerBase2.ProvideManagerFromTypeString <ManagerBase2>(element.Type);
                        _CustomManagers.Add(element.Name, managerBase);
                    }
                }
            }
            catch (Exception e)
            {
                HostContext.Current.AddUnhandeldException(e);
            }
            finally
            {
                HostContext.Current.Initialize();
                HostContext.Current.BeforeQuerySettings();
                HostContext.Current.AfterQuerySettings();
                HostContext.Current.Load();
                HostContext.Current.Loaded();
            }

            Console.ReadLine();
        }
        protected override void ParseAsCsvStream(System.IO.Stream stream, FactoryBase.ReportProgress ProgressReport)
        {
            using (StreamReader c = new StreamReader(stream))
            {
                c.ReadLine();
                while (c.Peek() > 0)
                {
                    ProgressReport.Invoke();
                    String row = c.ReadLine();
                    String[] fields = row.Split(',');

                    NumberFormatInfo global = System.Globalization.NumberFormatInfo.InvariantInfo;
                    byte toid = byte.Parse(fields[1], global);
                    byte fromid = byte.Parse(fields[0], global);
                    byte tomapid = byte.Parse(fields[5], global);
                    float x = float.Parse(fields[2], global);
                    float y = float.Parse(fields[3], global);
                    float z = float.Parse(fields[4], global);

                    Portal portal = new Portal(tomapid, x, y, z);

                    Dictionary<byte, Portal> portals_tmp;
                    if (this.portals.TryGetValue(fromid, out portals_tmp) == false)
                    {
                        portals_tmp = new Dictionary<byte, Portal>();
                    }
                    portals_tmp[toid] = portal;
                    this.portals[fromid] = portals_tmp;
                }
            }
        }