Skip to content

Commit

Permalink
Merge pull request #7 from JonnyOThan/movementinput
Browse files Browse the repository at this point in the history
New movement system
  • Loading branch information
JonnyOThan authored Sep 16, 2023
2 parents 6567bf4 + aee54b6 commit 95751b1
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 330 deletions.
Binary file modified GameData/kOS-EVA/Plugins/KISAutoEquip.dll
Binary file not shown.
Binary file modified GameData/kOS-EVA/Plugins/KerbalBot.dll
Binary file not shown.
Binary file modified GameData/kOS-EVA/Plugins/kOS-EVA.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions GameData/kOS-EVA/kOS-EVA.version
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"VERSION":{
"MAJOR":0,
"MINOR":1,
"PATCH":2,
"MINOR":2,
"PATCH":0,
"BUILD":0
},
"KSP_VERSION":{
Expand Down
91 changes: 80 additions & 11 deletions kOS-EVA/Addon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ private void InitializeSuffixes()
{

AddSuffix("TOGGLE_RCS", new OneArgsSuffix<BooleanValue>(ToggleRCS, "Switch the RCS of the Pack <on|off>"));
AddSuffix("RCS", new SetSuffix<BooleanValue>(GetRCS, SetRCS, "Querry or set the status of the pack RCS"));
AddSuffix("LIGHTS", new SetSuffix<BooleanValue>(GetLights, SetLights, "Querry or set the status of the headlamps"));
AddSuffix("RCS", new SetSuffix<BooleanValue>(GetRCS, SetRCS, "Query or set the status of the pack RCS"));
AddSuffix("LIGHTS", new SetSuffix<BooleanValue>(GetLights, SetLights, "Query or set the status of the headlamps"));
AddSuffix("VISOR", new SetSuffix<BooleanValue>(GetVisor, SetVisor));
AddSuffix("HELMET", new SetSuffix<BooleanValue>(GetHelmet, SetHelmet));
AddSuffix("DOEVENT", new TwoArgsSuffix<Suffixed.Part.PartValue, StringValue>(DoEvent, "Performs a Event on a others vessel part."));
AddSuffix("LADDER_RELEASE", new NoArgsVoidSuffix(LadderRelease, "Release a grabbed ladder"));
AddSuffix("LADDER_GRAB", new NoArgsVoidSuffix(LadderGrab, "Grab a nearby ladder"));
Expand All @@ -50,7 +52,13 @@ private void InitializeSuffixes()
AddSuffix("STOPALLANIMATIONS", new NoArgsVoidSuffix(StopAllAnimations, "Stops all Animations"));
AddSuffix(new[] { "GOEVA", "EVA" }, new OneArgsSuffix<CrewMember>(GoEVA, "Compliments a Kerbal to the Outside"));
AddSuffix("DUMPEXPERIMENTS", new NoArgsVoidSuffix(DumpExperiments));

AddSuffix("NEUTRALIZE", new SetSuffix<BooleanValue>(() => evacontrol.Neutralize, value => evacontrol.Neutralize = value));
AddSuffix("STARBOARD", new SetSuffix<ScalarValue>(() => evacontrol.MovementThrottle.x, value => { var throttle = evacontrol.MovementThrottle; throttle.x = Mathf.Clamp(value, -1, 1); evacontrol.MovementThrottle = throttle; }));
AddSuffix("TOP", new SetSuffix<ScalarValue>(() => evacontrol.MovementThrottle.y, value => { var throttle = evacontrol.MovementThrottle; throttle.y = Mathf.Clamp(value, -1, 1); evacontrol.MovementThrottle = throttle; }));
AddSuffix("FORE", new SetSuffix<ScalarValue>(() => evacontrol.MovementThrottle.z, value => { var throttle = evacontrol.MovementThrottle; throttle.z = Mathf.Clamp(value, -1, 1); evacontrol.MovementThrottle = throttle; }));
AddSuffix("MOVETHROTTLE", new SetSuffix<Vector>(() => new Vector(evacontrol.MovementThrottle), value => evacontrol.MovementThrottle = value.ToVector3()));
AddSuffix("JUMP", new NoArgsVoidSuffix(Jump));
AddSuffix("SPRINT", new SetSuffix<BooleanValue>(() => evacontrol.Sprint, value => evacontrol.Sprint = value));

// Set a default bootfilename, when no other has been set.
if (shared.Vessel.isEVA && shared.KSPPart.GetComponentCached<Module.kOSProcessor>(ref _myprocessor).bootFile.ToLower() == "none" )
Expand All @@ -60,13 +68,52 @@ private void InitializeSuffixes()
myproc.bootFile = "/boot/eva";
}

#if DEBUG
CheckEvaController();

#if DEBUG
AddSuffix("LS", new NoArgsSuffix<ListValue>(listfields, ""));
AddSuffix("LSF", new NoArgsSuffix<ListValue>(listfunctions, ""));
#endif

}

private void Jump()
{
CheckEvaController();
evacontrol.Jump = true;
}

private BooleanValue GetHelmet()
{
CheckEvaController();
return kerbaleva.isHelmetEnabled;
}

private void SetHelmet(BooleanValue value)
{
CheckEvaController();
kerbaleva.ToggleHelmet(value);
}

private BooleanValue GetVisor()
{
CheckEvaController();
return kerbaleva.visorState == KerbalEVA.VisorStates.Lowered;
}

private void SetVisor(BooleanValue value)
{
CheckEvaController();
if (value)
{
kerbaleva.LowerVisor();
}
else
{
kerbaleva.RaiseVisor();
}
}

private void DumpExperiments()
{
if (!shared.Vessel.isEVA) return;
Expand Down Expand Up @@ -476,30 +523,52 @@ private void MoveKerbal(StringValue direction)

Command command = (Command)Enum.Parse(typeof(Command), direction, true);
Debug.Log("EVA Command: " + command.ToString());
this.evacontrol.order = command;

switch (command)
{
case Command.Forward:
evacontrol.MovementThrottle = new Vector3(0, 0, 1);
break;
case Command.Backward:
evacontrol.MovementThrottle = new Vector3(0, 0, -1);
break;
case Command.Left:
evacontrol.MovementThrottle = new Vector3(-1, 0, 0);
break;
case Command.Right:
evacontrol.MovementThrottle = new Vector3(1, 0, 0);
break;
case Command.Up:
evacontrol.MovementThrottle = new Vector3(0, 1, 0);
break;
case Command.Down:
evacontrol.MovementThrottle = new Vector3(0, -1, 0);
break;
case Command.LookAt:
case Command.Stop:
evacontrol.MovementThrottle = Vector3.zero;
break;
}
}

private void TurnLeft(ScalarValue degrees)
{
if (!shared.Vessel.isEVA) { return; }
CheckEvaController();
this.evacontrol.lookdirection = v_rotate(kerbaleva.vessel.transform.forward, kerbaleva.vessel.transform.right, -degrees.GetDoubleValue());
this.evacontrol.order = Command.LookAt;
this.evacontrol.LookDirection = v_rotate(kerbaleva.vessel.transform.forward, kerbaleva.vessel.transform.right, -degrees.GetDoubleValue());
}
private void TurnRight(ScalarValue degrees)
{
if (!shared.Vessel.isEVA) { return; }
CheckEvaController();
this.evacontrol.lookdirection = v_rotate(kerbaleva.vessel.transform.forward, kerbaleva.vessel.transform.right, degrees.GetDoubleValue());
this.evacontrol.order = Command.LookAt;
this.evacontrol.LookDirection = v_rotate(kerbaleva.vessel.transform.forward, kerbaleva.vessel.transform.right, degrees.GetDoubleValue());
}

private void TurnTo(Vector direction)
{
if (!shared.Vessel.isEVA) { return; }
CheckEvaController();
this.evacontrol.lookdirection = direction.ToVector3D();
this.evacontrol.order = Command.LookAt;
this.evacontrol.LookDirection = direction.ToVector3D();
}
#endregion

Expand Down
Loading

0 comments on commit 95751b1

Please sign in to comment.