Example #1
0
        public void ReleaseCommand()
        {
            Debug.Log(vessel.vesselName + " was released from command.");
            command = PilotCommands.Free;

            defaultOrbitCoords = VectorUtils.WorldPositionToGeoCoords(vesselTransform.position, vessel.mainBody);
        }
Example #2
0
 public void CommandFollow(ModuleWingCommander leader, int followerIndex)
 {
     Debug.Log(vessel.vesselName + " was commanded to follow.");
     command            = PilotCommands.Follow;
     commandLeader      = leader;
     commandFollowIndex = followerIndex;
 }
        public virtual void CommandFlyTo(Vector3 gpsCoords)
        {
            if (!pilotEnabled)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to go to.");
            assignedPositionGeo = gpsCoords;
            command             = PilotCommands.FlyTo;
        }
        public virtual void CommandAttack(Vector3 gpsCoords)
        {
            if (!pilotEnabled)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to attack.");
            assignedPositionGeo = gpsCoords;
            command             = PilotCommands.Attack;
        }
Example #5
0
        public virtual void CommandAttack(Vector3 gpsCoords)
        {
            if (!pilotEnabled)
            {
                return;
            }

            if (BDArmorySettings.DRAW_DEBUG_LABELS)
            {
                Debug.Log("[BDGenericAIBase]:" + vessel.vesselName + " was commanded to attack.");
            }
            assignedPositionGeo = gpsCoords;
            command             = PilotCommands.Attack;
        }
        public virtual void ReleaseCommand()
        {
            if (!vessel || command == PilotCommands.Free)
            {
                return;
            }
            if (command == PilotCommands.Follow && commandLeader)
            {
                commandLeader = null;
            }
            Debug.Log(vessel.vesselName + " was released from command.");
            command = PilotCommands.Free;

            assignedPositionWorld = vesselTransform.position;
        }
        public virtual void CommandFollow(ModuleWingCommander leader, int followerIndex)
        {
            if (!pilotEnabled)
            {
                return;
            }
            if (leader == vessel || followerIndex < 0)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to follow.");
            command            = PilotCommands.Follow;
            commandLeader      = leader;
            commandFollowIndex = followerIndex;
        }
Example #8
0
        public virtual void ReleaseCommand()
        {
            if (!vessel || command == PilotCommands.Free)
            {
                return;
            }
            if (command == PilotCommands.Follow && commandLeader)
            {
                commandLeader = null;
            }
            if (BDArmorySettings.DRAW_DEBUG_LABELS)
            {
                Debug.Log("[BDGenericAIBase]:" + vessel.vesselName + " was released from command.");
            }
            command = PilotCommands.Free;

            assignedPositionWorld = vesselTransform.position;
        }
Example #9
0
        public virtual void CommandFollow(ModuleWingCommander leader, int followerIndex)
        {
            if (!pilotEnabled)
            {
                return;
            }
            if (leader == vessel || followerIndex < 0)
            {
                return;
            }

            if (BDArmorySettings.DRAW_DEBUG_LABELS)
            {
                Debug.Log("[BDGenericAIBase]:" + vessel.vesselName + " was commanded to follow.");
            }
            command            = PilotCommands.Follow;
            commandLeader      = leader;
            commandFollowIndex = followerIndex;
        }
Example #10
0
        public void CommandFollow(ModuleWingCommander leader, int followerIndex)
        {
            if(!pilotEnabled)
            {
                return;
            }

            if(leader == vessel || followerIndex < 0)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to follow.");
            command = PilotCommands.Follow;
            commandLeader = leader;
            commandFollowIndex = followerIndex;
        }
Example #11
0
        public void CommandFlyTo(Vector3 gpsCoords)
        {
            if(!pilotEnabled)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to fly to.");
            defaultOrbitCoords = gpsCoords;
            commandGeoPos = gpsCoords;
            command = PilotCommands.FlyTo;
        }
Example #12
0
        public void CommandAttack(Vector3 gpsCoords)
        {
            if(!pilotEnabled)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to attack.");
            defaultOrbitCoords = gpsCoords;
            commandGeoPos = gpsCoords;
            command = PilotCommands.Attack;
        }
        IEnumerator CommandPosition(IBDAIControl wingman, PilotCommands command)
        {
            if (focusIndexes.Count == 0 && !commandSelf)
            {
                yield break;
            }

            DisplayScreenMessage(Localizer.Format("#LOC_BDArmory_WingCommander_ScreenMessage"));//"Select target coordinates.\nRight-click to cancel."

            if (command == PilotCommands.FlyTo)
            {
                waitingForFlytoPos = true;
            }
            else if (command == PilotCommands.Attack)
            {
                waitingForAttackPos = true;
            }

            yield return(null);

            bool waitingForPos = true;

            drawMouseDiamond = true;
            while (waitingForPos)
            {
                if (Input.GetMouseButtonDown(1))
                {
                    break;
                }
                if (Input.GetMouseButtonDown(0))
                {
                    Vector3 mousePos = new Vector3(Input.mousePosition.x / Screen.width,
                                                   Input.mousePosition.y / Screen.height, 0);
                    Plane surfPlane = new Plane(vessel.upAxis,
                                                vessel.transform.position - (vessel.altitude * vessel.upAxis));
                    Ray   ray = FlightCamera.fetch.mainCamera.ViewportPointToRay(mousePos);
                    float dist;
                    if (surfPlane.Raycast(ray, out dist))
                    {
                        Vector3  worldPoint = ray.GetPoint(dist);
                        Vector3d gps        = VectorUtils.WorldPositionToGeoCoords(worldPoint, vessel.mainBody);

                        if (command == PilotCommands.FlyTo)
                        {
                            wingman.CommandFlyTo(gps);
                        }
                        else if (command == PilotCommands.Attack)
                        {
                            wingman.CommandAttack(gps);
                        }

                        StartCoroutine(CommandPositionGUIRoutine(wingman, new GPSTargetInfo(gps, command.ToString())));
                    }

                    break;
                }
                yield return(null);
            }

            waitingForAttackPos = false;
            waitingForFlytoPos  = false;
            drawMouseDiamond    = false;
            ScreenMessages.RemoveMessage(screenMessage);
        }
        public void CommandFollow(ModuleWingCommander leader, int followerIndex)
        {
            if(!pilotEnabled)
            {
                return;
            }

            if(leader == vessel || followerIndex < 0)
            {
                return;
            }

            Debug.Log(vessel.vesselName + " was commanded to follow.");
            command = PilotCommands.Follow;
            commandLeader = leader;
            commandFollowIndex = followerIndex;

            foreach(var pilot in commandLeader.vessel.FindPartModulesImplementing<BDModulePilotAI>())
            {
                pilot.isLeadingFormation = true;
            }
        }
        public void ReleaseCommand()
        {
            if(vessel && command != PilotCommands.Free)
            {
                if(command == PilotCommands.Follow)
                {
                    if(commandLeader)
                    {
                        foreach(var pilot in commandLeader.vessel.FindPartModulesImplementing<BDModulePilotAI>())
                        {
                            pilot.isLeadingFormation = false;
                        }
                    }
                }

                Debug.Log(vessel.vesselName + " was released from command.");
                command = PilotCommands.Free;

                defaultOrbitCoords = VectorUtils.WorldPositionToGeoCoords(vesselTransform.position, vessel.mainBody);
            }
        }
Example #16
0
        public void ReleaseCommand()
        {
            if(vessel && command != PilotCommands.Free)
            {
                Debug.Log(vessel.vesselName + " was released from command.");
                command = PilotCommands.Free;

                defaultOrbitCoords = VectorUtils.WorldPositionToGeoCoords(vesselTransform.position, vessel.mainBody);
            }
        }
Example #17
0
        void FlyOrbit(FlightCtrlState s, Vector3d centerGPS, float radius, float speed, bool clockwise)
        {
            if(vessel.srfSpeed < minSpeed)
            {
                RegainEnergy(s);
                return;
            }

            debugString += "\nFlying orbit";
            Vector3 flightCenter = GetTerrainSurfacePosition(VectorUtils.GetWorldSurfacePostion(centerGPS, vessel.mainBody)) + (defaultAltitude*upDirection);

            Vector3 myVectorFromCenter = Vector3.ProjectOnPlane(vessel.transform.position - flightCenter, upDirection);
            Vector3 myVectorOnOrbit = myVectorFromCenter.normalized * radius;

            Vector3 targetVectorFromCenter = Quaternion.AngleAxis(clockwise ? 15 : -15, upDirection) * myVectorOnOrbit;

            Vector3 verticalVelVector = Vector3.Project(vessel.srf_velocity, upDirection); //for vv damping

            Vector3 targetPosition = flightCenter + targetVectorFromCenter - (verticalVelVector * 0.25f);

            Vector3 vectorToTarget = targetPosition - vesselTransform.position;
            Vector3 planarVel = Vector3.ProjectOnPlane(vessel.srf_velocity, upDirection);
            vectorToTarget = Vector3.RotateTowards(planarVel, vectorToTarget, 25 * Mathf.Deg2Rad, 0);

            if(command != PilotCommands.Free && Vector3.Distance(vessel.transform.position, flightCenter) < radius*1.5f)
            {
                Debug.Log("AI Pilot reached command destination.");
                command = PilotCommands.Free;
            }

            AdjustThrottle(speed, false);
            FlyToPosition(s, targetPosition);
        }
Example #18
0
 public void ReleaseCommand()
 {
     Debug.Log(vessel.vesselName + " was released from command.");
     command = PilotCommands.Free;
 }