コード例 #1
0
        private bool FindDivingGear(float deltaTime)
        {
            if (divingGearObjective == null)
            {
                divingGearObjective = new AIObjectiveFindDivingGear(character, false);
            }

            if (divingGearObjective.IsCompleted())
            {
                return(true);
            }

            divingGearObjective.TryComplete(deltaTime);
            return(divingGearObjective.IsCompleted());
        }
コード例 #2
0
        protected override void Act(float deltaTime)
        {
            var item = character.Inventory.FindItem(gearName);

            if (item == null)
            {
                //get a diving mask/suit first
                if (!(subObjective is AIObjectiveGetItem))
                {
                    subObjective = new AIObjectiveGetItem(character, gearName, true);
                }
            }
            else
            {
                var containedItems = item.ContainedItems;
                if (containedItems == null)
                {
                    return;
                }

                //check if there's an oxygen tank in the mask
                var oxygenTank = Array.Find(containedItems, i => i.Name == "Oxygen Tank");

                if (oxygenTank != null)
                {
                    if (oxygenTank.Condition > 0.0f)
                    {
                        return;
                    }
                    else
                    {
                        oxygenTank.Drop();
                    }
                }


                if (!(subObjective is AIObjectiveContainItem) || subObjective.IsCompleted())
                {
                    subObjective = new AIObjectiveContainItem(character, "Oxygen Tank", item.GetComponent <ItemContainer>());
                }
            }

            if (subObjective != null)
            {
                subObjective.TryComplete(deltaTime);

                //isCompleted = subObjective.IsCompleted();
            }
        }
コード例 #3
0
        protected override void Act(float deltaTime)
        {
            var item = character.Inventory.FindItem(gearName);

            if (item == null)
            {
                //get a diving mask/suit first
                if (!(subObjective is AIObjectiveGetItem))
                {
                    subObjective = new AIObjectiveGetItem(character, gearName, true);
                }
            }
            else
            {
                var containedItems = item.ContainedItems;
                if (containedItems == null)
                {
                    return;
                }

                //check if there's an oxygen tank in the mask/suit
                foreach (Item containedItem in containedItems)
                {
                    if (containedItem == null)
                    {
                        continue;
                    }
                    if (containedItem.Condition <= 0.0f)
                    {
                        containedItem.Drop();
                    }
                    else if (containedItem.Prefab.NameMatches("Oxygen Tank") || containedItem.HasTag("oxygensource"))
                    {
                        //we've got an oxygen source inside the mask/suit, all good
                        return;
                    }
                }

                if (!(subObjective is AIObjectiveContainItem) || subObjective.IsCompleted())
                {
                    subObjective = new AIObjectiveContainItem(character, new string[] { "Oxygen Tank", "oxygensource" }, item.GetComponent <ItemContainer>());
                }
            }

            if (subObjective != null)
            {
                subObjective.TryComplete(deltaTime);
            }
        }
コード例 #4
0
        protected override void Act(float deltaTime)
        {
            var item = character.Inventory.FindItemByTag(gearTag);

            if (item == null || !character.HasEquippedItem(item))
            {
                //get a diving mask/suit first
                if (!(subObjective is AIObjectiveGetItem))
                {
                    character.Speak(TextManager.Get("DialogGetDivingGear"), null, 0.0f, "getdivinggear", 30.0f);
                    subObjective = new AIObjectiveGetItem(character, gearTag, true);
                }
            }
            else
            {
                var containedItems = item.ContainedItems;
                if (containedItems == null)
                {
                    return;
                }
                //check if there's an oxygen tank in the mask/suit
                foreach (Item containedItem in containedItems)
                {
                    if (containedItem == null)
                    {
                        continue;
                    }
                    if (containedItem.Condition <= 0.0f)
                    {
                        containedItem.Drop(character);
                    }
                    else if (containedItem.Prefab.Identifier == "oxygentank" || containedItem.HasTag("oxygensource"))
                    {
                        //we've got an oxygen source inside the mask/suit, all good
                        return;
                    }
                }
                if (!(subObjective is AIObjectiveContainItem) || subObjective.IsCompleted())
                {
                    character.Speak(TextManager.Get("DialogGetOxygenTank"), null, 0, "getoxygentank", 30.0f);
                    subObjective = new AIObjectiveContainItem(character, new string[] { "oxygentank", "oxygensource" }, item.GetComponent <ItemContainer>());
                }
            }
            if (subObjective != null)
            {
                subObjective.TryComplete(deltaTime);
            }
        }