From 7d320d5b4e2d0c740f4fceb150436f4a03497cbe Mon Sep 17 00:00:00 2001 From: Saphire Date: Mon, 21 Oct 2024 02:59:16 +0600 Subject: [PATCH 1/4] Change the movable contents to actually work, and make view include Center contents --- OpenDreamRuntime/Objects/Types/DreamList.cs | 85 +++++++++++++++++++ .../Objects/Types/DreamObjectMovable.cs | 21 ++--- .../Procs/Native/DreamProcNativeRoot.cs | 10 ++- TestGame/code.dm | 54 ++++++++++-- 4 files changed, 147 insertions(+), 23 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 31d66392a5..7344a9e0c7 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -1263,6 +1263,91 @@ public IEnumerable GetTurfs() { } } +// mob.contents, obj.contents list +public sealed class MovableContentsList(DreamObjectDefinition listDef, DreamObjectMovable movable) : DreamList(listDef, 0) { + private readonly DreamObjectMovable _movable = movable; + public override DreamValue GetValue(DreamValue key) { + if (!key.TryGetValueAsInteger(out var index)) + throw new Exception($"Invalid index into movable contents list: {key}"); + + + if (index < 1 || index > _movable.ChildCount) + throw new Exception($"Out of bounds index on movable contents list: {index}"); + + + using (var childEnumerator = _movable.ChildEnumerator) { + while (index >= 1) { + var current = childEnumerator.MoveNext(out EntityUid child); + + if (index == 1) { + if (AtomManager.TryGetMovableFromEntity(child, out var childObject)) + return new DreamValue(childObject); + else + throw new Exception($"Invalid child in movable contents list: {child}"); + } + + index--; + } + } + + throw new Exception($"Out of bounds index on movable contents list after iterating: {key}"); + } + + public override List GetValues() { + List values = []; + + using (var childEnumerator = _movable.ChildEnumerator) { + while (childEnumerator.MoveNext(out EntityUid child)) { + if (!AtomManager.TryGetMovableFromEntity(child, out var childObject)) + continue; + + values.Add(new DreamValue(childObject)); + } + } + + return values; + } + + public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth = false) { + throw new Exception("Cannot set an index of movable contents list"); + } + + public override void AddValue(DreamValue value) { + if (!value.TryGetValueAsDreamObject(out var movable)) + throw new Exception($"Cannot add {value} to movable contents"); + + movable.SetVariable("loc", new (_movable)); + } + + public override void RemoveValue(DreamValue value) { + if (!value.TryGetValueAsDreamObject(out var movable)) + throw new Exception($"Cannot remove {value} from movable contents"); + + movable.SetVariable("loc", DreamValue.Null); + } + + public override bool ContainsValue(DreamValue value) { + if (!value.TryGetValueAsDreamObject(out var movable)) + return false; + + if (!movable.TryGetVariable("loc", out var _locVariable)) + return false; + + if (!_locVariable.TryGetValueAsDreamObject(out var _loc)) + return false; + + return _loc == _movable; + } + + public override void Cut(int start = 1, int end = 0) { + // TODO + } + + public override int GetLength() { + return _movable.ChildCount; + } +} + // proc args list sealed class ProcArgsList : DreamList { private readonly DMProcState _state; diff --git a/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs b/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs index 9b38720942..dceae7995a 100644 --- a/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs +++ b/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs @@ -1,4 +1,4 @@ -using OpenDreamRuntime.Procs; +using OpenDreamRuntime.Procs; using OpenDreamRuntime.Rendering; using OpenDreamShared.Dream; using Robust.Shared.Map; @@ -19,6 +19,10 @@ public class DreamObjectMovable : DreamObjectAtom { private readonly TransformComponent _transformComponent; + public readonly MovableContentsList Contents; + + public TransformChildrenEnumerator ChildEnumerator => _transformComponent.ChildEnumerator; + public int ChildCount => _transformComponent.ChildCount; private string? ScreenLoc { get => _screenLoc; @@ -39,6 +43,8 @@ public DreamObjectMovable(DreamObjectDefinition objectDefinition) : base(objectD Entity = AtomManager.CreateMovableEntity(this); SpriteComponent = EntityManager.GetComponent(Entity); _transformComponent = EntityManager.GetComponent(Entity); + + Contents = new MovableContentsList(ObjectTree.List.ObjectDefinition, this); } public override void Initialize(DreamProcArguments args) { @@ -87,18 +93,7 @@ protected override bool TryGetVar(string varName, out DreamValue value) { value = (ScreenLoc != null) ? new(ScreenLoc) : DreamValue.Null; return true; case "contents": - DreamList contents = ObjectTree.CreateList(); - - using (var childEnumerator = _transformComponent.ChildEnumerator) { - while (childEnumerator.MoveNext(out EntityUid child)) { - if (!AtomManager.TryGetMovableFromEntity(child, out var childAtom)) - continue; - - contents.AddValue(new DreamValue(childAtom)); - } - } - - value = new(contents); + value = new(Contents); return true; case "locs": // Unimplemented; just return a list containing src.loc diff --git a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs index 405491c8f5..c468c7414f 100644 --- a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs +++ b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs @@ -1,4 +1,4 @@ -using System.Buffers; +using System.Buffers; using OpenDreamRuntime.Objects; using OpenDreamRuntime.Resources; using OpenDreamShared.Dream; @@ -3023,6 +3023,14 @@ public static DreamValue NativeProc_view(NativeProc.Bundle bundle, DreamObject? if (center is null) return new(view); + if (center.TryGetVariable("contents", out var centerContents) && centerContents.TryGetValueAsDreamList(out var centerContentsList)) { + foreach (var content in centerContentsList.GetValues()) { + view.AddValue(content); + } + } + + // Center gets included during the walk through the tiles + var eyePos = bundle.AtomManager.GetAtomPosition(center); var viewData = DreamProcNativeHelpers.CollectViewData(bundle.AtomManager, bundle.MapManager, eyePos, range); diff --git a/TestGame/code.dm b/TestGame/code.dm index 42c94dda80..67cd018e65 100644 --- a/TestGame/code.dm +++ b/TestGame/code.dm @@ -12,18 +12,26 @@ /obj/plane_master appearance_flags = PLANE_MASTER - + /obj/plane_master/turf screen_loc = "1,1" plane = TURF_PLANE New() - src.filters = filter(type="displace", size=100, icon=icon('icons/displace.dmi',"lense")) + src.filters = filter(type="displace", size=100, icon=icon('icons/displace.dmi',"lense")) /mob/verb/examine(atom/thing as obj|mob in world) set category = null usr << "This is [thing]. [thing.desc]" +/mob/verb/poke(mob/someone as obj|mob in world) + set category = null + usr << "You poke [someone]!" + for(var/x in view(someone, 0)) + usr << "They see: [x]" + for(var/obj/item/item in someone) + usr << "They have: [item]" + /turf icon = 'icons/turf.dmi' icon_state = "turf" @@ -45,9 +53,32 @@ icon = null else icon = 'icons/objects.dmi' - spawn(20) + spawn(20) toggleBlink() +/obj/item/bandoleer + icon = 'icons/objects.dmi' + icon_state = "bandoleer" + layer = OBJ_LAYER + + name = "Bandoleer" + desc = "Stylish and comes with a gun!" + + New() + ..() + contents += new /obj/item/gun + +/obj/item/gun + icon = 'icons/objects.dmi' + icon_state = "gun" + layer = OBJ_LAYER + + name = "Testing Gun" + desc = "Non-functional, but it takes up space" + + New() + ..() + /mob icon = 'icons/mob.dmi' icon_state = "mob" @@ -61,6 +92,11 @@ New() ..() + contents += new /obj/item/bandoleer + var/obj/item/gun = new /obj/item/gun + gun.name = "Testing Gun Outer" // Keep it distinct + contents += gun + loc = locate(5, 5, 1) Login() @@ -118,12 +154,12 @@ set name = "Walk North" usr << "Walking north. Use the 'Walk Stop' verb to cease." walk(src, NORTH) - + verb/start_walk_rand() set name = "Walk Randomly" usr << "Walking randomly. Use the 'Walk Stop' verb to cease." walk_rand(src) - + verb/stop_walk() set name = "Walk Stop" usr << "Walking stopped." @@ -210,7 +246,7 @@ if("drop_shadow") src.filters = filter(type="drop_shadow", size=2) if("displace") - src.client.screen += new /obj/plane_master/turf + src.client.screen += new /obj/plane_master/turf usr << "Applied [selected] filter" verb/toggle_see_invisibility() @@ -225,7 +261,7 @@ var/image/i = image(icon = 'icons/hanoi.dmi', icon_state="8") i.loc = src i.override = 1 - + src.client.images += i usr << "override added" for(var/turf/T in range(src, 2)) @@ -243,10 +279,10 @@ spawn(20) src << "showing main window" winset(src,"mainwindow","is-visible=true") - + verb/winget_text_verb(var/rawtext as command_text) set name = "wingettextverb" - world << "recieved: [rawtext]" + world << "recieved: [rawtext]" verb/test_hot_reload_interface() set category = "Test" From a2516c865dcee894c04cf3e36627b27a7e6c5a13 Mon Sep 17 00:00:00 2001 From: Saphire Date: Mon, 21 Oct 2024 15:01:44 +0600 Subject: [PATCH 2/4] Fix review issues --- OpenDreamRuntime/Objects/Types/DreamList.cs | 10 +++++++++- OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs | 4 +--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 7344a9e0c7..00471217b4 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -142,6 +142,14 @@ public virtual void AddValue(DreamValue value) { _values.Add(value); } + public virtual void AddValueRange(DreamList valueRange) { + _values.AddRange(valueRange.GetValues()); + } + + public virtual void AddValueRange(IEnumerable valueRange) { + _values.AddRange(valueRange); + } + //Does not include associations public virtual bool ContainsValue(DreamValue value) { for (int i = 0; i < _values.Count; i++) { @@ -1294,7 +1302,7 @@ public override DreamValue GetValue(DreamValue key) { } public override List GetValues() { - List values = []; + List values = new List(_movable.ChildCount); using (var childEnumerator = _movable.ChildEnumerator) { while (childEnumerator.MoveNext(out EntityUid child)) { diff --git a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs index c468c7414f..3e69cdc96d 100644 --- a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs +++ b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs @@ -3024,9 +3024,7 @@ public static DreamValue NativeProc_view(NativeProc.Bundle bundle, DreamObject? return new(view); if (center.TryGetVariable("contents", out var centerContents) && centerContents.TryGetValueAsDreamList(out var centerContentsList)) { - foreach (var content in centerContentsList.GetValues()) { - view.AddValue(content); - } + view.AddValueRange(centerContentsList); } // Center gets included during the walk through the tiles From ddfbb0803aa7548e9cc42644533175ce7f76222d Mon Sep 17 00:00:00 2001 From: wixoaGit Date: Thu, 16 Jan 2025 22:49:03 -0500 Subject: [PATCH 3/4] Lints --- OpenDreamRuntime/Objects/Types/DreamList.cs | 58 +++++++++------------ 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 0dbb82a149..630adecca7 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -1265,45 +1265,39 @@ public override int GetLength() { } // mob.contents, obj.contents list -public sealed class MovableContentsList(DreamObjectDefinition listDef, DreamObjectMovable movable) : DreamList(listDef, 0) { - private readonly DreamObjectMovable _movable = movable; +public sealed class MovableContentsList(DreamObjectDefinition listDef, DreamObjectMovable owner) : DreamList(listDef, 0) { public override DreamValue GetValue(DreamValue key) { if (!key.TryGetValueAsInteger(out var index)) throw new Exception($"Invalid index into movable contents list: {key}"); - - - if (index < 1 || index > _movable.ChildCount) + if (index < 1 || index > owner.ChildCount) throw new Exception($"Out of bounds index on movable contents list: {index}"); + using var childEnumerator = owner.ChildEnumerator; + while (index >= 1) { + childEnumerator.MoveNext(out EntityUid child); - using (var childEnumerator = _movable.ChildEnumerator) { - while (index >= 1) { - var current = childEnumerator.MoveNext(out EntityUid child); - - if (index == 1) { - if (AtomManager.TryGetMovableFromEntity(child, out var childObject)) - return new DreamValue(childObject); - else - throw new Exception($"Invalid child in movable contents list: {child}"); - } - - index--; + if (index == 1) { + if (AtomManager.TryGetMovableFromEntity(child, out var childObject)) + return new DreamValue(childObject); + else + throw new Exception($"Invalid child in movable contents list: {child}"); } + + index--; } throw new Exception($"Out of bounds index on movable contents list after iterating: {key}"); } public override List GetValues() { - List values = new List(_movable.ChildCount); + List values = new List(owner.ChildCount); + using var childEnumerator = owner.ChildEnumerator; - using (var childEnumerator = _movable.ChildEnumerator) { - while (childEnumerator.MoveNext(out EntityUid child)) { - if (!AtomManager.TryGetMovableFromEntity(child, out var childObject)) - continue; + while (childEnumerator.MoveNext(out EntityUid child)) { + if (!AtomManager.TryGetMovableFromEntity(child, out var childObject)) + continue; - values.Add(new DreamValue(childObject)); - } + values.Add(new DreamValue(childObject)); } return values; @@ -1314,10 +1308,10 @@ public override void SetValue(DreamValue key, DreamValue value, bool allowGrowth } public override void AddValue(DreamValue value) { - if (!value.TryGetValueAsDreamObject(out var movable)) + if (!value.TryGetValueAsDreamObject(out var dreamObject)) throw new Exception($"Cannot add {value} to movable contents"); - movable.SetVariable("loc", new (_movable)); + dreamObject.SetVariable("loc", new (owner)); } public override void RemoveValue(DreamValue value) { @@ -1328,16 +1322,14 @@ public override void RemoveValue(DreamValue value) { } public override bool ContainsValue(DreamValue value) { - if (!value.TryGetValueAsDreamObject(out var movable)) + if (!value.TryGetValueAsDreamObject(out var dreamObject)) return false; - - if (!movable.TryGetVariable("loc", out var _locVariable)) + if (!dreamObject.TryGetVariable("loc", out var locVariable)) return false; - - if (!_locVariable.TryGetValueAsDreamObject(out var _loc)) + if (!locVariable.TryGetValueAsDreamObject(out var loc)) return false; - return _loc == _movable; + return loc == owner; } public override void Cut(int start = 1, int end = 0) { @@ -1345,7 +1337,7 @@ public override void Cut(int start = 1, int end = 0) { } public override int GetLength() { - return _movable.ChildCount; + return owner.ChildCount; } } From e0fcf02fe14fe009bcf66e652d323ab135f2a700 Mon Sep 17 00:00:00 2001 From: wixoaGit Date: Thu, 16 Jan 2025 23:03:27 -0500 Subject: [PATCH 4/4] Review --- OpenDreamRuntime/Objects/Types/DreamList.cs | 57 ++++++------------- .../Objects/Types/DreamObjectMovable.cs | 17 ++---- .../Procs/Native/DreamProcNativeRoot.cs | 6 +- TestGame/code.dm | 36 ------------ 4 files changed, 28 insertions(+), 88 deletions(-) diff --git a/OpenDreamRuntime/Objects/Types/DreamList.cs b/OpenDreamRuntime/Objects/Types/DreamList.cs index 630adecca7..dc5897c0c6 100644 --- a/OpenDreamRuntime/Objects/Types/DreamList.cs +++ b/OpenDreamRuntime/Objects/Types/DreamList.cs @@ -142,14 +142,6 @@ public virtual void AddValue(DreamValue value) { _values.Add(value); } - public virtual void AddValueRange(DreamList valueRange) { - _values.AddRange(valueRange.GetValues()); - } - - public virtual void AddValueRange(IEnumerable valueRange) { - _values.AddRange(valueRange); - } - //Does not include associations public virtual bool ContainsValue(DreamValue value) { for (int i = 0; i < _values.Count; i++) { @@ -984,20 +976,10 @@ private ImmutableAppearance GetAppearance() { } // client.screen list -public sealed class ClientScreenList : DreamList { - private readonly DreamObjectTree _objectTree; - private readonly ServerScreenOverlaySystem? _screenOverlaySystem; - - private readonly DreamConnection _connection; +public sealed class ClientScreenList(DreamObjectTree objectTree, ServerScreenOverlaySystem? screenOverlaySystem, DreamConnection connection) + : DreamList(objectTree.List.ObjectDefinition, 0) { private readonly List _screenObjects = new(); - public ClientScreenList(DreamObjectTree objectTree, ServerScreenOverlaySystem? screenOverlaySystem, DreamConnection connection) : base(objectTree.List.ObjectDefinition, 0) { - _objectTree = objectTree; - _screenOverlaySystem = screenOverlaySystem; - - _connection = connection; - } - public override bool ContainsValue(DreamValue value) { return _screenObjects.Contains(value); } @@ -1021,7 +1003,7 @@ public override void AddValue(DreamValue value) { if (!value.TryGetValueAsDreamObject(out var movable)) return; - _screenOverlaySystem?.AddScreenObject(_connection, movable); + screenOverlaySystem?.AddScreenObject(connection, movable); _screenObjects.Add(value); } @@ -1029,7 +1011,7 @@ public override void RemoveValue(DreamValue value) { if (!value.TryGetValueAsDreamObject(out var movable)) return; - _screenOverlaySystem?.RemoveScreenObject(_connection, movable); + screenOverlaySystem?.RemoveScreenObject(connection, movable); _screenObjects.Remove(value); } @@ -1040,7 +1022,7 @@ public override void Cut(int start = 1, int end = 0) { if (!_screenObjects[i].TryGetValueAsDreamObject(out var movable)) continue; - _screenOverlaySystem?.RemoveScreenObject(_connection, movable); + screenOverlaySystem?.RemoveScreenObject(connection, movable); } _screenObjects.RemoveRange(start - 1, end - start); @@ -1051,7 +1033,6 @@ public override int GetLength() { } } - // client.images list public sealed class ClientImagesList : DreamList { private readonly ServerClientImagesSystem? _clientImagesSystem; @@ -1178,7 +1159,7 @@ public override void AddValue(DreamValue value) { if (!value.TryGetValueAsDreamObject(out var movable)) throw new Exception($"Cannot add {value} to turf contents"); - movable.SetVariable("loc", new(Cell.Turf)); + movable.SetLoc(Cell.Turf); } public override void Cut(int start = 1, int end = 0) { @@ -1186,7 +1167,7 @@ public override void Cut(int start = 1, int end = 0) { if (end == 0 || end > movableCount) end = movableCount; for (int i = start; i < end; i++) { - Cell.Movables[i - 1].SetVariable("loc", DreamValue.Null); + Cell.Movables[i - 1].SetLoc(null); } } @@ -1265,14 +1246,14 @@ public override int GetLength() { } // mob.contents, obj.contents list -public sealed class MovableContentsList(DreamObjectDefinition listDef, DreamObjectMovable owner) : DreamList(listDef, 0) { +public sealed class MovableContentsList(DreamObjectDefinition listDef, DreamObjectMovable owner, TransformComponent transform) : DreamList(listDef, 0) { public override DreamValue GetValue(DreamValue key) { if (!key.TryGetValueAsInteger(out var index)) throw new Exception($"Invalid index into movable contents list: {key}"); - if (index < 1 || index > owner.ChildCount) + if (index < 1 || index > transform.ChildCount) throw new Exception($"Out of bounds index on movable contents list: {index}"); - using var childEnumerator = owner.ChildEnumerator; + using var childEnumerator = transform.ChildEnumerator; while (index >= 1) { childEnumerator.MoveNext(out EntityUid child); @@ -1290,8 +1271,8 @@ public override DreamValue GetValue(DreamValue key) { } public override List GetValues() { - List values = new List(owner.ChildCount); - using var childEnumerator = owner.ChildEnumerator; + List values = new List(transform.ChildCount); + using var childEnumerator = transform.ChildEnumerator; while (childEnumerator.MoveNext(out EntityUid child)) { if (!AtomManager.TryGetMovableFromEntity(child, out var childObject)) @@ -1311,25 +1292,23 @@ public override void AddValue(DreamValue value) { if (!value.TryGetValueAsDreamObject(out var dreamObject)) throw new Exception($"Cannot add {value} to movable contents"); - dreamObject.SetVariable("loc", new (owner)); + dreamObject.SetLoc(owner); } public override void RemoveValue(DreamValue value) { if (!value.TryGetValueAsDreamObject(out var movable)) throw new Exception($"Cannot remove {value} from movable contents"); + if (movable.Loc != owner) + return; // This object wasn't in our contents to begin with - movable.SetVariable("loc", DreamValue.Null); + movable.SetLoc(null); } public override bool ContainsValue(DreamValue value) { if (!value.TryGetValueAsDreamObject(out var dreamObject)) return false; - if (!dreamObject.TryGetVariable("loc", out var locVariable)) - return false; - if (!locVariable.TryGetValueAsDreamObject(out var loc)) - return false; - return loc == owner; + return dreamObject.Loc == owner; } public override void Cut(int start = 1, int end = 0) { @@ -1337,7 +1316,7 @@ public override void Cut(int start = 1, int end = 0) { } public override int GetLength() { - return owner.ChildCount; + return transform.ChildCount; } } diff --git a/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs b/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs index d2e9f35b91..b012437857 100644 --- a/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs +++ b/OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs @@ -18,26 +18,21 @@ public class DreamObjectMovable : DreamObjectAtom { public int Z => (int)_transformComponent.MapID; private readonly TransformComponent _transformComponent; - - public readonly MovableContentsList Contents; - - public TransformChildrenEnumerator ChildEnumerator => _transformComponent.ChildEnumerator; - public int ChildCount => _transformComponent.ChildCount; + private readonly MovableContentsList _contents; + private string? _screenLoc; private string? ScreenLoc { get => _screenLoc; set => SetScreenLoc(value); } - private string? _screenLoc; - public DreamObjectMovable(DreamObjectDefinition objectDefinition) : base(objectDefinition) { Entity = AtomManager.CreateMovableEntity(this); SpriteComponent = EntityManager.GetComponent(Entity); AtomManager.SetSpriteAppearance((Entity, SpriteComponent), AtomManager.GetAppearanceFromDefinition(ObjectDefinition)); - _transformComponent = EntityManager.GetComponent(Entity); - Contents = new MovableContentsList(ObjectTree.List.ObjectDefinition, this); + _transformComponent = EntityManager.GetComponent(Entity); + _contents = new MovableContentsList(ObjectTree.List.ObjectDefinition, this, _transformComponent); } public override void Initialize(DreamProcArguments args) { @@ -86,7 +81,7 @@ protected override bool TryGetVar(string varName, out DreamValue value) { value = (ScreenLoc != null) ? new(ScreenLoc) : DreamValue.Null; return true; case "contents": - value = new(Contents); + value = new(_contents); return true; case "locs": // Unimplemented; just return a list containing src.loc @@ -145,7 +140,7 @@ protected override void SetVar(string varName, DreamValue value) { } } - private void SetLoc(DreamObjectAtom? loc) { + public void SetLoc(DreamObjectAtom? loc) { Loc = loc; if (TransformSystem == null) return; diff --git a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs index 67220ef5e4..d2b7688c35 100644 --- a/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs +++ b/OpenDreamRuntime/Procs/Native/DreamProcNativeRoot.cs @@ -156,7 +156,7 @@ public static DreamValue NativeProc_animate(NativeProc.Bundle bundle, DreamObjec return DreamValue.Null; chainAnim = true; } - + bundle.LastAnimatedObject = new DreamValue(obj); if(obj.IsSubtypeOf(bundle.ObjectTree.Filter)) {//TODO animate filters return DreamValue.Null; @@ -3025,7 +3025,9 @@ public static DreamValue NativeProc_view(NativeProc.Bundle bundle, DreamObject? return new(view); if (center.TryGetVariable("contents", out var centerContents) && centerContents.TryGetValueAsDreamList(out var centerContentsList)) { - view.AddValueRange(centerContentsList); + foreach (var item in centerContentsList.GetValues()) { + view.AddValue(item); + } } // Center gets included during the walk through the tiles diff --git a/TestGame/code.dm b/TestGame/code.dm index 0a490ca16a..c756394932 100644 --- a/TestGame/code.dm +++ b/TestGame/code.dm @@ -24,14 +24,6 @@ set category = null usr << "This is [thing]. [thing.desc]" -/mob/verb/poke(mob/someone as obj|mob in world) - set category = null - usr << "You poke [someone]!" - for(var/x in view(someone, 0)) - usr << "They see: [x]" - for(var/obj/item/item in someone) - usr << "They have: [item]" - /mob/verb/possess_key(mob/someone as mob in world) set category = null someone.ckey = usr.key @@ -60,29 +52,6 @@ spawn(20) toggleBlink() -/obj/item/bandoleer - icon = 'icons/objects.dmi' - icon_state = "bandoleer" - layer = OBJ_LAYER - - name = "Bandoleer" - desc = "Stylish and comes with a gun!" - - New() - ..() - contents += new /obj/item/gun - -/obj/item/gun - icon = 'icons/objects.dmi' - icon_state = "gun" - layer = OBJ_LAYER - - name = "Testing Gun" - desc = "Non-functional, but it takes up space" - - New() - ..() - /mob icon = 'icons/mob.dmi' icon_state = "mob" @@ -96,11 +65,6 @@ New() ..() - contents += new /obj/item/bandoleer - var/obj/item/gun = new /obj/item/gun - gun.name = "Testing Gun Outer" // Keep it distinct - contents += gun - loc = locate(5, 5, 1) Login()