Skip to content

Commit cf3645e

Browse files
committed
more leeway with archetype, better decision making if archetype unset
1 parent f19a719 commit cf3645e

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

game/addons/tools/Code/Scene/SceneView/DropObjects/ModelDropObject.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Threading;
1+
using Sandbox.ModelEditor.Nodes;
2+
using System.Threading;
23

34
namespace Editor;
45

@@ -55,6 +56,21 @@ public override void OnUpdate()
5556
}
5657
}
5758

59+
private bool HasPropData()
60+
{
61+
if ( archetype == "physics_prop_model" || archetype == "jointed_physics_model" || archetype == "breakable_prop_model" )
62+
return true;
63+
if ( model.Data.Explosive )
64+
return true;
65+
if ( model.Data.Flammable )
66+
return true;
67+
if ( model.Data.Health > 0 )
68+
return true;
69+
if ( model.HasData<ModelBreakPiece[]>() )
70+
return true;
71+
return false;
72+
}
73+
5874
public override async Task OnDrop()
5975
{
6076
await WaitForLoad();
@@ -70,12 +86,12 @@ public override async Task OnDrop()
7086
GameObject.Name = model.ResourceName;
7187
GameObject.WorldTransform = traceTransform;
7288

73-
bool isProp = (model.Physics?.Parts.Count ?? 0) > 0;
74-
if ( isProp )
89+
bool physics = (model.Physics?.Parts.Count ?? 0) > 0;
90+
if ( physics && HasPropData() )
7591
{
7692
var prop = GameObject.Components.Create<Prop>();
7793
prop.Model = model;
78-
prop.IsStatic = archetype == "static_prop_model";
94+
prop.IsStatic = archetype == "" || archetype == "default" || archetype == "static_prop_model" || archetype == "animated_model";
7995
}
8096
else if ( model.BoneCount > 0 )
8197
{
@@ -86,6 +102,11 @@ public override async Task OnDrop()
86102
{
87103
var renderer = GameObject.Components.Create<ModelRenderer>();
88104
renderer.Model = model;
105+
if ( physics )
106+
{
107+
var collider = GameObject.Components.Create<ModelCollider>();
108+
collider.Model = model;
109+
}
89110
}
90111

91112
GameObject.Enabled = true;

0 commit comments

Comments
 (0)