Skip to content

Commit 2b815fd

Browse files
Use in modifier for .Set() and .SetAutoOverride()
1 parent 4d09824 commit 2b815fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+2468
-8253
lines changed

src/Flecs.NET.Codegen/Generators/Entity.cs

+42-140
Original file line numberDiff line numberDiff line change
@@ -1178,101 +1178,52 @@ public bool IsChildOf<T>(T value) where T : Enum
11781178
return ref this;
11791179
}
11801180
1181-
/// <inheritdoc cref="Entity.SetAutoOverride{T}(T)"/>
1182-
public ref {{typeName}} SetAutoOverride<T>(T component)
1181+
/// <inheritdoc cref="Entity.SetAutoOverride{T}(in T)"/>
1182+
public ref {{typeName}} SetAutoOverride<T>(in T component)
11831183
{
1184-
Entity.SetAutoOverride(component);
1184+
Entity.SetAutoOverride(in component);
11851185
return ref this;
11861186
}
11871187
1188-
/// <inheritdoc cref="Entity.SetAutoOverride{T}(ref T)"/>
1189-
public ref {{typeName}} SetAutoOverride<T>(ref T component)
1188+
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst}(ulong, in TFirst)"/>
1189+
public ref {{typeName}} SetAutoOverride<TFirst>(ulong second, in TFirst component)
11901190
{
1191-
Entity.SetAutoOverride(ref component);
1191+
Entity.SetAutoOverride(second, in component);
11921192
return ref this;
11931193
}
11941194
1195-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst}(ulong, TFirst)"/>
1196-
public ref {{typeName}} SetAutoOverride<TFirst>(ulong second, TFirst component)
1195+
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(in TFirst)"/>
1196+
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(in TFirst component)
11971197
{
1198-
Entity.SetAutoOverride(second, component);
1198+
Entity.SetAutoOverride<TFirst, TSecond>(in component);
11991199
return ref this;
12001200
}
12011201
1202-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst}(ulong, ref TFirst)"/>
1203-
public ref {{typeName}} SetAutoOverride<TFirst>(ulong second, ref TFirst component)
1202+
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(in TSecond)"/>
1203+
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(in TSecond component)
12041204
{
1205-
Entity.SetAutoOverride(second, ref component);
1205+
Entity.SetAutoOverride<TFirst, TSecond>(in component);
12061206
return ref this;
12071207
}
12081208
1209-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TFirst)"/>
1210-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TFirst component)
1209+
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TSecond, in TFirst)"/>
1210+
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TSecond second, in TFirst component) where TSecond : Enum
12111211
{
1212-
Entity.SetAutoOverride<TFirst, TSecond>(component);
1212+
Entity.SetAutoOverride<TFirst, TSecond>(second, in component);
12131213
return ref this;
12141214
}
12151215
1216-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(ref TFirst)"/>
1217-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(ref TFirst component)
1216+
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TFirst, in TSecond)"/>
1217+
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TFirst first, in TSecond component) where TFirst : Enum
12181218
{
1219-
Entity.SetAutoOverride<TFirst, TSecond>(ref component);
1219+
Entity.SetAutoOverride<TFirst, TSecond>(first, in component);
12201220
return ref this;
12211221
}
12221222
1223-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TSecond)"/>
1224-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TSecond component)
1223+
/// <inheritdoc cref="Entity.SetAutoOverrideSecond{TSecond}(ulong, in TSecond)"/>
1224+
public ref {{typeName}} SetAutoOverrideSecond<TSecond>(ulong first, in TSecond component)
12251225
{
1226-
Entity.SetAutoOverride<TFirst, TSecond>(component);
1227-
return ref this;
1228-
}
1229-
1230-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(ref TSecond)"/>
1231-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(ref TSecond component)
1232-
{
1233-
Entity.SetAutoOverride<TFirst, TSecond>(ref component);
1234-
return ref this;
1235-
}
1236-
1237-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TSecond, TFirst)"/>
1238-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TSecond second, TFirst component) where TSecond : Enum
1239-
{
1240-
Entity.SetAutoOverride<TFirst, TSecond>(second, component);
1241-
return ref this;
1242-
}
1243-
1244-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TSecond, ref TFirst)"/>
1245-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TSecond second, ref TFirst component) where TSecond : Enum
1246-
{
1247-
Entity.SetAutoOverride<TFirst, TSecond>(second, ref component);
1248-
return ref this;
1249-
}
1250-
1251-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TFirst, TSecond)"/>
1252-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TFirst first, TSecond component) where TFirst : Enum
1253-
{
1254-
Entity.SetAutoOverride<TFirst, TSecond>(first, component);
1255-
return ref this;
1256-
}
1257-
1258-
/// <inheritdoc cref="Entity.SetAutoOverride{TFirst, TSecond}(TFirst, ref TSecond)"/>
1259-
public ref {{typeName}} SetAutoOverride<TFirst, TSecond>(TFirst first, ref TSecond component) where TFirst : Enum
1260-
{
1261-
Entity.SetAutoOverride<TFirst, TSecond>(first, ref component);
1262-
return ref this;
1263-
}
1264-
1265-
/// <inheritdoc cref="Entity.SetAutoOverrideSecond{TSecond}(ulong, TSecond)"/>
1266-
public ref {{typeName}} SetAutoOverrideSecond<TSecond>(ulong first, TSecond component)
1267-
{
1268-
Entity.SetAutoOverrideSecond(first, component);
1269-
return ref this;
1270-
}
1271-
1272-
/// <inheritdoc cref="Entity.SetAutoOverrideSecond{TSecond}(ulong, ref TSecond)"/>
1273-
public ref {{typeName}} SetAutoOverrideSecond<TSecond>(ulong first, ref TSecond component)
1274-
{
1275-
Entity.SetAutoOverrideSecond(first, ref component);
1226+
Entity.SetAutoOverrideSecond(first, in component);
12761227
return ref this;
12771228
}
12781229
@@ -1486,101 +1437,52 @@ public bool IsChildOf<T>(T value) where T : Enum
14861437
return ref this;
14871438
}
14881439
1489-
/// <inheritdoc cref="Entity.Set{T}(T)"/>
1490-
public ref {{typeName}} Set<T>(T data)
1491-
{
1492-
Entity.Set(data);
1493-
return ref this;
1494-
}
1495-
1496-
/// <inheritdoc cref="Entity.Set{TFirst}(ulong, TFirst)"/>
1497-
public ref {{typeName}} Set<TFirst>(ulong second, TFirst data)
1498-
{
1499-
Entity.Set(second, data);
1500-
return ref this;
1501-
}
1502-
1503-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TSecond)"/>
1504-
public ref {{typeName}} Set<TFirst, TSecond>(TSecond data)
1505-
{
1506-
Entity.Set<TFirst, TSecond>(data);
1507-
return ref this;
1508-
}
1509-
1510-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TFirst)"/>
1511-
public ref {{typeName}} Set<TFirst, TSecond>(TFirst data)
1512-
{
1513-
Entity.Set<TFirst, TSecond>(data);
1514-
return ref this;
1515-
}
1516-
1517-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TSecond, TFirst)"/>
1518-
public ref {{typeName}} Set<TFirst, TSecond>(TSecond second, TFirst data) where TSecond : Enum
1519-
{
1520-
Entity.Set<TFirst, TSecond>(second, data);
1521-
return ref this;
1522-
}
1523-
1524-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TFirst, TSecond)"/>
1525-
public ref {{typeName}} Set<TFirst, TSecond>(TFirst first, TSecond data) where TFirst : Enum
1526-
{
1527-
Entity.Set<TFirst, TSecond>(first, data);
1528-
return ref this;
1529-
}
1530-
1531-
/// <inheritdoc cref="Entity.SetSecond{TSecond}(ulong, TSecond)"/>
1532-
public ref {{typeName}} SetSecond<TSecond>(ulong first, TSecond data)
1533-
{
1534-
Entity.SetSecond(first, data);
1535-
return ref this;
1536-
}
1537-
1538-
/// <inheritdoc cref="Entity.Set{T}(ref T)"/>
1539-
public ref {{typeName}} Set<T>(ref T data)
1440+
/// <inheritdoc cref="Entity.Set{T}(in T)"/>
1441+
public ref {{typeName}} Set<T>(in T data)
15401442
{
1541-
Entity.Set(ref data);
1443+
Entity.Set(in data);
15421444
return ref this;
15431445
}
15441446
1545-
/// <inheritdoc cref="Entity.Set{TFirst}(ulong, ref TFirst)"/>
1546-
public ref {{typeName}} Set<TFirst>(ulong second, ref TFirst data)
1447+
/// <inheritdoc cref="Entity.Set{TFirst}(ulong, in TFirst)"/>
1448+
public ref {{typeName}} Set<TFirst>(ulong second, in TFirst data)
15471449
{
1548-
Entity.Set(second, ref data);
1450+
Entity.Set(second, in data);
15491451
return ref this;
15501452
}
15511453
1552-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(ref TSecond)"/>
1553-
public ref {{typeName}} Set<TFirst, TSecond>(ref TSecond data)
1454+
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(in TSecond)"/>
1455+
public ref {{typeName}} Set<TFirst, TSecond>(in TSecond data)
15541456
{
1555-
Entity.Set<TFirst, TSecond>(ref data);
1457+
Entity.Set<TFirst, TSecond>(in data);
15561458
return ref this;
15571459
}
15581460
1559-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(ref TFirst)"/>
1560-
public ref {{typeName}} Set<TFirst, TSecond>(ref TFirst data)
1461+
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(in TFirst)"/>
1462+
public ref {{typeName}} Set<TFirst, TSecond>(in TFirst data)
15611463
{
1562-
Entity.Set<TFirst, TSecond>(ref data);
1464+
Entity.Set<TFirst, TSecond>(in data);
15631465
return ref this;
15641466
}
15651467
1566-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TSecond, ref TFirst)"/>
1567-
public ref {{typeName}} Set<TFirst, TSecond>(TSecond second, ref TFirst data) where TSecond : Enum
1468+
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TSecond, in TFirst)"/>
1469+
public ref {{typeName}} Set<TFirst, TSecond>(TSecond second, in TFirst data) where TSecond : Enum
15681470
{
1569-
Entity.Set<TFirst, TSecond>(second, ref data);
1471+
Entity.Set<TFirst, TSecond>(second, in data);
15701472
return ref this;
15711473
}
15721474
1573-
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TFirst, ref TSecond)"/>
1574-
public ref {{typeName}} Set<TFirst, TSecond>(TFirst first, ref TSecond data) where TFirst : Enum
1475+
/// <inheritdoc cref="Entity.Set{TFirst, TSecond}(TFirst, in TSecond)"/>
1476+
public ref {{typeName}} Set<TFirst, TSecond>(TFirst first, in TSecond data) where TFirst : Enum
15751477
{
1576-
Entity.Set<TFirst, TSecond>(first, ref data);
1478+
Entity.Set<TFirst, TSecond>(first, in data);
15771479
return ref this;
15781480
}
15791481
1580-
/// <inheritdoc cref="Entity.SetSecond{TSecond}(ulong, ref TSecond)"/>
1581-
public ref {{typeName}} SetSecond<TSecond>(ulong first, ref TSecond data)
1482+
/// <inheritdoc cref="Entity.SetSecond{TSecond}(ulong, in TSecond)"/>
1483+
public ref {{typeName}} SetSecond<TSecond>(ulong first, in TSecond data)
15821484
{
1583-
Entity.SetSecond(first, ref data);
1485+
Entity.SetSecond(first, in data);
15841486
return ref this;
15851487
}
15861488

src/Flecs.NET.Examples/Entities/SettingComponents.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public static void Main()
1919
// Set data for a typed component using a copy or reference.
2020
Position position = new(1, 1);
2121
entity.Set(position);
22-
entity.Set(ref position);
22+
entity.Set(in position);
2323

2424
// Set data for a typed component using a pointer.
2525
Velocity velocity = new(2, 2);

src/Flecs.NET/Core/Ecs/Module.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static unsafe partial class Ecs
3131
if (!Type<T>.IsTag)
3232
{
3333
module.Add(EcsSparse);
34-
world.Set(ref moduleInstance);
34+
world.Set(in moduleInstance);
3535
}
3636

3737
return module;

0 commit comments

Comments
 (0)