This commit is contained in:
XtraCube committed 2024-08-27 14:30:27 -04:00
1 parent 74592b2558
commit 2dadf08df4
2 files changed
+11 -2

No files matched your search

+1 -2
View File
@@ -81,7 +81,6 @@ public interface ICustomRole
ParentMod.PluginConfig.TryGetEntry<int>(NumConfigDefinition, out var numEntry);
ParentMod.PluginConfig.TryGetEntry<int>(ChanceConfigDefinition, out var chanceEntry);
// TODO: use the RoleID class when that branch is merged
return new NetData((uint)((RoleBehaviour)this).Role, BitConverter.GetBytes(numEntry.Value).AddRangeToArray(BitConverter.GetBytes(chanceEntry.Value)));
return new NetData(RoleId.Get(GetType()), BitConverter.GetBytes(numEntry.Value).AddRangeToArray(BitConverter.GetBytes(chanceEntry.Value)));
}
}
+10
View File
@@ -14,4 +14,14 @@ public class RoleId
return roleId;
}
public static ushort Get(Type type)
{
if (!CustomRoleManager.RoleIds.TryGetValue(type, out var roleId))
{
throw new InvalidOperationException($"Role {type} is not registered");
}
return roleId;
}
}