Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Character"/> class.
        /// </summary>
        /// <param name="in_bounds">
        /// The bounds within which the <see cref="Character"/>'s <see cref="GameObjectID"/> is defined.
        /// Must be one of <see cref="All.BeingIDs"/>.
        /// </param>
        /// <param name="in_id">Unique identifier for the <see cref="Character"/>.  Cannot be null.</param>
        /// <param name="in_description">Player-friendly description of the <see cref="Character"/>.</param>
        /// <param name="in_comment">Comment of, on, or by the <see cref="Character"/>.</param>
        /// <param name="in_personalName">Personal name of the <see cref="Character"/>.  Cannot be null or empty.</param>
        /// <param name="in_familyName">Family name of the <see cref="Character"/>.  Cannot be null or empty.</param>
        /// <param name="in_primaryBehavior">The rules that govern how this <see cref="Character"/> acts.  Cannot be null.</param>
        /// <param name="in_avoids">Any parquets this <see cref="Character"/> avoids.</param>
        /// <param name="in_seeks">Any parquets this <see cref="Character"/> seeks.</param>
        /// <param name="in_pronoun">How to refer to this <see cref="Character"/>.</param>
        /// <param name="in_storyCharacterID">A means of identifying this <see cref="Character"/> across multiple shipped game titles.</param>
        /// <param name="in_startingQuests">Any quests this <see cref="Character"/> has to offer or has undertaken.</param>
        /// <param name="in_dialogue">All dialogue this <see cref="Character"/> may say.</param>
        /// <param name="in_startingInventory">Any items this <see cref="Character"/> owns at the outset.</param>
        protected Character(Range <GameObjectID> in_bounds, GameObjectID in_id,
                            string in_personalName, string in_familyName,
                            string in_description, string in_comment, GameObjectID in_nativeBiome,
                            Behavior in_primaryBehavior, List <GameObjectID> in_avoids = null,
                            List <GameObjectID> in_seeks = null, string in_pronoun = DefaultPronoun,
                            string in_storyCharacterID   = "", List <GameObjectID> in_startingQuests      = null,
                            List <string> in_dialogue    = null, List <GameObjectID> in_startingInventory = null)
            : base(in_bounds, in_id, $"{in_personalName} {in_familyName}", in_description, in_comment,
                   in_nativeBiome, in_primaryBehavior, in_avoids, in_seeks)
        {
            var nonNullPronoun   = string.IsNullOrEmpty(in_pronoun) ? DefaultPronoun : in_pronoun;
            var nonNullQuests    = in_startingQuests ?? Enumerable.Empty <GameObjectID>();
            var nonNullInventory = in_startingInventory ?? Enumerable.Empty <GameObjectID>();

            Precondition.AreInRange(nonNullQuests, All.QuestIDs, nameof(in_startingQuests));
            Precondition.AreInRange(nonNullInventory, All.ItemIDs, nameof(in_startingInventory));
            Precondition.IsNotEmpty(in_personalName, nameof(in_personalName));
            Precondition.IsNotEmpty(in_familyName, nameof(in_familyName));

            PersonalName      = in_personalName;
            FamilyName        = in_familyName;
            Pronoun           = nonNullPronoun;
            StoryCharacterID  = in_storyCharacterID;
            StartingQuests    = nonNullQuests.ToList();
            Dialogue          = (in_dialogue ?? Enumerable.Empty <string>()).ToList();
            StartingInventory = nonNullInventory.ToList();
        }
Example #2
0
        public void AreInRangeThrowsOnSingleOutOfRangeTest()
        {
            var testIDCollection = new List <EntityID> {
                0, 1, 5, 9, 10, 20
            };
            var testRange = new Range <EntityID>(0, 10);

            Assert.Throws <ArgumentOutOfRangeException>(() => Precondition.AreInRange(testIDCollection, testRange));
        }
Example #3
0
        public void AreInRangeThrowsOnSingleOutOfRangeCollectionTest()
        {
            var testIDCollection = new List <EntityID> {
                0, 1, 3, 8, 10, 20
            };
            var testCollection = new List <Range <EntityID> > {
                new Range <EntityID>(0, 5), new Range <EntityID>(6, 10)
            };

            Assert.Throws <ArgumentOutOfRangeException>(() => Precondition.AreInRange(testIDCollection, testCollection));
        }
Example #4
0
        public void AreInRangeTest()
        {
            var testIDCollection = new List <EntityID> {
                0, 1, 5, 6, 9, 10
            };
            var testRange = new Range <EntityID>(0, 10);

            var exception = Record.Exception(() => Precondition.AreInRange(testIDCollection, testRange));

            Assert.Null(exception);
        }
Example #5
0
        public void AreInRangeCollectionTest()
        {
            var testIDCollection = new List <EntityID> {
                0, 1, 2, 7, 8, 10
            };
            var testCollection = new List <Range <EntityID> > {
                new Range <EntityID>(0, 5), new Range <EntityID>(6, 10)
            };

            var exception = Record.Exception(() => Precondition.AreInRange(testIDCollection, testCollection));

            Assert.Null(exception);
        }
Example #6
0
        /// <summary>
        /// Used by <see cref="Being"/> subtypes.
        /// </summary>
        /// <param name="in_bounds">
        /// The bounds within which the <see cref="Being"/>'s <see cref="GameObjectID"/> is defined.
        /// Must be one of <see cref="All.BeingIDs"/>.
        /// </param>
        /// <param name="in_id">Unique identifier for the <see cref="Being"/>.  Cannot be null.</param>
        /// <param name="in_name">Player-friendly name of the <see cref="Being"/>.  Cannot be null or empty.</param>
        /// <param name="in_description">Player-friendly description of the <see cref="Being"/>.</param>
        /// <param name="in_comment">Comment of, on, or by the <see cref="Being"/>.</param>
        /// <param name="in_nativeBiome">The <see cref="GameObjectID"/> for the <see cref="Biome"/> in which this <see cref="Being"/> is most comfortable.</param>
        /// <param name="in_primaryBehavior">The rules that govern how this <see cref="Being"/> acts.  Cannot be null.</param>
        /// <param name="in_avoids">Any parquets this <see cref="Being"/> avoids.</param>
        /// <param name="in_seeks">Any parquets this <see cref="Being"/> seeks.</param>
        protected Being(Range <GameObjectID> in_bounds, GameObjectID in_id, string in_name, string in_description,
                        string in_comment, GameObjectID in_nativeBiome, Behavior in_primaryBehavior,
                        List <GameObjectID> in_avoids = null, List <GameObjectID> in_seeks = null)
            : base(in_bounds, in_id, in_name, in_description, in_comment)
        {
            Precondition.IsInRange(in_bounds, All.BeingIDs, nameof(in_bounds));
            Precondition.IsInRange(in_nativeBiome, All.BiomeIDs, nameof(in_nativeBiome));
            Precondition.AreInRange(in_avoids, All.ParquetIDs, nameof(in_avoids));
            Precondition.AreInRange(in_seeks, All.ParquetIDs, nameof(in_seeks));

            NativeBiome     = in_nativeBiome;
            PrimaryBehavior = in_primaryBehavior;
            Avoids          = (in_avoids ?? Enumerable.Empty <GameObjectID>()).ToList();
            Seeks           = (in_seeks ?? Enumerable.Empty <GameObjectID>()).ToList();
        }
Example #7
0
        public BeingStatus(Being in_beingDefinition, Behavior in_currentBehavior,
                           Location in_position, Location in_spawnAt,
                           int in_biomeTimeRemaining,
                           float in_buildingSpeed, float in_modificationSpeed,
                           float in_gatheringSpeed, float in_movementSpeed,
                           List <GameObjectID> in_knownCritters        = null, List <GameObjectID> in_knownNPCs        = null,
                           List <GameObjectID> in_knownParquets        = null, List <GameObjectID> in_knownRoomRecipes = null,
                           List <GameObjectID> in_knownCraftingRecipes = null, List <GameObjectID> in_quests           = null,
                           List <GameObjectID> in_inventory            = null)
        {
            Precondition.IsNotNull(in_beingDefinition, nameof(in_beingDefinition));
            var nonNullCritters        = in_knownCritters ?? Enumerable.Empty <GameObjectID>().ToList();
            var nonNullNPCs            = in_knownNPCs ?? Enumerable.Empty <GameObjectID>().ToList();
            var nonNullParquets        = in_knownParquets ?? Enumerable.Empty <GameObjectID>().ToList();
            var nonNullRoomRecipes     = in_knownRoomRecipes ?? Enumerable.Empty <GameObjectID>().ToList();
            var nonNullCraftingRecipes = in_knownCraftingRecipes ?? Enumerable.Empty <GameObjectID>().ToList();
            var nonNullQuests          = in_quests ?? Enumerable.Empty <GameObjectID>().ToList();
            var nonNullInventory       = in_inventory ?? Enumerable.Empty <GameObjectID>().ToList();

            Precondition.AreInRange(nonNullCritters, All.CritterIDs, nameof(in_knownCritters));
            Precondition.AreInRange(nonNullNPCs, All.NpcIDs, nameof(in_knownNPCs));
            Precondition.AreInRange(nonNullParquets, All.ParquetIDs, nameof(in_knownParquets));
            Precondition.AreInRange(nonNullRoomRecipes, All.RoomRecipeIDs, nameof(in_knownRoomRecipes));
            Precondition.AreInRange(nonNullCraftingRecipes, All.CraftingRecipeIDs, nameof(in_knownCraftingRecipes));
            Precondition.AreInRange(nonNullQuests, All.QuestIDs, nameof(in_quests));
            Precondition.AreInRange(nonNullInventory, All.ItemIDs, nameof(in_inventory));

            BeingDefinition      = in_beingDefinition;
            CurrentBehavior      = in_currentBehavior;
            Position             = in_position;
            SpawnAt              = in_spawnAt;
            BiomeTimeRemaining   = in_biomeTimeRemaining;
            BuildingSpeed        = in_buildingSpeed;
            ModificationSpeed    = in_modificationSpeed;
            GatheringSpeed       = in_gatheringSpeed;
            MovementSpeed        = in_movementSpeed;
            KnownCritters        = nonNullCritters;
            KnownNPCs            = nonNullNPCs;
            KnownParquets        = nonNullParquets;
            KnownRoomRecipes     = nonNullRoomRecipes;
            KnownCraftingRecipes = nonNullCraftingRecipes;
            Quests    = nonNullQuests;
            Inventory = nonNullInventory;
        }