Commit Graph

229 Commits

Author SHA1 Message Date
Paul Chote
8f14dd6113 Fix crash when a sequences defines both Alpha and Reverses. 2024-10-15 10:53:05 +03:00
Gustas
f21572d22a Fix DynamicFacingInit not being dynamic 2024-09-13 19:04:38 +02:00
Matthias Mailänder
14ef6b5774 Fix formatting rule warnings. 2024-08-03 13:27:18 +03:00
RoosterDragon
0649f3dc32 RCS0056 - roslynator_max_line_length = 160 2024-07-29 21:56:36 +02:00
RoosterDragon
9d5d2ab493 RCS0056 - roslynator_max_line_length = 180 2024-07-29 21:56:36 +02:00
Gustas
6b463f9d9e Remove color caches 2024-05-04 16:31:35 +02:00
Gustas
2f331548e1 Remove player colors from healthbars 2024-05-04 16:31:35 +02:00
Gustas
34262fb33c Make PlayerRelationShipColor static 2024-05-04 16:31:35 +02:00
David Wilson
2ced4abc24 Editor selection refactor pt1 2024-01-24 10:11:39 +02:00
Wojciech Walaszek
00857df990 adds tilting on slopes to suitable actor previews 2024-01-09 14:56:30 +02:00
Oliver Brakmann
c4acd8b361 Add ability to draw a border around a set of adjacent cells. 2023-12-03 17:14:47 +00:00
Paul Chote
3b67e425ed Add FilenamePattern support to sequences. 2023-11-16 15:06:10 +02:00
RoosterDragon
360f24f609 Fix IDE0055
This rule no longer appears to be buggy, so enforce it. Some of the automated fixes are adjusted in order to improve the result. #pragma directives have no option to control indentation, so remove them where possible.
2023-11-16 08:45:10 +02:00
RoosterDragon
4dd787be13 Fix RCS1061 2023-11-10 10:38:41 +02:00
Paul Chote
20c683fb4f Enforce stricter checks on sequence Facings. 2023-10-21 18:23:37 +03:00
Gustas
686040a316 Turn ModelRenderer and VoxelCache into traits 2023-09-23 19:12:51 +02:00
RoosterDragon
b7e0ed9b87 Improve lookups of nodes by key in MiniYaml.
When handling the Nodes collection in MiniYaml, individual nodes are located via one of two methods:

// Lookup a single key with linear search.
var node = yaml.Nodes.FirstOrDefault(n => n.Key == "SomeKey");

// Convert to dictionary, expecting many key lookups.
var dict = nodes.ToDictionary();

// Lookup a single key in the dictionary.
var node = dict["SomeKey"];

To simplify lookup of individual keys via linear search, provide helper methods NodeWithKeyOrDefault and NodeWithKey. These helpers do the equivalent of Single{OrDefault} searches. Whilst this requires checking the whole list, it provides a useful correctness check. Two duplicated keys in TS yaml are fixed as a result. We can also optimize the helpers to not use LINQ, avoiding allocation of the delegate to search for a key.

Adjust existing code to use either lnear searches or dictionary lookups based on whether it will be resolving many keys. Resolving few keys can be done with linear searches to avoid building a dictionary. Resolving many keys should be done with a dictionary to avoid quaradtic runtime from repeated linear searches.
2023-09-23 14:31:04 +02:00
RoosterDragon
949ba589c0 MiniYaml becomes an immutable data structure.
This changeset is motivated by a simple concept - get rid of the MiniYaml.Clone and MiniYamlNode.Clone methods to avoid deep copying yaml trees during merging. MiniYaml becoming immutable allows the merge function to reuse existing yaml trees rather than cloning them, saving on memory and improving merge performance. On initial loading the YAML for all maps is processed, so this provides a small reduction in initial loading time.

The rest of the changeset is dealing with the change in the exposed API surface. Some With* helper methods are introduced to allow creating new YAML from existing YAML. Areas of code that generated small amounts of YAML are able to transition directly to the immutable model without too much ceremony. Some use cases are far less ergonomic even with these helper methods and so a MiniYamlBuilder is introduced to retain mutable creation functionality. This allows those areas to continue to use the old mutable structures. The main users are the update rules and linting capabilities.
2023-08-07 21:57:10 +03:00
abcdefg30
c095690619 Fix combined sequences using frames being broken 2023-07-01 12:56:50 +02:00
RoosterDragon
f4af5c1764 Fix CA1852 2023-06-06 11:51:47 +03:00
RoosterDragon
277699cbd5 Fix CA1822 2023-06-06 11:51:47 +03:00
abcdefg30
ce7f9e71c1 DefaultSpriteSequence: Avoid an extra allocation and LINQ when adding shadow frames 2023-05-16 22:57:33 +03:00
abcdefg30
05f21fcbe2 DefaultSpriteSequence: Merge if statements for readability 2023-05-16 22:57:33 +03:00
abcdefg30
00f2ba1a53 DefaultSpriteSequence: Remove redundant modulo operations
frame is already bounded by length.Value
2023-05-16 22:57:33 +03:00
abcdefg30
991e0a4c9a DefaultSpriteSequence: Use .Count == 0 over !.Any() 2023-05-16 22:57:33 +03:00
abcdefg30
aa28881726 DefaultSpriteSequence: Use List.Find instead of LINQ's FirstOrDefault 2023-05-16 22:57:33 +03:00
Gustas
44f1af7059 Move TileScale to MapGrid 2023-05-02 16:37:30 +03:00
Gustas
7ef1dccdcf Add ContrailEndWidth 2023-04-21 17:58:42 +02:00
RoosterDragon
14c0d011ea Fix SA1414 2023-04-08 16:51:51 +03:00
RoosterDragon
8a285f9b19 Fix IDE0090 2023-04-08 16:51:51 +03:00
RoosterDragon
83561d639d Update LangVersion to C# 9.
mono was the bottleneck restricting our ability to use a newer C# version. mono 6.12 is currently available. Although poorly documented on their website, this supports C# 9. https://www.mono-project.com/docs/about-mono/versioning/#mono-source-versioning indicates mono 6.12 uses Roslyn 3.9.0. https://github.com/dotnet/roslyn/blob/main/docs/wiki/NuGet-packages.md#versioning indicates Roslyn 3.9.0 supports C# 9.

This unlocks C# 8 and C# 9 features previously unavailable to us.
- https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-80
- https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-version-history#c-version-9

A newer version of StyleCop is required to avoid rules tripping up on the new syntax. Currently only prerelease versions are available but their use is encouraged https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/3420#issuecomment-994899135

Fix style rule violations on existing rules where the newer language version makes some existing casts redundant or allows use of the null coalescing assignment operator.
2023-04-05 15:27:41 +03:00
RoosterDragon
98c4eaca83 Fix IDE0032 2023-03-14 13:41:25 +02:00
Paul Chote
3b0b15abb9 Reduce duplication and allocations around CalculateFrameIndices. 2023-03-10 20:11:33 +02:00
Paul Chote
c35ab081ff Rewrite sequence loading logic.
Multiple layers of Lazy<T>ness are replaced with
an explicit two-part loading scheme.

Sequences are parsed immediately, without the need
for the sprite assets, and tell the SpriteCache
which frames they need. Use-cases that want the
actual sprites can then tell the SpriteCache to
load the frames and the sequences to resolve the
sprites.
2023-03-10 20:11:33 +02:00
Paul Chote
a6f3db0a45 Allow all sprites to use interpolated facings. 2023-03-10 20:11:33 +02:00
Paul Chote
b051211842 Remove internal state from ISpriteSequence API. 2023-03-10 20:11:33 +02:00
Paul Chote
992ba1a9a2 Remove HasEmbeddedPalette from sequences. 2023-03-10 20:11:33 +02:00
RoosterDragon
52fd564eac Fix some whitespace formatting issues: stray tabs or spaces.
Wrap some long lines on affected code.
2023-03-02 20:02:45 +02:00
RoosterDragon
8ee6957e6a Fix IDE0048 2023-03-01 21:56:28 +02:00
RoosterDragon
0b01b73111 Fix IDE0060 2023-02-28 21:21:40 +02:00
RoosterDragon
d4135d608e Fix IDE0039 2023-02-27 10:09:11 +01:00
Gustas
8d0fe52dd8 Remove unnecessary parentheses 2023-02-27 08:36:47 +02:00
Paul Chote
5b8f148c50 Simplify tileset-specific sequence definitions.
All magic behaviour for constructing sprite filenames
has been removed in favour of an explicit Filename
(and TilesetFilenames for tileset-specific sequences)
property.
2023-01-22 22:10:48 +02:00
Paul Chote
04c3cd6ec5 Reimplement sequence Defaults parsing:
The previous MiniYaml.Merge implementation interacted
poorly with yaml inheritance, making it complicated
(or impossible) to override certain keys from Defaults.

The new implementation is simpler: If a key is defined
it will be used. If it isn't, the default (if defined)
will be used. Defaults can be masked by making sure
the same key is defined (even with an empty value)
in the sequence.

This also fixes naming within the sequence code to
distinguish between images (a group of sequences),
sequences (defining a specific sprite/animation),
and filenames for a specific sprite/animation.
2023-01-22 22:10:48 +02:00
abcdefg30
5bf7fe852c Remove the copyright year numbers 2023-01-11 11:58:54 +02:00
Gustas
f3e44094a1 Fix contrail using the wrong colors 2022-12-21 19:35:52 +02:00
Gustas
1809817b3f Add ContrailEndColor and Contrail transparency control 2022-09-24 13:19:22 +02:00
AspectInteractive2
a1a50d6c98 Added rotation logic to the renderer to enable the use of Interpolated Facings. 2022-07-17 17:03:53 +02:00
Paul Chote
c8df1e864c Rework sequence docs plumbing. 2022-07-02 14:10:52 +03:00
Paul Chote
2037e37d4e Replace Sequence EmbeddedPalette with HasEmbeddedPalette. 2022-07-02 14:10:52 +03:00