Skip to content

Commit

Permalink
performance: remove props if they have no modules left
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyOThan committed Aug 15, 2024
1 parent 91071da commit 7c714fa
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions RasterPropMonitor/Auxiliary modules/PropBatcher.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using JetBrains.Annotations;
using TMPro;
using UnityEngine;

Expand Down Expand Up @@ -180,6 +175,20 @@ public override void OnLoad(ConfigNode node)
}
}

// if the prop doesn't have any modules left (or never had any to start),
// just attach it to the internal model and remove the prop so we can avoid calling update etc.
if (keepProp && oldProp.internalModules.Count == 0)
{
var modelTransform = oldProp.transform.Find("model");
if (modelTransform != null)
{
modelTransform.SetParent(internalModel.transform.Find("model"), true);
}

JUtil.LogMessage(null, "PROP_BATCH: removing prop {0} because it has no modules left", oldProp.propName);
keepProp = false;
}

if (keepProp)
{
oldProp.propID = newProps.Count;
Expand Down

0 comments on commit 7c714fa

Please sign in to comment.