示例#1
0
        private IEnumerator EquipWeapon(HTNPlayer target)
        {
            yield return(CoroutineEx.waitForSeconds(0.25f));

            if (target == null || target.IsDestroyed || target.IsDead() || target.IsWounded() || target.inventory == null || target.inventory.containerBelt == null)
            {
                yield break;
            }
            Item item = target.inventory.containerBelt.GetSlot(0);

            if (item == null)
            {
                yield break;
            }
            target.UpdateActiveItem(item.uid);
            yield return(CoroutineEx.waitForSeconds(0.25f));

            ScientistAStarDomain aiDomain = target.AiDomain as ScientistAStarDomain;

            if (aiDomain)
            {
                if (item.info.category == ItemCategory.Weapon)
                {
                    BaseEntity heldEntity = item.GetHeldEntity();
                    if (heldEntity is BaseProjectile)
                    {
                        aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ProjectileWeapon, true, true, true);
                        aiDomain.ReloadFirearm();
                    }
                    else if (heldEntity is BaseMelee)
                    {
                        aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true);
                    }
                    else if (heldEntity is ThrownWeapon)
                    {
                        aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ThrowableWeapon, true, true, true);
                    }
                }
                else if (item.info.category == ItemCategory.Medical)
                {
                    aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.HealingItem, true, true, true);
                }
                else if (item.info.category == ItemCategory.Tool)
                {
                    aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.LightSourceItem, true, true, true);
                }
            }
        }
        private static void GiveKitScarecrow(HTNPlayer npc, string kit)
        {
            if (kit == null)
            {
                return;
            }

            Interface.Oxide.CallHook("GiveKit", npc, kit);

            Item item = npc.inventory.containerBelt.GetSlot(0);

            if (item == null)
            {
                return;
            }

            npc.UpdateActiveItem(item.uid);
        }
        private IEnumerator EquipWeapon(HTNPlayer target)
        {
            yield return((object)CoroutineEx.waitForSeconds(0.25f));

            if (!Object.op_Equality((Object)target, (Object)null) && !target.IsDestroyed && (!target.IsDead() && !target.IsWounded()) && (!Object.op_Equality((Object)target.inventory, (Object)null) && target.inventory.containerBelt != null))
            {
                Item slot = target.inventory.containerBelt.GetSlot(0);
                if (slot != null)
                {
                    target.UpdateActiveItem(slot.uid);
                    yield return((object)CoroutineEx.waitForSeconds(0.25f));

                    ScientistAStarDomain aiDomain = target.AiDomain as ScientistAStarDomain;
                    if (Object.op_Implicit((Object)aiDomain))
                    {
                        if (slot.info.category == ItemCategory.Weapon)
                        {
                            BaseEntity heldEntity = slot.GetHeldEntity();
                            if (heldEntity is BaseProjectile)
                            {
                                aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ProjectileWeapon, true, true, true);
                                aiDomain.ReloadFirearm();
                            }
                            else if (heldEntity is BaseMelee)
                            {
                                aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true);
                            }
                            else if (heldEntity is ThrownWeapon)
                            {
                                aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ThrowableWeapon, true, true, true);
                            }
                        }
                        else if (slot.info.category == ItemCategory.Medical)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.HealingItem, true, true, true);
                        }
                        else if (slot.info.category == ItemCategory.Tool)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.LightSourceItem, true, true, true);
                        }
                    }
                }
            }
        }
示例#4
0
        private IEnumerator EquipTool(HTNPlayer target)
        {
            yield return((object)CoroutineEx.waitForSeconds(0.25f));

            if (!Object.op_Equality((Object)target, (Object)null) && !target.IsDestroyed && (!target.IsDead() && !target.IsWounded()) && (!Object.op_Equality((Object)target.inventory, (Object)null) && target.inventory.containerBelt != null))
            {
                int slot1 = 1;
                if (Object.op_Inequality((Object)TOD_Sky.get_Instance(), (Object)null) && TOD_Sky.get_Instance().get_IsNight())
                {
                    slot1 = 2;
                }
                Item slot = target.inventory.containerBelt.GetSlot(slot1);
                if (slot == null)
                {
                    slot = target.inventory.containerBelt.GetSlot(0);
                    if (slot == null)
                    {
                        yield break;
                    }
                }
                target.UpdateActiveItem(slot.uid);
                yield return((object)CoroutineEx.waitForSeconds(0.25f));

                ScientistJunkpileDomain aiDomain = target.AiDomain as ScientistJunkpileDomain;
                if (Object.op_Implicit((Object)aiDomain))
                {
                    if (slot.info.category == ItemCategory.Weapon)
                    {
                        BaseEntity heldEntity = slot.GetHeldEntity();
                        if (heldEntity is BaseProjectile)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ProjectileWeapon, true, true, true);
                            aiDomain.ReloadFirearm();
                        }
                        else if (heldEntity is BaseMelee)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.MeleeWeapon, true, true, true);
                        }
                        else if (heldEntity is ThrownWeapon)
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ThrowableWeapon, true, true, true);
                        }
                    }
                    else if (slot.info.category == ItemCategory.Medical)
                    {
                        aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.HealingItem, true, true, true);
                    }
                    else if (slot.info.category == ItemCategory.Tool)
                    {
                        HeldEntity heldEntity = target.GetHeldEntity();
                        if (Object.op_Inequality((Object)heldEntity, (Object)null) && heldEntity.LightsOn())
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.LightSourceItem, true, true, true);
                        }
                        else
                        {
                            aiDomain.ScientistContext.SetFact(Facts.HeldItemType, ItemType.ResearchItem, true, true, true);
                        }
                    }
                }
            }
        }