Esempio n. 1
0
 public void AddGlobalNPC(string name, GlobalNPC globalNPC)
 {
     globalNPC.mod         = this;
     globalNPC.Name        = name;
     this.globalNPCs[name] = globalNPC;
     NPCLoader.globalNPCs.Add(globalNPC);
 }
Esempio n. 2
0
        private void AutoloadGlobalNPC(Type type)
        {
            GlobalNPC globalNPC = (GlobalNPC)Activator.CreateInstance(type);

            globalNPC.mod = this;
            string name = type.Name;

            if (globalNPC.Autoload(ref name))
            {
                AddGlobalNPC(name, globalNPC);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new instance of this GlobalNPC for an NPC instance.
        /// Called at the end of NPC.SetDefaults.
        /// If CloneNewInstances is true, just calls Clone()
        /// Otherwise calls the default constructor and copies fields
        /// </summary>
        public virtual GlobalNPC NewInstance(NPC npc)
        {
            if (CloneNewInstances)
            {
                return(Clone());
            }
            GlobalNPC copy = (GlobalNPC)Activator.CreateInstance(GetType());

            copy.Mod   = Mod;
            copy.index = index;
            return(copy);
        }
Esempio n. 4
0
        internal static void VerifyGlobalNPC(GlobalNPC npc)
        {
            var type = npc.GetType();

            bool hasInstanceFields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                     .Any(f => f.DeclaringType != typeof(GlobalNPC));

            if (hasInstanceFields)
            {
                if (!npc.InstancePerEntity)
                {
                    throw new Exception(type + " has instance fields but does not set InstancePerEntity to true. Either use static fields, or per instance globals");
                }
            }
        }
Esempio n. 5
0
 public void AddGlobalNPC(string name, GlobalNPC globalNPC)
 {
     globalNPC.mod = this;
     globalNPC.Name = name;
     this.globalNPCs[name] = globalNPC;
     NPCLoader.globalNPCs.Add(globalNPC);
 }
Esempio n. 6
0
 public void SetGlobalNPC(GlobalNPC globalNPC)
 {
     globalNPC.mod = this;
     this.globalNPC = globalNPC;
 }
Esempio n. 7
-1
 //I'm not sure why I have this
 internal void Unload()
 {
     recipes.Clear();
     items.Clear();
     globalItem = null;
     dusts.Clear();
     tiles.Clear();
     globalNPC = null;
 }