Exemplo n.º 1
0
        /// <summary>
        /// Loads the spaces for this zone
        /// </summary>
        /// <param name="zoneDef"></param>
        /// <returns></returns>
        private int LoadSpaces(ZoneDef zoneDef)
        {
            var count = 0;

            zoneDef.Spaces.OfType <DictionaryAtom>().ToList().ForEach(space =>
            {
                var id  = space.GetInt("ID");
                var def = StaticDataManager.GetStaticData(Globals.SystemTypes.Space.GetValue(),
                                                          id.ToString(CultureInfo.InvariantCulture));
                if (def.IsNull())
                {
                    throw new InvalidDataException($"Definition for Space {id} not found.");
                }

                var spaceDef = def.CastAs <SpaceDef>();
                if (spaceDef.IsNull())
                {
                    throw new InvalidDataException($"Definition file {id} was not a SpaceDef file.");
                }

                var obj = EntityManager.Create <Space>(id, spaceDef.Name, spaceDef);
                if (obj.IsNull())
                {
                    throw new InstantiationException("Space {0} could not be instantiated.", id);
                }

                _loadingSet.AddItem($"Space{obj.ID}");
                obj.OnInit(InitializationAtom);
                count++;
            });

            return(count);
        }
Exemplo n.º 2
0
        private void OnCharacterAbilitiesLoaded(RealmEventArgs args)
        {
            var success = args.Data["success"].CastAs <bool>();

            if (!success)
            {
                Logger.InfoFormat("game_GetCharacterAbilities failed");
                return;
            }

            Abilities = new List <Ability>();

            var results = args.Data["commandResult"].CastAs <ListAtom>();

            foreach (var result in results.Select(atom => atom.CastAs <DictionaryAtom>()))
            {
                var abilityId  = result.GetInt("AbilityID");
                var abilityDef = StaticDataManager.GetStaticData(Globals.SystemTypes.Ability,
                                                                 abilityId.ToString());

                Abilities.Add(EntityManager.Create <Ability>(abilityId, abilityDef.Name, abilityDef));
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Loads the resets for this zone
        /// </summary>
        /// <param name="zoneDef"></param>
        /// <returns></returns>
        private int LoadResets(ZoneDef zoneDef)
        {
            _repository = new ResetRepository();

            var count = 0;

            zoneDef.Resets.OfType <DictionaryAtom>().ToList().ForEach(reset =>
            {
                var id = reset.GetInt("ID");

                var def = StaticDataManager.GetStaticData(Globals.SystemTypes.Reset.GetValue(),
                                                          id.ToString(CultureInfo.InvariantCulture));
                if (def.IsNull())
                {
                    throw new InvalidDataException($"Definition for Reset {id} not found.");
                }

                var resetDef = def.CastAs <ResetDef>();
                if (resetDef.IsNull())
                {
                    throw new InvalidDataException($"Definition file {id} was not a ResetDef file.");
                }
                var obj = EntityManager.Create(new ResetFactoryHelper(), resetDef.ResetType.ToString(), id, resetDef.Name, resetDef);
                if (obj.IsNull())
                {
                    throw new InstantiationException("Reset {0} {1} could not be instantiated.", resetDef.ResetType,
                                                     id);
                }

                var newReset = obj.CastAs <Reset>();
                newReset.OnInit(this, InitializationAtom);
                _repository.Add(newReset.ID, newReset);
                count++;
            });

            return(count);
        }