RogueSharp icon indicating copy to clipboard operation
RogueSharp copied to clipboard

v5.0 upgrade guide

Open bsimser opened this issue 4 years ago • 2 comments

Seems there's a lot of changes to v5.0 that I took a look at but it broke most of my code and I can't find alternative ways to figure out the way to move forward, so I have to go back to the last release until either I write my own functions to replace the old missing ones or figure out how to migration v4 RogueSharp to v5. Would like to see some documentation on how to do this.

Specifically here's a few things that break in v5 that I don't see a clear path to fix:

  • ComputeFov is no longer in the Map class. I know there's a FieldOfView class but it doesn't seem to be used anywhere. I think you're supposed to use the FieldOfView class on the fly and pass the Map in and use it's ComputeFov from it?
  • Cells no longer have a value for if they're explored or not (IsExplored) so do we have to keep track of this ourselves in our own Cell implementations?

Thanks

bsimser avatar May 25 '20 15:05 bsimser

Check out this branch with changes to the example project: https://github.com/FaronBracy/RogueSharpRLNetSamples/compare/V5Upgrade

Specifically this commit: https://github.com/FaronBracy/RogueSharpRLNetSamples/commit/deea0d46a38e37413c121e3d840d2f57fe263346

There is now a generic Map<TCell> where TCell is your own Cell class. In the example I make a DungeonCell which has the IsExplored property.

In the example I also add a field of view method to the DungeonMap<DungeonCell> class that makes use of the FiledOfView class.

public ReadOnlyCollection<DungeonCell> ComputeFov( int xOrigin, int yOrigin, int radius, bool lightWalls )
{
  return _fieldOfView.ComputeFov( xOrigin, yOrigin, radius, lightWalls );
}

Because there are so many changes in V5 I plan to do a blog post about upgrading before making it a real release. I also was hoping to get some feedback and appreciate your comments here.

FaronBracy avatar May 26 '20 11:05 FaronBracy

I'm in a similar position, but with a new project. The existing material (tutorials) are expected to be out of date, but what really slowed me down was that there are no samples that deal with with 5.0pre and the 'modern' way to do things.

The samples use the older, direct method of generating a map while the readme suggests using IMapCreationStrategy. The upgrade samples certainly helped, but it took a fairly long time for me to figure out how to get an inherited Map and Cell class to both play nice with this. I resorted to reading the map creation code in the library.

Talkyn avatar Jul 25 '21 23:07 Talkyn