Ejemplo n.º 1
0
        // input TransformInfo[], FlightControls[]
        // output => updated transform
        // assumes index of flight controller == index of transform info
        // assumes no nulls
        // todo better data orient this

        private void TickActives()
        {
            float deltaTime = GameTimer.Instance.deltaTime;

            ListX <TransformInfo>    transformInfos    = GameData.Instance.transformInfoMap;
            ListX <FlightController> flightControllers = GameData.Instance.flightControllers;

            int count = transformInfos.Count;

            TransformInfo[]    rawTransformInfos    = transformInfos.RawArray;
            FlightController[] rawFlightControllers = flightControllers.RawArray;

            for (int i = 0; i < count; i++)
            {
                TransformInfo    entityTransform  = rawTransformInfos[i];
                FlightController flightController = rawFlightControllers[i];

                //debug assert transformInfo.entityId == flightController.entityId

                Quaternion rotation = PropulsionUtil.RotateTowardsDirection(
                    entityTransform.rotation,
                    entityTransform.DirectionTo(flightController.targetPosition),
                    flightController.turnRate,
                    deltaTime
                    );

                float   speed    = flightController.currentSpeed * deltaTime;
                Vector3 position = entityTransform.position + (rotation.GetForward() * speed);

                transformInfos[i] = new TransformInfo(entityTransform.entityId, position, rotation);
            }
        }
        protected override float Score(EntityContext context)
        {
            TransformInfo info      = context.agent.transformInfo;
            TransformInfo otherInfo = context.other.transformInfo;

            Vector3 toMe = otherInfo.DirectionTo(info);

            return(Vector3.Dot(otherInfo.forward, toMe));
        }
Ejemplo n.º 3
0
        public override bool Tick()
        {
            TransformInfo trasformInfo        = context.agent.transformInfo;
            TransformInfo targetTransformInfo = context.other.transformInfo;

            Vector3 toTarget = trasformInfo.DirectionTo(targetTransformInfo);

            context.agent.FlightSystem.SetTargetDirection(toTarget, ApproachType.Attack);
            context.agent.WeaponSystem.Fire();

            return(false);
        }