-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from SpaceWarpDev/v1.0.0
Space Warp - v1.0.0 Release
- Loading branch information
Showing
22 changed files
with
916 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using KSP.Game; | ||
using KSP.Sim.Definitions; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace SpaceWarp.API.Game.Extensions; | ||
|
||
public static class PartProviderExtensions | ||
{ | ||
public static IEnumerable<PartCore> WithModule<T>(this PartProvider provider) where T : ModuleData | ||
{ | ||
return provider._partData.Values.Where(part => part.modules.OfType<T>().Count() > 0); | ||
} | ||
} |
219 changes: 219 additions & 0 deletions
219
SpaceWarp/API/Game/Extensions/VesselVehicleExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,219 @@ | ||
using KSP.Sim.impl; | ||
using KSP.Sim.State; | ||
using UnityEngine; | ||
|
||
namespace SpaceWarp.API.Game.Extensions; | ||
|
||
public static class VesselVehicleExtensions | ||
{ | ||
public static void SetMainThrottle(this VesselVehicle vehicle, float throttle) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
mainThrottle = throttle | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetRoll(this VesselVehicle vehicle, float roll) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
roll = roll | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetYaw(this VesselVehicle vehicle, float yaw) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
yaw = yaw | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
public static void SetPitch(this VesselVehicle vehicle, float pitch) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
pitch = pitch | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetRollYawPitch(this VesselVehicle vehicle, float roll, float yaw, float pitch) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
roll = roll, | ||
yaw = yaw, | ||
pitch = pitch | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetRollTrim(this VesselVehicle vehicle, float rollTrim) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
rollTrim=rollTrim | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetYawTrim(this VesselVehicle vehicle, float yawTrim) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
yawTrim=yawTrim | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetPitchTrim(this VesselVehicle vehicle, float pitchTrim) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
pitchTrim = pitchTrim | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
|
||
public static void SetRollYawPitchTrim(this VesselVehicle vehicle, float rollTrim, float yawTrim, float pitchTrim) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
rollTrim = rollTrim, | ||
yawTrim = yawTrim, | ||
pitchTrim = pitchTrim | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetInputRoll(this VesselVehicle vehicle, float roll) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
inputRoll = roll | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetInputYaw(this VesselVehicle vehicle, float yaw) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
inputYaw = yaw | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
public static void SetInputPitch(this VesselVehicle vehicle, float pitch) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
inputPitch = pitch | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetInputRollYawPitch(this VesselVehicle vehicle, float roll, float yaw, float pitch) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
inputRoll = roll, | ||
inputYaw = yaw, | ||
inputPitch = pitch | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetWheelSteer(this VesselVehicle vehicle, float wheelSteer, float? wheelSteerTrim=null) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
wheelSteer = wheelSteer, | ||
wheelSteerTrim = wheelSteerTrim | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetWheelThrottle(this VesselVehicle vehicle, float wheelThrottle, float? wheelThrottleTrim=null) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
wheelThrottle = wheelThrottle, | ||
wheelThrottleTrim = wheelThrottleTrim | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetXYZ(this VesselVehicle vehicle, float? X = null, float? Y = null, float? Z = null) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
X = X, | ||
Y = Y, | ||
Z = Z | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
public static void SetXYZ(this VesselVehicle vehicle, Vector3 XYZ) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
X = XYZ.x, | ||
Y = XYZ.y, | ||
Z = XYZ.z | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetKillRot(this VesselVehicle vehicle, bool killRot) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
killRot = killRot | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetGearState(this VesselVehicle vehicle, bool up) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
gearUp = up, | ||
gearDown = !up | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
|
||
public static void SetHeadlight(this VesselVehicle vehicle, bool on) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
headlight = on | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
|
||
public static void SetBrake(this VesselVehicle vehicle, bool on) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
brakes = on | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
|
||
public static void SetStage(this VesselVehicle vehicle, bool stage) | ||
{ | ||
var incremental = new FlightCtrlStateIncremental() | ||
{ | ||
stage = stage | ||
}; | ||
vehicle.AtomicSet(incremental); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using KSP.Game; | ||
using KSP.Sim.impl; | ||
|
||
namespace SpaceWarp.API.Game; | ||
|
||
public static class Vehicle | ||
{ | ||
public static VesselVehicle ActiveVesselVehicle => GameManager.Instance.Game.ViewController._activeVesselVehicle; | ||
public static VesselComponent ActiveSimVessel => GameManager.Instance.Game.ViewController.GetActiveSimVessel(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.