Xavier513

Members
  • Content Count

    29
  • Joined

  • Last visited

Community Reputation

20 Excellent

About Xavier513

  • Rank
    Rocketeer

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Congrats! Long live KSP! So, what would you like to see in KSP 3?
  2. Awsome! Now the Duna polar area are not covered by icing sugar anymore
  3. What is Kift? Kift is an add-on based on Thrift(v0.12.0) . Kift is a bridge between your code and the game, it lets you control the game with your program running outside of the game. Kift is inpired by kRPC -- a great Mod from @djungelorm -- but implemented in a different way. Dev Thread: https://forum.kerbalspaceprogram.com/index.php?/topic/187084-wip173-kift-thrift-plugin-for-ksp-v010-alpha2-2019-08-10/ GitHub: https://github.com/vaporz/Kift Releases: https://github.com/vaporz/Kift/releases Doc portal: https://vaporz.github.io/Kift/index.html Licensed by LGPL-3.0 . Architecture Kift starts a Thrift server inside of KSP process. The server receives requests, then send them to a Message Queue. A KSP addon will dequeue requests from the queue, and run the corresponding Executor. The server will wait until the response to a request is returned. Supported languages Theoritically, any programming language supported by Thrift v0.12.0 is supported by Kift. Languages supported by Thrift v0.12.0: C, C++, Go, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi, etc. Getting Started 1, Install Kift Download Kift.zip, copy the "Kift" folder in zip file into "Kerbal Space Programe/GameData" directory. Now the server side is ready. When your game is loaded and the main menu shows up, the Thift server is started and listening for requests. 2, Connect to Thrift server, and call Kift APIs To interact with the Thrift server within KSP process, you have to write your own client side codes. Following lines of code show how to call a Kift API to get current vessel's info, in C#: // The game is started, and MUST be in Flight scene. // Import "Kift.ThriftGen.dll"(built from "Kift/thrift-gen/gen-csharp"), // or generate stub codes by yourself, then build and import your DLL file. using Kift; // Import "Thrift.dll": https://cwiki.apache.org/confluence/display/thrift/ThriftUsageCSharp using Thrift.Protocol; using Thrift.Transport; ... // The port is configable in "Kerbal Space Program/GameData/Kift/server.cfg" TTransport transport = new TFramedTransport(new TSocket("localhost", 9090)); TProtocol protocol = new TCompactProtocol(transport); KiftService.Client client = new KiftService.Client(protocol); transport.Open(); // Connect to server Vessel v = client.currentVessel(); // Call API "currentVessel" Console.WriteLine(v.Name); ... transport.Close(); // finally close the connection Kift APIs Kift provides two sets of APIs: "InfoSync APIs" and "Command APIs". "InfoSync APIs" pull infos from the game. "Command APIs" send commands to control vessels/parts/game. Command APIs are devided into three categories according to the target. InfoSync APIs Real time snapshot Read data at real time(approximately), useful when you want to monitor any data, such as height, speed, etc. GetInfo APIs Get data from current game, such as current vessel, the part list of a vessel, etc. Command APIs Vessel Control APIs APIs to control a vessel, such as pitch/yaw/roll, enable/disable RCS, deploy/restract landing legs, etc. Part Control APIs APIs to control a part, such as deploy/restract a solar panel, open/close a cargo bay, etc. Game Control APIs APIs to control the game, such as time warp, change camera mode, set/remove maneuver nodes etc. See more about Kift APIs at the doc portal: https://vaporz.github.io/Kift/api/index.html Kift needs your help 1. Please pay more attention to APIs about position/direction/rotation and reference frames, I spent a lot of time investigaing and learning about them, but I still can not be sure about the correctness. 2. Please report an issue if you find a bug: https://github.com/vaporz/Kift/issues 3. Kift's codes are relatively simple, you're very appreciated to submit a PR and contribute to Kift. 4. English is not my native language, please help me to improve the wording of documentation, or add new articles to "Kift/server/articles". Docs are generated from the "md" files under "Kift/server" using Docfx. 5. I'm quite new to C# programming, in fact, this is my first C# program, so please create an issue if you have any suggestion against the code, for example, coding style, best practices, etc. 6. Star "Kift" on GitHub if you like it
  4. What is Kift? Kift is an add-on based on Thrift(v0.12.0) . Kift is a bridge between your code and the game, it lets you control the game with your program running outside of the game. Kift is inpired by kRPC -- a great Mod from @djungelorm -- but implemented in a different way. Release Thread: https://forum.kerbalspaceprogram.com/index.php?/topic/187109-173-kift-thrift-plugin-for-ksp-v010-alpha2/ GitHub: https://github.com/vaporz/Kift Releases: https://github.com/vaporz/Kift/releases Doc portal: https://vaporz.github.io/Kift/index.html Licensed by LGPL-3.0 . Architecture Kift starts a Thrift server inside of KSP process. The server receives requests, then send them to a Message Queue. A KSP addon will dequeue requests from the queue, and run the corresponding Executor. The server will wait until the response to a request is returned. Supported languages Theoritically, any programming language supported by Thrift v0.12.0 is supported by Kift. Languages supported by Thrift v0.12.0: C, C++, Go, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, OCaml and Delphi, etc. Getting Started 1, Install Kift Download Kift.zip, copy the "Kift" folder in zip file into "Kerbal Space Programe/GameData" directory. Now the server side is ready. When your game is loaded and the main menu shows up, the Thift server is started and listening for requests. 2, Connect to Thrift server, and call Kift APIs To interact with the Thrift server within KSP process, you have to write your own client side codes. Following lines of code show how to call a Kift API to get current vessel's info, in C#: // The game is started, and MUST be in Flight scene. // Import "Kift.ThriftGen.dll"(built from "Kift/thrift-gen/gen-csharp"), // or generate stub codes by yourself, then build and import your DLL file. using Kift; // Import "Thrift.dll": https://cwiki.apache.org/confluence/display/thrift/ThriftUsageCSharp using Thrift.Protocol; using Thrift.Transport; ... // The port is configable in "Kerbal Space Program/GameData/Kift/server.cfg" TTransport transport = new TFramedTransport(new TSocket("localhost", 9090)); TProtocol protocol = new TCompactProtocol(transport); KiftService.Client client = new KiftService.Client(protocol); transport.Open(); // Connect to server Vessel v = client.currentVessel(); // Call API "currentVessel" Console.WriteLine(v.Name); ... transport.Close(); // finally close the connection Kift APIs Kift provides two sets of APIs: "InfoSync APIs" and "Command APIs". "InfoSync APIs" pull infos from the game. "Command APIs" send commands to control vessels/parts/game. Command APIs are devided into three categories according to the target. InfoSync APIs Real time snapshot Read data at real time(approximately), useful when you want to monitor any data, such as height, speed, etc. GetInfo APIs Get data from current game, such as current vessel, the part list of a vessel, etc. Command APIs Vessel Control APIs APIs to control a vessel, such as pitch/yaw/roll, enable/disable RCS, deploy/restract landing legs, etc. Part Control APIs APIs to control a part, such as deploy/restract a solar panel, open/close a cargo bay, etc. Game Control APIs APIs to control the game, such as time warp, change camera mode, set/remove maneuver nodes etc. See more about Kift APIs at the doc portal: https://vaporz.github.io/Kift/api/index.html Kift needs your help 1. Please pay more attention to APIs about position/direction/rotation and reference frames, I spent a lot of time investigaing and learning about them, but I still can not be sure about the correctness. 2. Please report an issue if you find a bug: https://github.com/vaporz/Kift/issues 3. Kift's codes are relatively simple, you're very appreciated to submit a PR and contribute to Kift. 4. English is not my native language, please help me to improve the wording of documentation, or add new articles to "Kift/server/articles". Docs are generated from the "md" files under "Kift/server" using Docfx. 5. I'm quite new to C# programming, in fact, this is my first C# program, so please create an issue if you have any suggestion against the code, for example, coding style, best practices, etc. 6. Star "Kift" on GitHub if you like it
  5. Hi, I'm working on a plugin, what's the difference between Orbit.orbitalSpeed and Orbit.vel? My guess is, they have different reference frames: Orbit.orbitalSpeed is relative to the celestial body's center of mass, and Orbit.vel is the velocity in world reference frame. Am I correct?
  6. @Shadowmage I think this is what "Exclude()" does: for example, Exclude(a, b) = b - Project(b, a)
  7. I find another "Exclude()" method at https://github.com/sldsmkd/vector3d/blob/master/Vector3d.cs#L325 public static Vector3d Exclude(Vector3d excludeThis, Vector3d fromThat) { return fromThat - Vector3d.Project(fromThat, excludeThis); } Is it the same with the one in KSP?
  8. Edit: OK, this should be the answer: https://github.com/sldsmkd/vector3d/blob/master/Vector3d.cs#L325 Please correct me if I'm wrong. ------------------------------------------------------------------------------ I understand vector calculations such as "Cross" and "Dot", but what does "Vector3d.Exclude()" means? public static Vector3d Exclude(Vector3d excludeThis, Vector3d fromThat); I'm trying to understand following code from KRPC : /// Returns the up vector for the reference frame in world coordinates. /// The direction in which the y-axis points. /// The vector is not normalized. Vector3d UpNotNormalized { get { switch (type) { ....... case ReferenceFrameType.VesselSurface: { var right = vessel.CoM - vessel.mainBody.position; return Vector3d.Exclude (right, ToNorthPole (vessel).normalized); } ...... } } } /// Vector from given vessel to north pole of body being orbited, in world space. static Vector3d ToNorthPole (global::Vessel vessel) { var parent = vessel.mainBody; return parent.position + ((Vector3d)parent.transform.up) * parent.Radius - (vessel.CoM); } It returns a vector in UP direction in "VesselSurface" reference frame, and I don't understand what "Exclude" means in math. Help please! Thanks!
  9. My only wish currently is to upgrade to latest Unity version, and get rid of the old "outdated" .Net Framework 3.5 .
  10. Is there any method to get a list of CeletialBody in curent game universe? Or a list of CeletialBody names? I find a list at the bottom of file "setting.cfg", though. OK, I get it: FlightGlobals.Bodies
  11. Thanks. Indeed, KRPC is a great mod, and I spent alomost a whole last week reading the source code(I'm totally new to C sharp and KSP plugin development), I learnt A LOT from @djungelorm's great work! But I prefer using existing RPC framework(for example, GRPC, Thrift), rather than building my own RPC framework. Good news! I find Thrift still supports .Net framework 3.5, and in fact I have already ran a "HelloWorld.exe" successfully. The bridge between local process and KSP is through! Now I can continue my development focusing on "bussiness logic".
  12. It's understandable for not upgrading, but the world is changing fast, more and more third-party software never support .Net Framework 3.5, for example, GRPC requires .Net Framework 4.5+, and GRPC has no plan to support 3.5.(I'm planning to create a new plugin based on GRPC, but unfortunately, I find KSP requires .Net framework 3.5) I'm also a programmer, I believe "refactoring/rewriting of existing code" is an important part of a long-term software project such as KSP, the key is how to balance the effort between "refactoring/rewriting of existing code" and new feature development. Many times, I have seen a software finally corrupted and became so hard to maintain that it was replaced by a totally new software, at the cost of huge resources and time investment. Maybe for now, KSP hasn't reach the point that SQUAD has to upgrade .Net Framework, otherwise KSP is too painful to add new features for the dev, or too painful for the community to develop a new plugin/mod. But that day will finally come, as long as KSP is still alive, the later that day is, the more effort "refactoring/rewriting" KSP will require. I can see some signs already in recent years. Even Microsoftware won't end 3.5's life before 2028-10-10, depending on an "unofficially outdated" framework is not a good idea for me, especially when we are talking about KSP, which is still under development and "young". I bravely estimate that, in three years, KSP will upgrade .Net Framework, before SQUAD finds it's too late.
  13. OK, I decide to continue my journey on Windows, everything works smoothly there. Thanks for your replies! @steve_v @DMagic
  14. Hi, I'm a software engineer with 9 years experience on Java and 2 years on Golang. I have also been a KSP player for 4 years. Now I get some ideas and decide to go one step further. So I spent several days learning about C# basics and how to develop a KSP plugin. At first, I followed a tutorial, and succeeded to run a demo on Windows(had some trouble installing .NET 3.5 on Windows 10 though). Then I tried to do the same thing on my Mac. Unfortunately, I failed to set "target framework" to v3.5 in Visual Studio 2017. I imported UnityEngine.dll, UnityEngine.UI.dll, Assembly-Csharp.dll and Assembly-Csharp-firstpass.dll. But the IDE reports this error: "The type or namespace name 'MonoBehaviour' could not be found (are you missing a using directive or an assembly reference?)". The oldest version in the list is 4.5. I googled, read and tried many times, but none worked. At last, I found this page, I'm now doubting that whether it's possible to dev plugins on Mac OS at all? Environment: Mac OS Mojave v10.14.2 Mono 5.18.1 (versions older than 5.10 is not compatible with the OS) Visual Studio for Mac, Community, v7.8.3 Here're my questions: 1, What's the version of .Net framework supported by KSP currently? Is it still version 3.5? 2, How to set the target framework to v3.5 in VS on Mac OS? 3, Is there anybody developing plugins on Mac OS? Should I just give up and move to Windows? Thanks a lot!