示例#1
0
    private void AttemptBreeding(object[] args)
    {
        KinematicBody otherBody = (KinematicBody)args[0];

        if (otherBody.GetName() == targetName)
        {
            ((Entity)otherBody.GetNode("Entity")).SendMessage("acceptBreed");
            SetState(BreedState.GoingForBreed);
        }
        else
        {
            if (!active || state == BreedState.ApproachingTarget)
            {
                if (component.Satiated < satiatedThreshold)
                {
                    return;
                }
                int n = BaseComponent.random.Next(0, 100);
                if (n < component.Breedability)
                {
                    ((Entity)otherBody.GetNode("Entity")).SendMessage("acceptBreed");
                    target     = otherBody;
                    targetName = otherBody.GetName();
                    active     = true;

                    SetState(BreedState.GoingForBreed);
                }
            }
        }
    }