1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 23:52:57 +08:00

Clarify type check

This commit is contained in:
Bartłomiej Dach 2023-05-04 19:06:07 +02:00
parent 1f1342b099
commit 485b7282dc
No known key found for this signature in database

View File

@ -188,10 +188,13 @@ namespace osu.Game.Rulesets.Mods
if (sourceSetting.IsDefault) if (sourceSetting.IsDefault)
continue; continue;
var targetType = targetSetting.GetType(); var targetBindableType = targetSetting.GetType();
var sourceType = sourceSetting.GetType(); var sourceBindableType = sourceSetting.GetType();
if (!targetType.IsAssignableFrom(sourceType) && !sourceType.IsAssignableFrom(targetType)) // if either the target is assignable to the source or the source is assignable to the target,
// then we presume that the data types contained in both bindables are compatible and we can proceed with the copy.
// this handles cases like `Bindable<int>` and `BindableInt`.
if (!targetBindableType.IsAssignableFrom(sourceBindableType) && !sourceBindableType.IsAssignableFrom(targetBindableType))
continue; continue;
// TODO: special case for handling number types // TODO: special case for handling number types