|
3 | 3 | using Sandbox.Game.Entities; |
4 | 4 | using Sandbox.Game.World; |
5 | 5 | using Sandbox.ModAPI; |
| 6 | +using System; |
6 | 7 | using System.Collections.Generic; |
7 | 8 | using VRage.Game; |
8 | 9 | using VRage.Game.Entity; |
@@ -52,20 +53,18 @@ public override void ProcessClient() |
52 | 53 | if (remove) |
53 | 54 | { |
54 | 55 | clear(uniqueName); |
55 | | - return; |
56 | 56 | } |
57 | 57 | else if (removeAll) |
58 | 58 | { |
59 | 59 | clearAll(); |
60 | | - return; |
61 | 60 | } |
62 | 61 |
|
63 | 62 | //MyAPIGateway.Utilities.ShowMessage("Torch", $"Hit process client on debug draw!"); |
64 | 63 |
|
65 | 64 | //If its the same unique name, we can add it |
66 | | - if (AllDraws.TryGetValue(uniqueName, out DrawDebug draw)) |
| 65 | + if(AllDraws.ContainsKey(uniqueName)) |
67 | 66 | { |
68 | | - draw.drawObjects.AddList(drawObjects); |
| 67 | + AllDraws[uniqueName].drawObjects.AddList(drawObjects); |
69 | 68 | } |
70 | 69 | else |
71 | 70 | { |
@@ -153,11 +152,17 @@ public void refreshDraw() |
153 | 152 | //static update to update all draws |
154 | 153 | public static void refreshAllDraws() |
155 | 154 | { |
156 | | - //MyRenderProxy.DebugClearPersistentMessages(); |
| 155 | + try |
| 156 | + { |
| 157 | + |
| 158 | + foreach (var draw in AllDraws) |
| 159 | + { |
| 160 | + draw.Value.refreshDraw(); |
| 161 | + } |
157 | 162 |
|
158 | | - foreach (var draw in AllDraws) |
| 163 | + }catch(Exception ex) |
159 | 164 | { |
160 | | - draw.Value.refreshDraw(); |
| 165 | + //do nothings |
161 | 166 | } |
162 | 167 | } |
163 | 168 |
|
@@ -198,6 +203,8 @@ public drawObject() { } |
198 | 203 | [ProtoMember(106)] |
199 | 204 | public Vector3D up; |
200 | 205 |
|
| 206 | + [ProtoMember(118)] |
| 207 | + public int wireDivideRatio = 0; |
201 | 208 |
|
202 | 209 | [ProtoMember(120)] |
203 | 210 | public float radius; |
@@ -244,35 +251,41 @@ public void drawOBB() |
244 | 251 | { |
245 | 252 | MatrixD worldMatrix = MatrixD.CreateWorld(position, forward, up); |
246 | 253 | var material = TorchModCore.id; |
247 | | - MySimpleObjectDraw.DrawTransparentBox(ref worldMatrix, ref box, ref color, raster, 1, linethickness, material, material); |
| 254 | + MySimpleObjectDraw.DrawTransparentBox(ref worldMatrix, ref box, ref color, raster, wireDivideRatio, linethickness, material, material, intensity: intensity); |
248 | 255 | } |
249 | 256 |
|
250 | 257 | public void drawSphere() |
251 | 258 | { |
252 | 259 | var material = TorchModCore.id; |
253 | 260 | var transform = MatrixD.CreateTranslation(position); |
254 | | - MySimpleObjectDraw.DrawTransparentSphere(ref transform, 10, ref color, raster, 25, material, material, -1); |
| 261 | + |
| 262 | + MySimpleObjectDraw.DrawTransparentSphere(ref transform, radius, ref color, raster, wireDivideRatio, material, material, linethickness, intensity: intensity); |
255 | 263 | } |
256 | 264 |
|
257 | 265 | public void drawOBBEntity() |
258 | 266 | { |
259 | 267 | //This will keep updating the draw for live grid box preview |
260 | | - //Do not keep searching for entity on draw |
261 | | - if (searchAttempts > 10) |
| 268 | + //Do not keep searching for entity on draw |
| 269 | + if (searchAttempts > 250 || entityID == 0) |
262 | 270 | return; |
263 | 271 |
|
264 | | - if (entRef == null && entityID != 0) |
| 272 | + |
| 273 | + |
| 274 | + |
| 275 | + |
| 276 | + entRef = MyEntities.GetEntityById(entityID); |
| 277 | + if (entRef == null ) |
265 | 278 | { |
266 | | - entRef = MyEntities.GetEntityById(entityID); |
267 | 279 | searchAttempts++; |
| 280 | + return; |
268 | 281 | } |
269 | 282 |
|
270 | 283 |
|
271 | 284 | var material = TorchModCore.id; |
272 | 285 | var Matrix = entRef.WorldMatrix; |
273 | 286 | BoundingBoxD myAabb = entRef.PositionComp.LocalAABB; |
274 | 287 |
|
275 | | - MySimpleObjectDraw.DrawTransparentBox(ref Matrix, ref myAabb, ref color, raster, 1, linethickness, material, material); |
| 288 | + MySimpleObjectDraw.DrawTransparentBox(ref Matrix, ref myAabb, ref color, raster, wireDivideRatio, linethickness, material, material); |
276 | 289 | } |
277 | 290 |
|
278 | 291 |
|
|
0 commit comments