refactor: remove Source property from IRelationship

Remove the redundant `Source` property from `IRelationship` and its
implementations. Since the relationship component is inherently
stored on the source entity, the `Source` field was unnecessary and
required manual synchronization during deserialization.

This change simplifies the relationship model, reduces memory usage,
and removes the need for reflection-based fixups in the serializer.
This commit is contained in:
2026-07-20 22:59:27 +08:00
parent 2de735498c
commit 91c6f4aa2c
21 changed files with 39 additions and 98 deletions
+3 -3
View File
@@ -57,7 +57,7 @@ public class GameSetupSystem : ISystem
var defs = CardDataLoader.LoadDefinitions(world, _cardDataCsv);
foreach (var (defEntity, _) in defs)
{
world.AddComponent(defEntity, new InDeck { Source = defEntity, Target = publicDeck });
world.AddComponent(defEntity, new InDeck { Target = publicDeck });
}
// Shuffle public deck.
@@ -79,12 +79,12 @@ public class GameSetupSystem : ISystem
world.AddComponent(leader, new Leader());
world.AddComponent(leader, new CardDef { Name = $"领袖{i}", Ranks = new[] { 0 }, Effect = CardEffect.None, Kind = CardKind.Faction });
world.AddComponent(leader, new Card { Rank = 0, FaceDown = false });
world.AddComponent(leader, new OnField { Source = leader, Target = player });
world.AddComponent(leader, new OnField { Target = player });
// Create banner.
var banner = world.CreateEntity();
world.AddComponent(banner, new Banner());
world.AddComponent(banner, new OnField { Source = banner, Target = player });
world.AddComponent(banner, new OnField { Target = player });
// Create faction deck.
var factionDeck = world.CreateEntity();
+1 -1
View File
@@ -42,7 +42,7 @@ public class ScoringSystem : ISystem
if (castles.Count > 0)
{
var castle = castles[0];
world.AddComponent(castle, new HeldBy { Source = castle, Target = winner });
world.AddComponent(castle, new HeldBy { Target = winner });
world.RemoveComponent<Castle>(castle);
}