Пример #1
0
        /// <summary>
        /// Defines all the components within the given assembly and stores them for use within a session.
        /// Should be called once within game instance before a session is loaded, e.g. within IPlugin.Init().
        /// Assembly should be determined with Assembly.GetExecutingAssembly().
        /// </summary>
        /// <remarks>
        /// Assembly could default to CallingAssembly, but inlining and tail-recursion make it difficult to ensure that's coming from the right place.
        /// </remarks>
        public static void AddComponents(Assembly assembly)
        {
            Log.Debug($"AddComponents assembly: {assembly.GetName().FullName}");
            var collection = ComponentDescriptionCollection.FromAssembly(assembly);

            ComponentsByAssembly.Add(assembly, collection);
        }
Пример #2
0
 /// <summary>
 /// We don't want one crappy mod to ruin everyone else's day!
 /// </summary>
 public void TryAddCollection(ComponentDescriptionCollection collection)
 {
     try
     {
         AddCollection(collection);
     }
     catch (Exception error)
     {
         Log.Error($"Failed to add collection: {collection}" + error);
     }
 }
Пример #3
0
        public void AddCollection(ComponentDescriptionCollection collection)
        {
            Log.Debug($"Adding components from {collection}");

            // Session components first
            foreach (var component in collection.SessionComponents)
            {
                SessionStore.AddComponent(component);
            }

            foreach (var component in collection.BlockComponents)
            {
                BlockStore.AddComponent(component);
            }
            foreach (var component in collection.CharacterComponents)
            {
                CharacterStore.AddComponent(component);
            }
            foreach (var component in collection.GridComponents)
            {
                GridStore.AddComponent(component);
            }
        }