public override void OnStart(StartState state) { base.OnStart(state); part.force_activate(); //setup anim if (!string.IsNullOrEmpty(deployAnimationName)) { hasDeployAnimation = true; deployAnimState = Misc.Misc.SetUpSingleAnimation(deployAnimationName, part); if (state == StartState.Editor) { Events["EditorToggleAnimation"].guiActiveEditor = true; } } if (HighLogic.LoadedSceneIsFlight) { List <ModuleTurret> .Enumerator tur = part.FindModulesImplementing <ModuleTurret>().GetEnumerator(); while (tur.MoveNext()) { if (tur.Current == null) { continue; } if (tur.Current.turretID != turretID) { continue; } turret = tur.Current; break; } tur.Dispose(); attachedRadar = part.FindModuleImplementing <ModuleRadar>(); if (attachedRadar) { hasAttachedRadar = true; } finalTransform = part.FindModelTransform(finalTransformName); UpdateMissileChildren(); if (!autoReturn) { Events["ReturnTurret"].guiActive = true; } } }
public TargetSignatureData(CMFlare flare, float _signalStrength) { velocity = flare.velocity; geoPos = VectorUtils.WorldPositionToGeoCoords(flare.transform.position, FlightGlobals.currentMainBody); exists = true; acceleration = Vector3.zero; timeAcquired = Time.time; signalStrength = _signalStrength; targetInfo = null; vesselJammer = null; team = BDArmorySettings.BDATeams.None; pingPosition = Vector2.zero; orbital = false; orbit = null; lockedByRadar = null; vessel = null; }
public TargetSignatureData(Vessel v, float _signalStrength) { orbital = false; orbit = null; timeAcquired = Time.time; vessel = v; velocity = v.Velocity(); geoPos = VectorUtils.WorldPositionToGeoCoords(v.CoM, v.mainBody); acceleration = v.acceleration; exists = true; signalStrength = _signalStrength; targetInfo = v.gameObject.GetComponent <TargetInfo> (); // vessel never been picked up on radar before: create new targetinfo record if (targetInfo == null) { targetInfo = v.gameObject.AddComponent <TargetInfo>(); } team = BDArmorySettings.BDATeams.None; if (targetInfo) { team = targetInfo.team; targetInfo.detectedTime = Time.time; } else { List <MissileFire> .Enumerator mf = v.FindPartModulesImplementing <MissileFire>().GetEnumerator(); while (mf.MoveNext()) { team = BDATargetManager.BoolToTeam(mf.Current.team); break; } mf.Dispose(); } vesselJammer = v.gameObject.GetComponent <VesselECMJInfo>(); pingPosition = Vector2.zero; lockedByRadar = null; }
public TargetSignatureData(Vector3 _velocity, Vector3 _position, Vector3 _acceleration, bool _exists, float _signalStrength) { velocity = _velocity; geoPos = VectorUtils.WorldPositionToGeoCoords(_position, FlightGlobals.currentMainBody); acceleration = _acceleration; exists = _exists; timeAcquired = Time.time; signalStrength = _signalStrength; targetInfo = null; vesselJammer = null; team = BDArmorySettings.BDATeams.None; pingPosition = Vector2.zero; orbital = false; orbit = null; lockedByRadar = null; vessel = null; }
public TargetSignatureData(Vessel v, float _signalStrength) { orbital = v.InOrbit(); orbit = v.orbit; timeAcquired = Time.time; vessel = v; velocity = v.Velocity(); geoPos = VectorUtils.WorldPositionToGeoCoords(v.CoM, v.mainBody); acceleration = v.acceleration_immediate; exists = true; signalStrength = _signalStrength; targetInfo = v.gameObject.GetComponent <TargetInfo>(); // vessel never been picked up on radar before: create new targetinfo record if (targetInfo == null) { targetInfo = v.gameObject.AddComponent <TargetInfo>(); } Team = null; if (targetInfo) // Always true, as we just set it? { Team = targetInfo.Team; } else { List <MissileFire> .Enumerator mf = v.FindPartModulesImplementing <MissileFire>().GetEnumerator(); while (mf.MoveNext()) { Team = mf.Current.Team; break; } mf.Dispose(); } vesselJammer = v.gameObject.GetComponent <VesselECMJInfo>(); pingPosition = Vector2.zero; lockedByRadar = null; }
public TargetSignatureData(Vessel v, float _signalStrength) { orbital = v.InOrbit(); orbit = v.orbit; timeAcquired = Time.time; vessel = v; velocity = v.Velocity(); geoPos = VectorUtils.WorldPositionToGeoCoords(v.CoM, v.mainBody); acceleration = v.acceleration_immediate; exists = true; signalStrength = _signalStrength; targetInfo = v.gameObject.GetComponent <TargetInfo>(); // vessel never been picked up on radar before: create new targetinfo record if (targetInfo == null) { targetInfo = v.gameObject.AddComponent <TargetInfo>(); } Team = null; if (targetInfo) // Always true, as we just set it? { Team = targetInfo.Team; } else { var mf = VesselModuleRegistry.GetMissileFire(v, true); if (mf != null) { Team = mf.Team; } } vesselJammer = v.gameObject.GetComponent <VesselECMJInfo>(); pingPosition = Vector2.zero; lockedByRadar = null; }
void dumpParts() { String gunName = "bda_weapons_list.csv"; String missileName = "bda_missile_list.csv"; String radarName = "bda_radar_list.csv"; String jammerName = "bda_jammer_list.csv"; ModuleWeapon weapon = null; MissileLauncher missile = null; ModuleRadar radar = null; ModuleECMJammer jammer = null; // 1. create the file var fileguns = KSP.IO.TextWriter.CreateForType <BDAEditorCategory>(gunName); var filemissiles = KSP.IO.TextWriter.CreateForType <BDAEditorCategory>(missileName); var fileradars = KSP.IO.TextWriter.CreateForType <BDAEditorCategory>(radarName); var filejammers = KSP.IO.TextWriter.CreateForType <BDAEditorCategory>(jammerName); // 2. write header fileguns.WriteLine("NAME;TITLE;AUTHOR;MANUFACTURER;PART_MASS;PART_COST;PART_CRASHTOLERANCE;PART_MAXTEMP;WEAPON_RPM;WEAPON_DEVIATION;WEAPON_MAXEFFECTIVEDISTANCE;WEAPON_TYPE;WEAPON_BULLETTYPE;WEAPON_AMMONAME;WEAPON_BULLETMASS;WEAPON_BULLET_VELOCITY;WEAPON_MAXHEAT;WEAPON_HEATPERSHOT;WEAPON_HEATLOSS;CANNON_SHELLPOWER;CANNON_SHELLHEAT;CANNON_SHELLRADIUS;CANNON_AIRDETONATION"); filemissiles.WriteLine("NAME;TITLE;AUTHOR;MANUFACTURER;PART_MASS;PART_COST;PART_CRASHTOLERANCE;PART_MAXTEMP;" + "MISSILE_THRUST;MISSILE_BOOSTTIME;MISSILE_CRUISETHRUST;MISSILE_CRUISETIME;MISSILE_MAXTURNRATEDPS;MISSILE_BLASTPOWER;MISSILE_BLASTHEAT;MISSILE_BLASTRADIUS;MISSILE_GUIDANCEACTIVE;MISSILE_HOMINGTYPE;MISSILE_TARGETINGTYPE;MISSILE_MINLAUNCHSPEED;MISSILE_MINSTATICLAUNCHRANGE;MISSILE_MAXSTATICLAUNCHRANGE;MISSILE_OPTIMUMAIRSPEED;" + "CRUISE_TERMINALMANEUVERING; CRUISE_TERMINALGUIDANCETYPE; CRUISE_TERMINALGUIDANCEDISTANCE;" + "RADAR_ACTIVERADARRANGE;RADAR_RADARLOAL;" + "TRACK_MAXOFFBORESIGHT;TRACK_LOCKEDSENSORFOV;" + "HEAT_HEATTHRESHOLD;" + "LASER_BEAMCORRECTIONFACTOR; LASER_BEAMCORRECTIONDAMPING" ); fileradars.WriteLine("NAME;TITLE;AUTHOR;MANUFACTURER;PART_MASS;PART_COST;PART_CRASHTOLERANCE;PART_MAXTEMP;radar_name;rwrThreatType;omnidirectional;directionalFieldOfView;boresightFOV;" + "scanRotationSpeed;lockRotationSpeed;lockRotationAngle;showDirectionWhileScan;multiLockFOV;lockAttemptFOV;canScan;canLock;canTrackWhileScan;canRecieveRadarData;" + "DEPRECATED_minSignalThreshold;DEPRECATED_minLockedSignalThreshold;maxLocks;radarGroundClutterFactor;radarDetectionCurve;radarLockTrackCurve" ); filejammers.WriteLine("NAME;TITLE;AUTHOR;MANUFACTURER;PART_MASS;PART_COST;PART_CRASHTOLERANCE;PART_MAXTEMP;alwaysOn;rcsReduction;rcsReducationFactor;lockbreaker;lockbreak_strength;jammerStrength"); Debug.Log("Dumping parts..."); // 3. iterate weapons and write out fields foreach (var item in availableParts) { weapon = null; missile = null; radar = null; jammer = null; weapon = item.partPrefab.GetComponent <ModuleWeapon>(); missile = item.partPrefab.GetComponent <MissileLauncher>(); radar = item.partPrefab.GetComponent <ModuleRadar>(); jammer = item.partPrefab.GetComponent <ModuleECMJammer>(); if (weapon != null) { fileguns.WriteLine( item.name + ";" + item.title + ";" + item.author + ";" + item.manufacturer + ";" + item.partPrefab.mass + ";" + item.cost + ";" + item.partPrefab.crashTolerance + ";" + item.partPrefab.maxTemp + ";" + weapon.roundsPerMinute + ";" + weapon.maxDeviation + ";" + weapon.maxEffectiveDistance + ";" + weapon.weaponType + ";" + weapon.bulletType + ";" + weapon.ammoName + ";" + weapon.bulletMass + ";" + weapon.bulletVelocity + ";" + weapon.maxHeat + ";" + weapon.heatPerShot + ";" + weapon.heatLoss + ";" + weapon.cannonShellPower + ";" + weapon.cannonShellHeat + ";" + weapon.cannonShellRadius + ";" + weapon.airDetonation ); } if (missile != null) { filemissiles.WriteLine( item.name + ";" + item.title + ";" + item.author + ";" + item.manufacturer + ";" + item.partPrefab.mass + ";" + item.cost + ";" + item.partPrefab.crashTolerance + ";" + item.partPrefab.maxTemp + ";" + missile.thrust + ";" + missile.boostTime + ";" + missile.cruiseThrust + ";" + missile.cruiseTime + ";" + missile.maxTurnRateDPS + ";" + missile.blastPower + ";" + missile.blastHeat + ";" + missile.blastRadius + ";" + missile.guidanceActive + ";" + missile.homingType + ";" + missile.targetingType + ";" + missile.minLaunchSpeed + ";" + missile.minStaticLaunchRange + ";" + missile.maxStaticLaunchRange + ";" + missile.optimumAirspeed + ";" + missile.terminalManeuvering + ";" + missile.terminalGuidanceType + ";" + missile.terminalGuidanceDistance + ";" + missile.activeRadarRange + ";" + missile.radarLOAL + ";" + missile.maxOffBoresight + ";" + missile.lockedSensorFOV + ";" + missile.heatThreshold + ";" + missile.beamCorrectionFactor + ";" + missile.beamCorrectionDamping ); } if (radar != null) { fileradars.WriteLine( item.name + ";" + item.title + ";" + item.author + ";" + item.manufacturer + ";" + item.partPrefab.mass + ";" + item.cost + ";" + item.partPrefab.crashTolerance + ";" + item.partPrefab.maxTemp + ";" + radar.radarName + ";" + radar.getRWRType(radar.rwrThreatType) + ";" + radar.omnidirectional + ";" + radar.directionalFieldOfView + ";" + radar.boresightFOV + ";" + radar.scanRotationSpeed + ";" + radar.lockRotationSpeed + ";" + radar.lockRotationAngle + ";" + radar.showDirectionWhileScan + ";" + radar.multiLockFOV + ";" + radar.lockAttemptFOV + ";" + radar.canScan + ";" + radar.canLock + ";" + radar.canTrackWhileScan + ";" + radar.canRecieveRadarData + ";" + radar.maxLocks + ";" + radar.radarGroundClutterFactor + ";" + radar.radarDetectionCurve.Evaluate(radar.radarMaxDistanceDetect) + "@" + radar.radarMaxDistanceDetect + ";" + radar.radarLockTrackCurve.Evaluate(radar.radarMaxDistanceLockTrack) + "@" + radar.radarMaxDistanceLockTrack ); } if (jammer != null) { filejammers.WriteLine( item.name + ";" + item.title + ";" + item.author + ";" + item.manufacturer + ";" + item.partPrefab.mass + ";" + item.cost + ";" + item.partPrefab.crashTolerance + ";" + item.partPrefab.maxTemp + ";" + jammer.alwaysOn + ";" + jammer.rcsReduction + ";" + jammer.rcsReductionFactor + ";" + jammer.lockBreaker + ";" + jammer.lockBreakerStrength + ";" + jammer.jammerStrength ); } } // 4. close file fileguns.Close(); filemissiles.Close(); fileradars.Close(); filejammers.Close(); Debug.Log("...dumping parts complete."); }
public static void Postfix(ref ModuleRadar __instance) { FieldInfo m_Range = typeof(ModuleRadar).GetField("m_Range", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); m_Range.SetValue(__instance, Mathf.Max(900.0f, (float)m_Range.GetValue(__instance))); }