本文整理汇总了C#中Vessel.Die方法的典型用法代码示例。如果您正苦于以下问题:C# Vessel.Die方法的具体用法?C# Vessel.Die怎么用?C# Vessel.Die使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vessel
的用法示例。
在下文中一共展示了Vessel.Die方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnVesselCreate
private void OnVesselCreate(Vessel vessel)
{
ProtoVessel pv = vessel.BackupVessel();
List<uint> vesselParts = new List<uint>();
bool killShip = false;
bool vesselOk = false;
foreach (ProtoPartSnapshot pps in pv.protoPartSnapshots)
{
if (pps.flightID == 0)
{
loadGuid = vessel.id;
//When you spawn a new vessel in all the part ID's are 0 until OnFlightReady.
return;
}
vesselParts.Add(pps.flightID);
if (partToVessel.ContainsKey(pps.flightID))
{
killShip = true;
foreach (Vessel otherVessel in partToVessel[pps.flightID])
{
if (otherVessel.id == vessel.id)
{
vesselOk = true;
}
//Either of the locks are ours or neither of the locks exist
if (LockSystem.fetch.LockIsOurs("control-" + otherVessel.id) || LockSystem.fetch.LockIsOurs("update-" + otherVessel.id) || (!LockSystem.fetch.LockExists("control-" + otherVessel.id) && !LockSystem.fetch.LockExists("update-" + otherVessel.id)))
{
vesselOk = true;
}
}
}
}
if (killShip && !vesselOk)
{
DarkLog.Debug("PartKiller: Destroying vessel fragment");
vessel.Die();
}
else
{
vesselToPart.Add(vessel, vesselParts);
foreach (uint partID in vesselParts)
{
if (!partToVessel.ContainsKey(partID))
{
partToVessel.Add(partID, new List<Vessel>());
}
partToVessel[partID].Add(vessel);
}
}
}
示例2: AsteriodModifier
public void AsteriodModifier( Vessel asteriod )
{
if( asteriod.vesselType == VesselType.SpaceObject && asteriod.loaded == false )
{
try
{
TerraformingAsteriodImpactor impactor = asteriod.gameObject.AddComponent<TerraformingAsteriodImpactor>();
//Comets are rarer than asteriods:
if( UnityEngine.Random.Range( 1, 2 ) == 1 ) //1 in 40 asteriods
{
impactor.Init( asteriod, 1 );
asteriod.vesselName = asteriod.vesselName.Replace( "Ast." , "Comet" );
}
else
{
impactor.Init( asteriod, 0 );
}
}
catch
{
asteriod.Die();
}
}
}
示例3: killVesselOnNextUpdate
private IEnumerator<WaitForFixedUpdate> killVesselOnNextUpdate(Vessel vessel)
{
yield return new WaitForFixedUpdate();
if (vessel != null)
{
KMPClientMain.DebugLog("Killing vessel");
vessel.Die();
}
}
示例4: killVessel
private void killVessel(Vessel vessel)
{
if (vessel !=null && !killedThisUpdate.Contains(vessel.id))
{
killedThisUpdate.Add(vessel.id);
if (!isInFlight)
{
KMPClientMain.DebugLog("Killing vessel immediately: " + vessel.id);
FlightGlobals.Vessels.Remove(vessel);
vessel.Die();
} else StartCoroutine(killVesselOnNextUpdate(vessel));
}
}
示例5: KillVessel
private void KillVessel(Vessel killVessel)
{
if (killVessel != null)
{
DarkLog.Debug("Killing vessel: " + killVessel.id.ToString());
if (!killVessels.Contains(killVessel))
{
killVessels.Add(killVessel);
}
lastKillVesselDestroy[killVessel.id.ToString()] = UnityEngine.Time.realtimeSinceStartup;
try
{
/*
if (!killVessel.packed)
{
try
{
OrbitPhysicsManager.HoldVesselUnpack(2);
}
catch
{
//Don't care
}
killVessel.GoOnRails();
}
if (killVessel.loaded)
{
killVessel.Unload();
}
*/
killVessel.Die();
}
catch (Exception e)
{
DarkLog.Debug("Error destroying vessel: " + e);
}
}
}
示例6: killVesselOnNextUpdate
private IEnumerator<WaitForFixedUpdate> killVesselOnNextUpdate(Vessel vessel)
{
yield return new WaitForFixedUpdate();
if (vessel != null)
{
Log.Debug("Killing vessel" + vessel.id);
try
{
vessel.Die();
}
catch
{
Log.Debug("Failed to kill vessel");
}
//try { FlightGlobals.Vessels.Remove(vessel); } catch {}
//StartCoroutine(destroyVesselOnNextUpdate(vessel));
}
}
示例7: loadProtovessel
private IEnumerator<WaitForFixedUpdate> loadProtovessel(Vessel oldVessel, Vector3 newWorldPos, Vector3 newOrbitVel, bool wasLoaded, bool wasActive, bool setTarget, ProtoVessel protovessel, Guid vessel_id, KMPVessel kvessel = null, KMPVesselUpdate update = null, double distance = 501d)
{
yield return new WaitForFixedUpdate();
if (oldVessel != null && !wasActive)
{
Log.Debug("Killing vessel");
try { oldVessel.Die(); } catch {}
try { FlightGlobals.Vessels.Remove(oldVessel); } catch {}
StartCoroutine(destroyVesselOnNextUpdate(oldVessel));
}
serverVessels_LoadDelay[vessel_id] = UnityEngine.Time.realtimeSinceStartup + 5f;
serverVessels_PartCounts[vessel_id] = protovessel.protoPartSnapshots.Count;
protovessel.Load(HighLogic.CurrentGame.flightState);
Vessel created_vessel = protovessel.vesselRef;
if (created_vessel != null)
{
try
{
OrbitPhysicsManager.HoldVesselUnpack(1);
}
catch (NullReferenceException e)
{
Log.Debug("Exception thrown in loadProtovessel(), catch 1, Exception: {0}", e.ToString());
}
if (!created_vessel.loaded) created_vessel.Load();
Log.Debug(created_vessel.id.ToString() + " initializing: ProtoParts=" + protovessel.protoPartSnapshots.Count + ",Parts=" + created_vessel.Parts.Count + ",Sit=" + created_vessel.situation.ToString() + ",type=" + created_vessel.vesselType + ",alt=" + protovessel.altitude);
vessels[vessel_id.ToString()].vessel.vesselRef = created_vessel;
serverVessels_PartCounts[vessel_id] = created_vessel.Parts.Count;
serverVessels_Parts[vessel_id] = new List<Part>();
serverVessels_Parts[vessel_id].AddRange(created_vessel.Parts);
if (created_vessel.vesselType != VesselType.Flag && created_vessel.vesselType != VesselType.EVA)
{
foreach (Part part in created_vessel.Parts)
{
part.OnLoad();
part.OnJustAboutToBeDestroyed += checkRemoteVesselIntegrity;
part.explosionPotential = 0;
part.terrainCollider = new PQS_PartCollider();
part.terrainCollider.part = part;
part.terrainCollider.useVelocityCollider = false;
part.terrainCollider.useGravityCollider = false;
part.breakingForce = float.MaxValue;
part.breakingTorque = float.MaxValue;
}
if (update == null || (update != null && update.bodyName == FlightGlobals.ActiveVessel.mainBody.name))
{
Log.Debug("update included");
if (update == null || (update.relTime == RelativeTime.PRESENT))
{
if (newWorldPos != Vector3.zero)
{
Log.Debug("repositioning");
created_vessel.transform.position = newWorldPos;
}
if (newOrbitVel != Vector3.zero)
{
Log.Debug("updating velocity");
created_vessel.ChangeWorldVelocity((-1 * created_vessel.GetObtVelocity()) + (new Vector3(newOrbitVel.x,newOrbitVel.z,newOrbitVel.y))); //xzy?
}
StartCoroutine(restoreVesselState(created_vessel,newWorldPos,newOrbitVel));
//Update FlightCtrlState
if (update != null)
{
if (created_vessel.ctrlState == null) created_vessel.ctrlState = new FlightCtrlState();
created_vessel.ctrlState.CopyFrom(update.flightCtrlState.getAsFlightCtrlState(0.75f));
}
}
else
{
StartCoroutine(setNewVesselNotInPresent(created_vessel));
}
}
}
if (setTarget) StartCoroutine(setDockingTarget(created_vessel));
if (wasActive) StartCoroutine(setActiveVessel(created_vessel, oldVessel));
Log.Debug(created_vessel.id.ToString() + " initialized");
}
}
示例8: OnVesselCreate
public void OnVesselCreate(Vessel createdVessel)
{
try
{
//DarkLog.Debug("Vessel creation detected: " + createdVessel.id + ", name: " + createdVessel.vesselName);
ProtoVessel pv = createdVessel.BackupVessel();
bool killShip = false;
bool spawnDebris = false;
string partOwner = null;
string createdVesselID = pv.vesselID.ToString();
foreach (ProtoPartSnapshot vesselPart in pv.protoPartSnapshots)
{
if (vesselPart != null)
{
if (vesselParts.ContainsKey(vesselPart.flightID.ToString()))
{
partOwner = vesselParts[vesselPart.flightID.ToString()];
if (!killShip && (createdVesselID != partOwner))
{
if (LockSystem.fetch.LockIsOurs("control-" + partOwner) || LockSystem.fetch.LockIsOurs("update-" + partOwner) || !LockSystem.fetch.LockExists("update-" + partOwner))
{
//Vessel is ours, update the part owner.
spawnDebris = true;
vesselParts[vesselPart.flightID.ToString()] = createdVesselID;
}
else
{
DarkLog.Debug("Detected debris for a vessel we do not control, removing " + createdVesselID);
killShip = true;
break;
}
}
}
}
}
if (killShip)
{
createdVessel.Die();
}
if (spawnDebris)
{
//DarkLog.Debug("Spawned debris " + createdVesselID + " from " + partOwner);
}
}
catch (Exception e)
{
DarkLog.Debug("Threw in OnVesselCreate: " + e);
}
}
示例9: RecycleVessel
public float RecycleVessel(Vessel v)
{
float ConversionEfficiency = 0.8f;
double amount;
VesselResources scrap = new VesselResources (v);
string target_resource;
PartResourceDefinition rp_def;
if (ExLaunchPad.kethane_present) {
target_resource = "Metal";
} else {
target_resource = "RocketParts";
}
rp_def = PartResourceLibrary.Instance.GetDefinition (target_resource);
if (FlightGlobals.ActiveVessel == v)
FlightGlobals.ForceSetActiveVessel (this.vessel);
float mass = 0;
foreach (var crew in v.GetVesselCrew ()) {
mass += RecycleKerbal (crew, null);
}
foreach (string resource in scrap.resources.Keys) {
amount = scrap.ResourceAmount (resource);
mass += ReclaimResource (resource, amount, v.name);
scrap.TransferResource (resource, -amount);
}
float hull_mass = v.GetTotalMass ();
amount = hull_mass * ConversionEfficiency / rp_def.density;
mass += ReclaimResource (target_resource, amount, v.name, "hull");
v.Die ();
return mass;
}
示例10: KillVessel
private void KillVessel(Vessel killVessel)
{
if (killVessel != null)
{
//TODO: Deselect the vessel in the tracking station if we are about to kill it.
DarkLog.Debug("Killing vessel: " + killVessel.id.ToString());
killVessel.DespawnCrew();
//Add it to the delay kill list to make sure it dies.
//With KSP, If it doesn't work first time, keeping doing it until it does.
if (!delayKillVessels.Contains(killVessel))
{
delayKillVessels.Add(killVessel);
}
lastKillVesselDestroy[killVessel.id.ToString()] = UnityEngine.Time.realtimeSinceStartup;
if (killVessel.loaded)
{
try
{
killVessel.Unload();
}
catch (Exception unloadException)
{
DarkLog.Debug("Error unloading vessel: " + unloadException);
}
}
foreach (ProtoPartSnapshot pps in killVessel.protoVessel.protoPartSnapshots)
{
foreach (ProtoCrewMember pcm in pps.protoModuleCrew)
{
DarkLog.Debug("Unassigning " + pcm.name + " from " + killVessel.id.ToString());
pcm.rosterStatus = ProtoCrewMember.RosterStatus.Available;
pcm.seatIdx = -1;
}
pps.protoModuleCrew.Clear();
}
try
{
killVessel.Die();
}
catch (Exception killException)
{
DarkLog.Debug("Error destroying vessel: " + killException);
}
}
}
示例11: RecycleVessel
public float RecycleVessel(Vessel v)
{
float ConversionEfficiency = 0.8f;
double amount;
VesselResources scrap = new VesselResources (v);
PartResourceDefinition rp_def;
string target_resource = ExSettings.HullRecycleTarget;
rp_def = PartResourceLibrary.Instance.GetDefinition (target_resource);
if (FlightGlobals.ActiveVessel == v)
FlightGlobals.ForceSetActiveVessel (this.vessel);
float mass = 0;
foreach (var crew in v.GetVesselCrew ()) {
mass += RecycleKerbal (crew, null);
}
foreach (string resource in scrap.resources.Keys) {
amount = scrap.ResourceAmount (resource);
mass += ReclaimResource (resource, amount, v.name);
scrap.TransferResource (resource, -amount);
}
float hull_mass = v.GetTotalMass ();
amount = hull_mass * ConversionEfficiency / rp_def.density;
mass += ReclaimResource (target_resource, amount, v.name, String.Format ("hull({0})", target_resource));
v.Die ();
return mass;
}
示例12: killVesselOnNextUpdate
private IEnumerator<WaitForFixedUpdate> killVesselOnNextUpdate(Vessel vessel)
{
yield return new WaitForFixedUpdate();
if (vessel != null)
{
KMPClientMain.DebugLog("Killing vessel");
try { vessel.Die(); } catch {}
try { FlightGlobals.Vessels.Remove(vessel); } catch {}
StartCoroutine(destroyVesselOnNextUpdate(vessel));
}
}
示例13: killVessel
private void killVessel(Vessel vessel)
{
if (vessel !=null)
{
if (!isInFlightOrTracking && !syncing)
{
KMPClientMain.DebugLog("Killing vessel immediately: " + vessel.id);
try { vessel.Die(); } catch {}
try { FlightGlobals.Vessels.Remove(vessel); } catch {}
StartCoroutine(destroyVesselOnNextUpdate(vessel));
} else StartCoroutine(killVesselOnNextUpdate(vessel));
}
}
示例14: KillVessel
private void KillVessel(Vessel killVessel)
{
if (killVessel != null)
{
bool oldDestroyIsValid = destroyIsValid;
destroyIsValid = false;
if (oldDestroyIsValid)
{
DarkLog.Debug("Disabling vessel destroy for vessel killing");
}
DarkLog.Debug("Killing vessel: " + killVessel.id.ToString());
try
{
if (!killVessel.packed)
{
killVessel.GoOnRails();
}
if (killVessel.loaded)
{
killVessel.Unload();
}
killVessel.Die();
}
catch (Exception e)
{
DarkLog.Debug("Error destroying vessel: " + e);
}
if (oldDestroyIsValid)
{
reenableDestroyInFixedUpdates = 5;
}
}
}
示例15: OnVesselCreate
private void OnVesselCreate(Vessel checkVessel)
{
if (VesselIsAsteroid(checkVessel))
{
lock (serverAsteroidListLock)
{
if (LockSystem.fetch.LockIsOurs("asteroid-spawning"))
{
if (!serverAsteroids.Contains(checkVessel.id.ToString()))
{
if (GetAsteroidCount() <= maxNumberOfUntrackedAsteroids)
{
DarkLog.Debug("Spawned in new server asteroid!");
serverAsteroids.Add(checkVessel.id.ToString());
VesselWorker.fetch.RegisterServerVessel(checkVessel.id.ToString());
NetworkWorker.fetch.SendVesselProtoMessage(checkVessel.protoVessel, false, false);
}
else
{
DarkLog.Debug("Killing non-server asteroid " + checkVessel.id);
checkVessel.Die();
}
}
}
else
{
if (!serverAsteroids.Contains(checkVessel.id.ToString()))
{
DarkLog.Debug("Killing non-server asteroid " + checkVessel.id + ", we don't own the asteroid-spawning lock");
checkVessel.Die();
}
}
}
}
}