refactor(world): read-only World.Mobiles / World.Items views (drop scalar count props) #160
No reviewers
Labels
No labels
alpha:wave-0
alpha:wave-1
alpha:wave-2
alpha:wave-3
area:assets
area:combat
area:ecology
area:infra
area:render
area:scripting
area:ui
area:world
enhancement
epic
migration
post-alpha
roadmap
tech-debt
type:bug
type:chore
type:design
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
marco/IsoMmo!160
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/world-entity-views"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Unify entity access on the
Worldfacade behind two read-only query views —World.MobilesandWorld.Items— replacing the scattered scalar count props andFindMobile. ModernUO-style (World.Mobiles/World.Items), but read-only: mutation stays onWorld's own methods. Closes #158.World.Mobiles(MobileCollection : IReadOnlyCollection<Mobile>) — unifies the player + creature registries:Find(id)(live instance),Count, and enumeration, soworld.Mobiles.Count(m => m.IsPlayer)/Find(id)read cleanly. AddedMobile.IsPlayer(virtual;trueonPlayerMobile).World.Items(ItemCollection : IReadOnlyCollection<Item>) —Find(id),Count, enumeration overItemRegistry.World.FindMobile,World.CreatureCount,World.PlacedItemCount,World.ItemCount— migrated every call-site (GMSetCommand/SetSkillCommand,WorldPersister,WorldTickmetrics, tests) to the views.Item+ItemPlacepromoted topublic, withItem's mutating setters madeinternal setand itsSerialize/Deserializeinternal— so an item handed out byItems.Findis a read/inspect handle; placement/ownership still change only throughWorld/ItemRegistryoperations.EquipLayerwas already public.Why read-only (not the raw registry)
Exposing the mutating registries would let callers
Spawn/Give/reassign around the facade, breaking the thin-facade + single-thread discipline. The views expose only find/count/enumerate;Find(id)returns the live entity for the act-on-instance pattern (e.g. GMSetStat) — identical to the oldFindMobile, now unified. Items can't own Mobile-style guarded mutators (an item's validity is contextual — walkable tile, owner, weight budget — which lives inItemRegistry), soItems.Findis honestly a read/inspect handle while mutation stays on the facade.Invariants Check (persisted from the critical-design-review)
SetCommand/SetSkillCommandstill authorize viaCanExecute; only the target lookup changed toMobiles.Find.World.csHARD GATE ✓Mobiles/Itemsare trivial property gets; find/count/enumerate logic lives in the view components. Net logic inWorld.csdecreased (removedFindMobile/count bodies).ScreenHARD GATE N/A — server-only.World.Mobiles.Find(id)returns the liveMobile; no side-collection — the views are projections over the authoritative registries.IsPlayeris a virtual override (polymorphism), not a type switch.Item.Serialize/Deserializebecameinternalbut format + version int unchanged; no blob change.MobilesWithin/PlayersWithinuntouched; the views add a whole-world query surface, not an AoI change.World.Mobiles/World.Items; diverges by staying read-only and keeping per-player blobs (no global linker, #23).docs/architecture.mdupdated; DoD in #158.How it was tested
WorldEntityViewsTests(7):Mobiles.Findreturns the live instance (mutation via it is observed), unknown id → null,Count+ predicate counts split players/creatures, enumeration covers both;Items.Find/Count, unknown id → null, predicate count separates Ground vs Placed.dotnet test IsoMmo.slnx— all 7 projects green (GameServer 213).dotnet build IsoMmo.slnxclean.dotnet csharpier check .clean.Checklist
just lintpasses (zero warnings)just testgreen (whole solution builds)docs/architecture.md) + DoD in #158