コード例 #1
0
        static bool Prefix(EntityAlive __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            // Check if there's a door in our way, then open it.
            if (__instance.GetAttackTarget() == null)
            {
                // If it's an animal, don't let them attack blocks
                EntityAliveFarmingAnimalSDX animal = __instance as EntityAliveFarmingAnimalSDX;
                if (animal)
                {
                    if (__instance.GetAttackTarget() == null)
                    {
                        return(false);
                    }
                }
                // If a door is found, try to open it. If it returns false, start attacking it.
                EntityAliveSDX myEntity = __instance as EntityAliveSDX;
                if (myEntity)
                {
                    if (myEntity.OpenDoor())
                    {
                        return(true);
                    }
                }
            }

            if (__instance.GetAttackTarget() != null)
            {
                __instance.RotateTo(__instance.GetAttackTarget(), 30f, 30f);
            }

            return(true);
        }