Exemplo n.º 1
0
        protected override void AwardCompletion()
        {
            base.AwardCompletion();

            Debug.Log("[LRTR] DownrangeDistance AwardCompletion");

            var cc = (ConfiguredContract)Root;

            if (cc.AutoAccept)
            {
                string contractName = ConfiguredContract.contractTypeName(cc);
                Debug.Log("[LRTR] Contract name: " + contractName);

                GameEvents.onGameSceneSwitchRequested.Add(SceneChangeInProgress);

                if (CompletedParams == null)
                {
                    CompletedParams = new Dictionary <string, DownrangeDistance>();
                }

                if (CompletedParams.ContainsKey(contractName))
                {
                    CompletedParams[contractName] = this;
                }
                else
                {
                    CompletedParams.Add(contractName, this);
                }
            }
        }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            if (contract.targetBody == null)
            {
                return(false);
            }

            switch (field)
            {
            case RadiationFieldType.INNER_BELT:
                return(KerbalismContracts.Instance.BodyData(contract.targetBody).has_inner);

            case RadiationFieldType.OUTER_BELT:
                return(KerbalismContracts.Instance.BodyData(contract.targetBody).has_outer);

            case RadiationFieldType.MAGNETOPAUSE:
                return(KerbalismContracts.Instance.BodyData(contract.targetBody).has_pause);

            case RadiationFieldType.ANY:
                return(KerbalismContracts.Instance.BodyData(contract.targetBody).has_inner ||
                       KerbalismContracts.Instance.BodyData(contract.targetBody).has_outer ||
                       KerbalismContracts.Instance.BodyData(contract.targetBody).has_pause);
            }

            return(false);
        }
Exemplo n.º 3
0
        public override bool RequirementMet(ConfiguredContract contract)
        {
            // Perform another validation of the target body to catch late validation issues due to expressions
            if (!ValidateTargetBody())
            {
                return(false);
            }

            // Validate the CelestialBodySubtree exists
            ProgressNode cbProgress = GetCelestialBodySubtree();

            if (cbProgress == null)
            {
                LoggingUtil.LogError(this, ": ProgressNode for targetBody " + targetBody.bodyName + " not found.");
                return(false);
            }

            if (checkType == CheckType.MANNED)
            {
                return(cbProgress.IsReached && cbProgress.IsCompleteManned);
            }
            else if (checkType == CheckType.UNMANNED)
            {
                return(cbProgress.IsReached && cbProgress.IsCompleteUnmanned);
            }

            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Copy constructor.
        /// </summary>
        public WaypointGenerator(WaypointGenerator orig, ConfiguredContract contract)
            : base()
        {
            foreach (WaypointData old in orig.waypoints)
            {
                // Copy waypoint data
                for (int i = 0; i < old.count; i++)
                {
                    WaypointData wpData = new WaypointData(old, contract);
                    waypoints.Add(wpData);

                    // Set the name
                    if (old.names.Any())
                    {
                        wpData.waypoint.name = (old.names.Count() == 1 ? old.names.First() : old.names.ElementAtOrDefault(i));
                    }
                    if (string.IsNullOrEmpty(wpData.waypoint.name) || wpData.waypoint.name.ToLower() == "site")
                    {
                        wpData.waypoint.name = StringUtilities.GenerateSiteName(random.Next(), wpData.waypoint.celestialBody, !wpData.waterAllowed);
                    }

                    // Handle waypoint chaining
                    if (wpData.chained && i != 0)
                    {
                        wpData.nearIndex = waypoints.Count - 2;
                    }
                }
            }
            initialized      = orig.initialized;
            orig.initialized = false;
            this.contract    = contract;

            Initialize();
        }
Exemplo n.º 5
0
 public override bool RequirementMet(ConfiguredContract contract)
 {
     foreach (CelestialBody body in Database.instance.BodyList)
     {
         if (Database.instance.CelestialBodies[body].isResearched && Database.instance.CelestialBodies[body].researchState < 100)
         {
             if (host == "Observatory")
             {
                 if (RBRange.WithinObsRange(body.transform))
                 {
                     return(true);
                 }
             }
             else
             {
                 if (FlightGlobals.fetch != null)
                 {
                     for (int i = 0; i < FlightGlobals.Vessels.Count; i++)
                     {
                         double range = 0;
                         if (RBRange.VesselHasModuleTrackBodies(FlightGlobals.Vessels[i], out range))
                         {
                             if (RBRange.WithinVslRange(FlightGlobals.Vessels[i], body.transform))
                             {
                                 return(true);
                             }
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
Exemplo n.º 6
0
        protected override void OnRegister()
        {
            base.OnRegister();
            GameEvents.onLaunch.Add(new EventData <EventReport> .OnEvent(OnLaunch));

            try
            {
                var    cc           = (ConfiguredContract)Root;
                string contractName = ConfiguredContract.contractTypeName(cc);

                if (cc.AutoAccept && CompletedParams != null && CompletedParams.ContainsKey(contractName))
                {
                    Debug.Log("[LRTR] Carrying starting point over to new contract...");
                    DownrangeDistance oldParam = CompletedParams[contractName];
                    triggered     = oldParam.triggered;
                    curDist       = oldParam.curDist;
                    markLatitude  = oldParam.markLatitude;
                    markLongitude = oldParam.markLongitude;
                }
            }
            catch (Exception ex)
            {
                Debug.LogError("[LRTR] OnRegisterError: " + ex);
            }
        }
 protected void OnContractLoaded(ConfiguredContract contract)
 {
     if (contract == Root)
     {
         CreateTimerParameter();
     }
 }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            if (pqsCity != null)
            {
                latitude  = targetBody.GetLatitude(pqsCity.transform.position);
                longitude = targetBody.GetLongitude(pqsCity.transform.position);
                pqsCity   = null;
            }

            return(SCANsatUtil.IsCovered(latitude, longitude, SCANsatUtil.GetSCANtype(scanType), targetBody));
        }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            // Perform another validation of the target body to catch late validation issues due to expressions
            if (!ValidateTargetBody())
            {
                return false;
            }

            double coverageInPercentage = SCANsatUtil.GetCoverage(SCANsatUtil.GetSCANtype(scanType), targetBody);
            return coverageInPercentage >= minCoverage && coverageInPercentage <= maxCoverage;
        }
Exemplo n.º 10
0
        public override bool RequirementMet(ConfiguredContract contract)
        {
            LoggingUtil.LogVerbose(this, "Checking requirement");

            // Perform another validation of the target body to catch late validation issues due to expressions
            if (!ValidateTargetBody())
            {
                return(false);
            }

            return(RemoteTechProgressTracker.Instance.ActiveRange(targetBody) > range);
        }
Exemplo n.º 11
0
        public override bool RequirementMet(ConfiguredContract contract)
        {
            bool bOpen = LaunchSiteManager.getIsSiteOpen(basename);

            if (bOpen)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            TieredResource resource = ColonizationResearchScenario.Instance.AllResourcesTypes.FirstOrDefault(r => r.ResearchCategory.Name == this.researchCategory);

            if (resource == null)
            {
                Debug.LogError($"Misconfigured PksTierRequirement - unknown resource '{this.researchCategory}'");
                return(false);
            }

            TechTier tier = ColonizationResearchScenario.Instance.GetMaxUnlockedTier(resource, this.targetBody.name);

            return((int)tier > this.tier);
        }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            LoggingUtil.LogVerbose(this, "Checking requirement");

            if (RemoteTechProgressTracker.Instance == null)
            {
                // Assume no coverage
                return(maxCoverage == 0.0);
            }

            double coverage = RemoteTechProgressTracker.Instance.GetCoverage(targetBody);

            return(coverage >= minCoverage && coverage <= maxCoverage);
        }
Exemplo n.º 14
0
        private bool ContractTypeMatches(Contract contract)
        {
            // Get the contract type
            Type   contractType     = contract.GetType();
            string contractTypeName = contractType.Name;

            if (contractTypeName == "ConfiguredContract")
            {
                contractTypeName = ConfiguredContract.contractGroupName(contract);
            }

            // Check if contract type matches
            return(contractTypes.Contains(contractTypeName));
        }
Exemplo n.º 15
0
        public override ContractBehaviour Generate(ConfiguredContract contract)
        {
            // Set legacy values
            if (legacy)
            {
                kerbals = passengerName.Select(name => new Kerbal(gender, name, experienceTrait)).ToList();
            }

            // Set the kerbal type
            foreach (Kerbal kerbal in kerbals)
            {
                kerbal.kerbalType = kerbalType;
            }

            return(new SpawnPassengers(kerbals, count, removePassengers));
        }
Exemplo n.º 16
0
        public override ContractBehaviour Generate(ConfiguredContract contract)
        {
            ContractBehaviour result;

            if (current != null)
            {
                result  = current;
                current = null;
            }
            else
            {
                result = new SpawnKerbal(spawnKerbalTemplate);
            }

            return(result);
        }
Exemplo n.º 17
0
        public override ContractBehaviour Generate(ConfiguredContract contract)
        {
            WaypointGenerator result;

            if (current != null)
            {
                result  = current;
                current = null;
                result.SetContract(contract);
            }
            else
            {
                result = new WaypointGenerator(waypointGeneratorTemplate, contract);
            }

            return(result);
        }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            // Perform another validation of the target body to catch late validation issues due to expressions
            if (!ValidateTargetBody())
            {
                return false;
            }

            if (pqsCity != null)
            {
                latitude = targetBody.GetLatitude(pqsCity.transform.position);
                longitude = targetBody.GetLongitude(pqsCity.transform.position);
                pqsCity = null;
            }

            return SCANsatUtil.IsCovered(latitude, longitude, SCANsatUtil.GetSCANtype(scanType), targetBody);
        }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            LoggingUtil.LogVerbose(this, "Checking requirement");

            // Perform another validation of the target body to catch late validation issues due to expressions
            if (!ValidateTargetBody())
            {
                return(false);
            }

            if (RemoteTechProgressTracker.Instance == null)
            {
                // Assume no coverage
                return(maxCoverage == 0.0);
            }

            double coverage = RemoteTechProgressTracker.GetCoverage(targetBody);

            return(coverage >= minCoverage && coverage <= maxCoverage);
        }
Exemplo n.º 20
0
 public override bool RequirementMet(ConfiguredContract contract)
 {
     if (contract == null)
     {
         return(false);
     }
     if (contract.ContractState == Contract.State.Active)
     {
         return(true);
     }
     for (int i = 0; i < PSystemSetup.Instance.SpaceCenterFacilities.Length; i++)
     {
         if (PSystemSetup.Instance.SpaceCenterFacilities[i].name == facility)
         {
             int level = Mathf.RoundToInt(ScenarioUpgradeableFacilities.GetFacilityLevel(facility) + 1);
             return(level >= minLevel);
         }
     }
     RSTLogWriter.Log("Observatory NOT found....");
     return(false);
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new CloseBase(conditions, basename));
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return new Expression(expression);
 }
Exemplo n.º 23
0
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new ExperimentalPart(parts, add, remove));
 }
Exemplo n.º 24
0
 public override bool RequirementMet(ConfiguredContract contract)
 {
     return(LaunchSiteManager.checkLaunchSiteExists(basename));
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new AwardExperience(parameter, kerbals, experience, awardImmediately));
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new ChangeVesselOwnership(onState, vessels, owned, parameter));
 }
        public override bool RequirementMet(ConfiguredContract contract)
        {
            double coverageInPercentage = SCANUtil.GetCoverage((int)scanType, targetBody);

            return(coverageInPercentage >= minCoverage && coverageInPercentage <= maxCoverage);
        }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new Expression(expression));
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return new AwardExperience(parameter, experience, awardImmediately);
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     throw new InvalidOperationException("Cannot generate invalid behaviour.");
 }
Exemplo n.º 31
0
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new UnlockPart(parts, unlockTech));
 }
Exemplo n.º 32
0
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new WaypointGenerator(waypointGenerator, contract));
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return new RunCutScene(onState, parameter, cutSceneDefinition);
 }
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return new ChangeVesselOwnership(onState, vessels, owned, parameter);
 }
 public override bool RequirementMet(ConfiguredContract contract)
 {
     return(!LaunchSiteManager.getIsSiteOpen(basename));
 }
Exemplo n.º 36
0
 public override ContractBehaviour Generate(ConfiguredContract contract)
 {
     return(new SpawnVessel(spawnVessel));
 }
 public override bool RequirementMet(ConfiguredContract contract)
 {
     return(Configuration.HideRadiationBelts);
 }
 public ContractContainer(ConfiguredContract contract)
 {
     this.contract = contract;
     contractType = contract.contractType;
 }