Skip to content

Commit

Permalink
Fix new /turf(loc) not updating name and desc (OpenDreamProject#1559)
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit authored Dec 21, 2023
1 parent b6375da commit a3dcd59
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
7 changes: 0 additions & 7 deletions OpenDreamRuntime/AtomManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,6 @@ public EntityUid CreateMovableEntity(DreamObjectMovable movable) {
DMISpriteComponent sprite = _entityManager.AddComponent<DMISpriteComponent>(entity);
sprite.SetAppearance(GetAppearanceFromDefinition(movable.ObjectDefinition));

if (_entityManager.TryGetComponent(entity, out MetaDataComponent? metaData)) {
_metaDataSystem ??= _entitySystemManager.GetEntitySystem<MetaDataSystem>();

_metaDataSystem.SetEntityName(entity, movable.GetDisplayName(), metaData);
_metaDataSystem.SetEntityDescription(entity, movable.Desc ?? string.Empty, metaData);
}

_entityToAtom.Add(entity, movable);
return entity;
}
Expand Down
1 change: 1 addition & 0 deletions OpenDreamRuntime/Objects/DreamObjectTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void LoadJson(DreamCompiledJson json) {
_entitySystemManager.TryGetEntitySystem(out _appearanceSystem);
_entitySystemManager.TryGetEntitySystem(out _transformSystem);
_entitySystemManager.TryGetEntitySystem(out _pvsOverrideSystem);
_entitySystemManager.TryGetEntitySystem(out _metaDataSystem);

Strings = json.Strings ?? new();

Expand Down
11 changes: 7 additions & 4 deletions OpenDreamRuntime/Objects/Types/DreamObjectAtom.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OpenDreamShared.Dream;
using OpenDreamRuntime.Procs;
using OpenDreamShared.Dream;

namespace OpenDreamRuntime.Objects.Types;

Expand All @@ -14,9 +15,6 @@ public class DreamObjectAtom : DreamObject {
public DreamList? VisLocs; // TODO: Implement

public DreamObjectAtom(DreamObjectDefinition objectDefinition) : base(objectDefinition) {
ObjectDefinition.Variables["name"].TryGetValueAsString(out Name);
ObjectDefinition.Variables["desc"].TryGetValueAsString(out Desc);

Overlays = new(ObjectTree.List.ObjectDefinition, this, AppearanceSystem, false);
Underlays = new(ObjectTree.List.ObjectDefinition, this, AppearanceSystem, true);
VisContents = new(ObjectTree.List.ObjectDefinition, PvsOverrideSystem, this);
Expand All @@ -26,6 +24,11 @@ public DreamObjectAtom(DreamObjectDefinition objectDefinition) : base(objectDefi
AtomManager.AddAtom(this);
}

public override void Initialize(DreamProcArguments args) {
ObjectDefinition.Variables["name"].TryGetValueAsString(out Name);
ObjectDefinition.Variables["desc"].TryGetValueAsString(out Desc);
}

protected override void HandleDeletion() {
AtomManager.RemoveAtom(this);

Expand Down
12 changes: 8 additions & 4 deletions OpenDreamRuntime/Objects/Types/DreamObjectMovable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using OpenDreamRuntime.Rendering;
using OpenDreamShared.Dream;
using Robust.Shared.Map;
using Robust.Shared.Utility;

namespace OpenDreamRuntime.Objects.Types;

Expand Down Expand Up @@ -40,14 +39,19 @@ public DreamObjectMovable(DreamObjectDefinition objectDefinition) : base(objectD
Entity = AtomManager.CreateMovableEntity(this);
SpriteComponent = EntityManager.GetComponent<DMISpriteComponent>(Entity);
_transformComponent = EntityManager.GetComponent<TransformComponent>(Entity);

objectDefinition.Variables["screen_loc"].TryGetValueAsString(out var screenLoc);
ScreenLoc = screenLoc;
}

public override void Initialize(DreamProcArguments args) {
base.Initialize(args);

ObjectDefinition.Variables["screen_loc"].TryGetValueAsString(out var screenLoc);
ScreenLoc = screenLoc;

if (EntityManager.TryGetComponent(Entity, out MetaDataComponent? metaData)) {
MetaDataSystem?.SetEntityName(Entity, GetDisplayName(), metaData);
MetaDataSystem?.SetEntityDescription(Entity, Desc ?? string.Empty, metaData);
}

args.GetArgument(0).TryGetValueAsDreamObject<DreamObjectAtom>(out var loc);
SetLoc(loc); //loc is set before /New() is ever called
}
Expand Down

0 comments on commit a3dcd59

Please sign in to comment.