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

Save System? #20

Open
Gammer0909 opened this issue Dec 27, 2023 · 5 comments
Open

Save System? #20

Gammer0909 opened this issue Dec 27, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@Gammer0909
Copy link
Contributor

I propose a Saving System, to abstract save files to make a save game implementation easier.

Do I have to propose how I would have this implemented? If so I will, upon request.

I will start as soon as I'm cleared to start.

Thanks, Gammer0909

@MrScautHD
Copy link
Owner

Hello,
Sounds very usefull, how would you impliment this?

@MrScautHD MrScautHD added the enhancement New feature or request label Dec 27, 2023
@Gammer0909
Copy link
Contributor Author

Gammer0909 commented Dec 31, 2023

@MrScautHD

Save/Load System Spec

By Gammer0909

SaveSettings

This is a data-holding class that needs:

  • A Filename, and directory
  • Encryption method (This might take me a minute to figure out...)
  • A GameSettings object
  • A type to save in, these can be:
    • YAML
    • JSON
    • XML

This will create save files to the directory you specified.


LoadSettings

This class sets up your settings for loading your save file.

This needs:

  • A Filename and directory
  • Encryption method (This might take me a minute to figure out...)
  • A type to load from, these can be:
    • YAML
    • JSON
    • XML

This will extract the data from the save file and return it as a GameSettings object.

(This may change in the future, but for now, this is how it will work.)


Making Objects Saveable

To make an object saveable, you need to add the Saveable attribute to the class.

This will allow the object to be saved and loaded.

ex:

[Saveable]
public class Person : Entity {

    // Things derived from Entity
    // ....

    public string Name { get; set; }
    public int Age { get; set; }
}

Saving/Loading Objects

To save an object, you need to create a SaveSettings object, and call the Save() method.

ex:

SaveSettings settings = new SaveSettings("C:/Users/Me/Documents/MyGame/SaveFiles", new GameSettings(), EncryptionMethod.None, SaveType.YAML);

Person person = new Person("Bob", 20);

settings.Save(person);

Extra Dependency

I will be using the YamlDotNet library for the YAML serialization.

(Newtonsoft.Json is already a dependency for the project, so I will be using that for JSON serialization.)

Namespace and my Code Style

The namespace for the Saving system will be in

Sparkle.csharp.saving

and the load system will be in

Sparkle.csharp.loading

and the attributes will be in

Sparkle.csharp.attributes


Code Style

I will be using the C# code style, and I will be using the C# naming conventions.

However, I do some things differently:

// I always use `var` for objects, not new()
var person = new Person("Bob", 20);

// For braces, I use the `K&R` style
// Ex
void Method() {
    if (true) {
        // Do something
    } else {
        // Do something else
    }

    if (false)
        Statement();
}

If you request that I change this style for my PR, I will.


Thanks, Gammer0909

(Sorry for taking a long time to respond, I had some things to do and I had to design the API.)

@MrScautHD
Copy link
Owner

looks very cool!

(Sorry for taking a long time to respond)

@Gammer0909
Copy link
Contributor Author

Am I clear to start?

@MrScautHD
Copy link
Owner

Yep!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants