Esempio n. 1
0
        public void Execute()
        {
            timeSinceLastFrame += Time.deltaTime;
            if (timeSinceLastFrame < pathfindInterval)
            {
                return;
            }
            timeSinceLastFrame = 0f;

            Vector3 currentPos = owner.GetMovement().GetPosition();

            nextTarget = owner.GetSensors().GetFoundMateInfo().Position;
            Vector3 diff       = nextTarget - currentPos;
            float   diffLength = Mathf.Sqrt(Mathf.Pow(diff.x, 2) + Mathf.Pow(diff.z, 2));

            if (diffLength <= 2.5f)
            {
                // Reproduction event
                Entity partner = owner.GetSensors().GetFoundMateInfo().Entity;
                owner.GetInteraction().Reproduce(partner);
                ParticleMono.InstantiateParticles(ParticleMono.breed, currentPos, 2f);
                owner.GetNeedsStatus().SateSexualUrge(2f);
                owner.GetNeedsStatus().SateSexualUrge(2f, partner);
            }

            // Move owner
            owner.Move(nextTarget, 1f, 200);
        }
Esempio n. 2
0
        public void Execute()
        {
            timeSinceLastFrame += Time.deltaTime;
            if (timeSinceLastFrame < pathfindInterval)
            {
                return;
            }
            timeSinceLastFrame = 0f;

            Vector3 currentPos = owner.GetMovement().GetPosition();

            nextTarget = owner.GetSensors().GetFoundFoodInfo().Position;
            float diffLength = Vector3.Distance(nextTarget, currentPos);

            if (diffLength <= 2.5f)
            {
                Entity food = owner.GetSensors().GetFoundFoodInfo().Entity;
                ParticleMono.InstantiateParticles(ParticleMono.eatplant, currentPos, 2f);
                ParticleMono.InstantiateParticles(ParticleMono.eatmeat, currentPos, 2f);
                owner.GetNeedsStatus().SateHunger(owner.GetInteraction().Eat(food));
            }

            // Move owner
            owner.Move(nextTarget, 1f, 200);
        }
Esempio n. 3
0
 protected override void OnUpdate()
 {
     Entities
     .WithStructuralChanges()
     .WithoutBurst()
     .WithAll <BirthEvent>()
     .ForEach((Entity entity,
               PregnancyData pregnancyData,
               DNA dna,
               AnimalPrefab prefab,
               in Translation position,
               in Rotation rotation) =>
     {
         ParticleMono.InstantiateParticles(ParticleMono.birth, position.Value, 2f);
         Attributes.Animal baby = Object.Instantiate(prefab.Prefab, position.Value, rotation.Value).GetComponent <Attributes.Animal>(); // Spawns child
         baby.InitDNA(pregnancyData.DNAforBaby);                                                                                        // Initialize the baby's DNA
         EntityManager.RemoveComponent <BirthEvent>(entity);
         EntityManager.RemoveComponent <PregnancyData>(entity);
     }).Run();
Esempio n. 4
0
        public void Execute()
        {
            timeSinceLastFrame += Time.deltaTime;
            if (timeSinceLastFrame < pathfindInterval)
            {
                return;
            }
            timeSinceLastFrame = 0f;
            var     preyInfo   = owner.GetSensors().GetFoundPreyInfo();
            Vector3 preyPos    = preyInfo.Position;
            Vector3 currentPos = owner.GetMovement().GetPosition();
            float   diffLength = Vector3.Distance(preyPos, currentPos);

            if (diffLength <= 1f)
            {
                Entity prey = owner.GetSensors().GetFoundPreyInfo().Entity;
                ParticleMono.InstantiateParticles(ParticleMono.kill, currentPos, 2f);
                owner.GetInteraction().Kill(prey);
            }
            Vector3 predictedPosition = preyInfo.PredictedPosition;

            owner.Move(predictedPosition, 0f, 200);
        }
Esempio n. 5
0
        public void Execute()
        {
            timeSinceLastFrame += Time.deltaTime;
            if (timeSinceLastFrame < pathfindInterval)
            {
                return;
            }
            timeSinceLastFrame = 0f;

            Vector3 currentPos = owner.GetMovement().GetPosition();

            nextTarget = owner.GetSensors().GetFoundWaterInfo();
            float diffLength = Vector3.Distance(nextTarget, currentPos);

            if (diffLength <= 3f)
            {
                ParticleMono.InstantiateParticles(ParticleMono.drink, currentPos, 2f);
                owner.GetNeedsStatus().SateThirst(3f);
            }

            // Move owner
            owner.Move(nextTarget, 1f, 200);
        }