소스 검색

Prevent double onAdd script call for GameBase objs

Adds a check to skip this the first time onNewDataBlock is called (when the object is created) to prevent double-calling onAdd
AtomicWalrus 2 년 전
부모
커밋
4b678a3e3b
1개의 변경된 파일9개의 추가작업 그리고 4개의 파일을 삭제
  1. 9 4
      Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript

+ 9 - 4
Templates/BaseGame/game/core/utility/scripts/gameObjectManagement.tscript

@@ -80,10 +80,15 @@ function spawnGameObject(%name, %addToScene)
 
 function GameBaseData::onNewDataBlock(%this, %obj)
 {
-   if(%this.isMethod("onRemove"))
-      %this.onRemove(%obj);
-   if(%this.isMethod("onAdd"))
-      %this.onAdd(%obj);
+   if (%obj.firstDataCheck)
+   {
+      if(%this.isMethod("onRemove"))
+         %this.onRemove(%obj);
+      if(%this.isMethod("onAdd"))
+         %this.onAdd(%obj);
+   }
+   else
+      %obj.firstDataCheck = true;
 }
 
 function saveGameObject(%name, %tamlPath, %scriptPath)