Entity Prefabs - first iteration #2857
Replies: 8 comments 12 replies
-
This is so cool and going to be super useful testing iterating, and working on everything everything going forwards, thank you! All the scene related stuff is super useful also. Massive thanks to garry and the facepunch team for all this work in s&box, I very much appreciate it and love it all, its so cool and amazing and always gets me hyped and wanting to make stuff!. |
Beta Was this translation helpful? Give feedback.
-
Wow this is incredible. |
Beta Was this translation helpful? Give feedback.
-
Love it! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
edit: Just gonna add more things that I notice here while I work with prefabs. It'd be nice if we could adjust the scale of the root entity as well. |
Beta Was this translation helpful? Give feedback.
-
one thing i would suggest is a way to filter the select entity and select component prompts. being able to filter the entity list based off projects would be nice |
Beta Was this translation helpful? Give feedback.
-
@garrynewman what's the state of this API? Tried making a custom editor with EditorForAssetType attribute, the wiki says it's located in |
Beta Was this translation helpful? Give feedback.
-
Would be nice if some of the features that were planned for prefabs got finished up. It has been many months and they have been sitting to rot in their unfinished state. |
Beta Was this translation helpful? Give feedback.
-
Instead of spawning a raw entity in code and filling its attributes, adding components and children. we can have a "description" of an entity configuration to spawn. This can be copied, edited and updated outside of the game. This is an entity prefab.
This is the first iteration so I can find out what sucks nice and early. It should be safe enough to use right now and if the format changes I'll add upgraders so it'll retain backwards compatibility.
Example
2f67f1b7-cd1f-4108-9216-fd662d910b05.mp4
Eligibility
Entities, Components and their properties need to be marked with an attribute to show up in the editor.
Spawning
Right now the only way to spawn a prefab is from code. Hammer doesn't see these entities yet.
Future
I've got a list of things on the todo list for the future of this.
Side Changes
This was a couple of weeks so it brings along with it a bunch of loosely related changes..
EditorForAssetType attribute
This replaces
[CanEdit("asset:entity")]
. This has the advantage that this is only created when double clicking an asset. This means that the panel in the inspector is a different thing.CS Project Names
You can set the name of your addon's csproj file in project settings. This lets you give them nice names instead of whatever the addon is called.
Scene Tracing
You can trace against scene worlds now, to be able to pick objects inside.
BoneCollection
I created a new abstract class called BoneCollection and made Model.Bone return one, rather than trying to fumble around using GetBoneName etc. This provides a flat bone list and a heirachy (with bone.parent and bone.children).
SceneCamera.GetRay
Given a cursor position get a scene aiming ray
SceneObject.Model setter
Can change the model on SceneObjects instead of just being able to set it on creation. This needed a bunch of internal changes to wipe up all the old setup.
SceneSunLight works
Added ShadowCascadeCount, SetShadowCascadeResolution, SetShadowCascadeDistance and gave it sensible defaults that will work out of the box.
GameResource serialization, compilation
Entity Auto Flushing
I moved the logic code to call ExecuteQueuedCreation to c#. This means we can decide whether to call auto spawn at some point. This isn't exposed to addons at all.
Entity Constructor
I added an internal Entity.CreateByName where you can create an entity and configure it before Spawn is called.
This probably isn't much use right now, but it does mean that when spawning a prefab the model, children and components etc will all be setup before Spawn is called.
TypeDescription additions
HasAttribute
to take a bool (inherited)Added CaseInsensitiveDictionary
This dictionary is a regular dictionary with a string key, with StringComparer.OrdinalIgnoreCase set. This is useful when serializing to and from json, where you want to enforce this behaviour - which seems pretty common.
BBox.AddBBox
Add a bbox to a bbox, which will expand it.
Transform Scales
The transform class didn't really pay any attention to Scale when doing ToWorld and ToLocal. I made this work and added some tests around it.
SceneCamera.RenderToWidget removed
You can't render to just ANY widget now. I ran into a bunch of weird problems by doing this. You can now only render to a NativeRenderingWidget
Dragging
I simplified how dragging works, made it possible for dragging and dropping virtualWidgets from list widgets like ListView and TreeView.
DragData is now persistent and can hold an Object - which simplifies things a LOT when dragging internally.. but you obviously need to keep an eye on people dragging between windows.
FloatProperty
LineEdit had a horrible thing where when you clicked on it the precision would change. I removed that and increased the default precision to 3 places. I also made it so when dragging side to side the value changed even if the textentry has focus.
Max Shadow Cascades
MaxShadowCascades was set to 2. I increased that to 4.
UndoSystem
Added Sandbox.Helpers.UndoSystem, which gives a quick and dirty undo system. It's missing a few features that I'm sure people would like but it's a start.
Beta Was this translation helpful? Give feedback.
All reactions