Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add C# scripting support #667

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

pacampbell
Copy link
Collaborator

@pacampbell pacampbell commented Dec 20, 2024

  • Added Roslyn to the project.
  • Added an example of parsing game logic settings from a .csx file.
  • Made GameLogicSettings.csx hotloadable.
  • Adjusted exp point modifier settings for enemies and quests to be
    hotload friendly.
  • Implemented a ScriptModule interface for GameServer scripts.
  • Enabled ScriptModule to be hotloaded for OnChanged and OnCreate events.
  • Converted extended NPC facilities into scripting .csx files for each NPC.

Checklist:

  • The project compiles
  • The PR targets develop branch

@pacampbell pacampbell force-pushed the scripting_experiment branch 5 times, most recently from 81551e3 to 5740041 Compare December 21, 2024 04:06
- Added Roslyn to the project.
- Added an example of parsing game logic settings from a .csx file.
- Made GameLogicSettings.csx hotloadable.
- Adjusted exp point modifier settings for enemies and quests to be
  hotload friendly.
- Implemented a ScriptModule interface for GameServer scripts.
- Converted extended NPC facilities into scripting .csx files for each
  NPC and made directory hotloadable. New NPC options can be added after
  the server starts without a restart.
@pacampbell pacampbell marked this pull request as ready for review December 21, 2024 20:09
<None Update="Files\Assets\scripts\GameLogicSettings.csx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\Assets\scripts\HellWorld.csx">
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete these two scripts that don't exist.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since GameLogicSetting no longer come from the json file maybe we shouldnt have it be part of this class.
Im aware this implies an annoying refactor but i feel its confusing if kept here

/// </summary>
/// <param name="path">Path to a text based file to read</param>
/// <returns>Returns the contents of the file read as a string</returns>
public static string ReadAllText(string path)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use this function in the AssetRepository deserializers too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, we should. This fixes that issue where the file can't be accessed, which is why we have that retry logic. We should be able to remove that and just use this function instead.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add it to the pr?
im not sure why this function fixes the issue but oh well as long as it works

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this article on SF which I tried an no longer get the error.

https://stackoverflow.com/a/61658645

Replaced File.ReadAllText with Util.ReadAllText.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants