Example #1
0
        public SocialDef GetSocial(IBiota biote, string verb)
        {
            var socials = _staticDataManager.GetStaticData(Globals.SystemTypes.Social);

            return(socials.Select(def => def.CastAs <SocialDef>())
                   .FirstOrDefault(socialDef => socialDef.DisplayName.Equals(verb, StringComparison.OrdinalIgnoreCase)));
        }
Example #2
0
        public void Load(IStaticDataManager staticDataManager, IHelpRepository helpRepository)
        {
            Dictionary <string, Definition> helps =
                staticDataManager.GetStaticData(Globals.SystemTypes.HelpLookup);

            // TODO Do something here
        }
        private void OnLoadChannelsComplete(RealmEventArgs args)
        {
            Validation.IsNotNull(args, "args");
            Validation.IsNotNull(args.Data, "args.Data");

            var data = args.Data.ToDictionaryAtom();

            if (!data.GetBool("success"))
            {
                throw new ProcedureFailureException("Load Failure", GetType());
            }

            var commandResults = data.GetAtom <ListAtom>("commandResult");
            var results        = commandResults.GetEnumerator().Current.CastAs <DictionaryAtom>().GetAtom <ListAtom>("Results");

            using (var it = results.GetEnumerator())
            {
                while (it.MoveNext())
                {
                    var result     = it.Current.CastAs <DictionaryAtom>();
                    var channelDef = (ChannelDef)_staticDataManager.GetStaticData(Globals.SystemTypes.Channel, result.GetInt("ChannelPrimitiveID").ToString());
                    var obj        = _entityManager.Create <Channel>(result.GetInt("ChannelID"), result.GetString("Name"), result, channelDef);
                    if (obj == null)
                    {
                        throw new InstantiationException("Failed to instantiate Channel {0}", result.GetInt("ChannelID"));
                    }

                    obj.OnInit(_entityManager.InitializationAtom);
                    _repository.Add(obj.ID, obj);
                }
            }

            _log.DebugFormat("Loaded {0} channels.", _repository.Count);
            _callback?.Invoke(new RealmEventArgs());
        }
Example #4
0
        public void OnInit(DictionaryAtom initAtom)
        {
            var commands = _staticDataManager.GetStaticData(Globals.SystemTypes.GameCommand);

            commands.Keys.ToList().ForEach(command => Repository.Add(command,
                                                                     new Tuple <Action, Definition>(Helper.Get(command), commands[command])));
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="startupSet"></param>
        /// <param name="zoneList"></param>
        public void LoadStartupEntities(BooleanSet startupSet, IEnumerable <int> zoneList)
        {
            Log.DebugFormat("Beginning to load {0} startup entities.", zoneList.Count());

            Validation.IsNotNull(zoneList, "zoneList");

            var count = 0;

            zoneList.ToList().ForEach(id =>
            {
                var def = _staticDataManager.GetStaticData(Globals.SystemTypes.Zone.GetValue(),
                                                           id.ToString(CultureInfo.InvariantCulture));
                if (def == null)
                {
                    throw new InvalidDataException(string.Format(Resources.ERR_ZONE_DEF_NOT_FOUND, id));
                }

                var zoneDef = def.CastAs <ZoneDef>();
                if (zoneDef == null)
                {
                    throw new InvalidDataException(string.Format(Resources.ERR_DEF_WAS_NOT_ZONE_DEF, id));
                }
                Log.DebugFormat("Zone Definition {0} loaded.", zoneDef.ID);

                var obj = _entityManager.Create <Zone>(id, zoneDef.Name, zoneDef);
                if (obj == null)
                {
                    throw new InstantiationException(Resources.ERR_FAILURE_INSTANTIATE, typeof(Zone), id,
                                                     zoneDef.ID);
                }

                Log.DebugFormat("Zone {0} loaded.", id);
                startupSet.AddItem($"Zone{id}");
                obj.OnInit(_initAtom);
                count++;
            });

            Log.InfoFormat(Resources.MSG_ZONE_STARTUP, count);
            EventManager.ThrowEvent <OnStartupEntitiesLoaded>(this, new EventTable {
                { "BooleanSet", startupSet }
            });
        }