bool has_creature(IDataObject data)
        {
            Creature c = data.GetData(typeof(Creature)) as Creature;

            if (c != null)
            {
                return(true);
            }

            CustomCreature cc = data.GetData(typeof(CustomCreature)) as CustomCreature;

            if (cc != null)
            {
                return(true);
            }

            NPC npc = data.GetData(typeof(NPC)) as NPC;

            if (npc != null)
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        ///     Remove a custom creature by its ref. Removes the custom recipe, too.
        /// </summary>
        /// <param name="creature"><see cref="CustomCreature"/> to remove.</param>
        public void RemoveCreature(CustomCreature creature)
        {
            Creatures.Remove(creature);

            if (creature.Prefab)
            {
                PrefabManager.Instance.RemovePrefab(creature.Prefab.name);
            }
        }
        private void AddCreature_Click(object sender, EventArgs e)
        {
            CustomCreature cc = new CustomCreature();

            cc.Name = "New Creature";

            CreatureBuilderForm dlg = new CreatureBuilderForm(cc);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                Session.Project.CustomCreatures.Add(dlg.Creature as CustomCreature);
                Session.Modified = true;

                update_creatures();
            }
        }
Example #4
0
        private void DeckView_DragDrop(object sender, DragEventArgs e)
        {
            e.Effect = DragDropEffects.None;

            Creature c = e.Data.GetData(typeof(Creature)) as Creature;

            if (c != null)
            {
                e.Effect = DragDropEffects.Copy;
            }

            CustomCreature cc = e.Data.GetData(typeof(CustomCreature)) as CustomCreature;

            if (cc != null)
            {
                e.Effect = DragDropEffects.Copy;
            }
        }
        /// <summary>
        ///     Add a <see cref="CustomCreature"/> to the game.<br />
        ///     Checks if the custom creature is valid and unique and adds it to the list of custom creatures.
        /// </summary>
        /// <param name="customCreature">The custom Creature to add.</param>
        /// <returns>true if the custom Creature was added to the manager.</returns>
        public bool AddCreature(CustomCreature customCreature)
        {
            if (!customCreature.IsValid())
            {
                Logger.LogWarning($"Custom creature {customCreature} is not valid");
                return(false);
            }
            if (Creatures.Contains(customCreature))
            {
                Logger.LogWarning($"Custom creature {customCreature} already added");
                return(false);
            }

            // Add prefab to the PrefabManager
            if (!PrefabManager.Instance.AddPrefab(customCreature.Prefab, customCreature.SourceMod))
            {
                return(false);
            }

            // Set the correct Layer if not set
            if (customCreature.Prefab.layer != CharacterLayer)
            {
                customCreature.Prefab.layer = CharacterLayer;

                // Also set the first level of child GOs
                foreach (Transform child in customCreature.Prefab.transform)
                {
                    child.gameObject.layer = CharacterLayer;
                }
            }

            // Move prefab to our own container
            customCreature.Prefab.transform.SetParent(SpawnListContainer.transform, false);

            // Add custom creature to CreatureManager
            Creatures.Add(customCreature);

            // Add spawners to Jötunn's own spawner list
            SpawnList.m_spawners.AddRange(customCreature.Spawns);

            return(true);
        }
Example #6
0
        public CustomCreatureForm(CustomCreature cc, bool unused)
        {
            InitializeComponent();

            Application.Idle += new EventHandler(Application_Idle);

            fCreature = cc.Copy();

            fUpdating = true;

            NameBox.Text   = fCreature.Name;
            LevelBox.Value = fCreature.Level;
            RoleBtn.Text   = fCreature.Role.ToString();
            InfoBtn.Text   = fCreature.Phenotype;

            StrBox.Value = fCreature.Strength.Score;
            ConBox.Value = fCreature.Constitution.Score;
            DexBox.Value = fCreature.Dexterity.Score;
            IntBox.Value = fCreature.Intelligence.Score;
            WisBox.Value = fCreature.Wisdom.Score;
            ChaBox.Value = fCreature.Charisma.Score;

            InitModBox.Value = fCreature.InitiativeModifier;
            HPModBox.Value   = fCreature.HPModifier;
            ACModBox.Value   = fCreature.ACModifier;
            FortModBox.Value = fCreature.FortitudeModifier;
            RefModBox.Value  = fCreature.ReflexModifier;
            WillModBox.Value = fCreature.WillModifier;

            fUpdating = false;

            update_fields();
            update_powers_list();
            update_aura_list();
            update_damage_list();
            update_details();

            if (fCreature.Image != null)
            {
                PortraitBox.Image = fCreature.Image;
            }
        }
Example #7
0
        public static ICreature FindCreature(Guid creature_id, SearchType search_type)
        {
            if ((search_type == SearchType.External) || (search_type == SearchType.Global))
            {
                foreach (Library lib in Libraries)
                {
                    Creature creature = lib.FindCreature(creature_id);
                    if (creature != null)
                    {
                        return(creature);
                    }
                }
            }

            if ((search_type == SearchType.Project) || (search_type == SearchType.Global))
            {
                if (Project != null)
                {
                    Creature creature = Project.Library.FindCreature(creature_id);
                    if (creature != null)
                    {
                        return(creature);
                    }

                    CustomCreature cc = Project.FindCustomCreature(creature_id);
                    if (cc != null)
                    {
                        return(cc);
                    }

                    NPC npc = Project.FindNPC(creature_id);
                    if (npc != null)
                    {
                        return(npc);
                    }
                }
            }

            return(null);
        }