@@ -260,12 +260,14 @@ std::shared_ptr<GameObject> GameObject::createFromString(std::string_view str)
260260
261261 ptr->groups .push_back (group);
262262
263- if (!GameLayer::instance->groups [group]->objects .contains (ptr->section ))
263+ GameLayer::instance->groups [group]->objects .push_back (ptr.get ());
264+
265+ if (!GameLayer::instance->groups [group]->objectsInSections .contains (ptr->section ))
264266 {
265267 std::unordered_map<int , GameObject*> map;
266- GameLayer::instance->groups [group]->objects .insert ({ptr->section , map});
268+ GameLayer::instance->groups [group]->objectsInSections .insert ({ptr->section , map});
267269 }
268- GameLayer::instance->groups [group]->objects [ptr->section ].insert (
270+ GameLayer::instance->groups [group]->objectsInSections [ptr->section ].insert (
269271 {static_cast <int >(ptr->uniqueID ), ptr.get ()});
270272 }
271273 break ;
@@ -309,6 +311,14 @@ std::shared_ptr<GameObject> GameObject::createFromString(std::string_view str)
309311 }
310312 }
311313
314+ if (ptr->isTrigger && effectPtr->spawnTriggered && ptr->groups .size () > 0 )
315+ {
316+ for (int i : ptr->groups )
317+ {
318+ GameLayer::instance->groups [i]->spawnTriggered .push_back (effectPtr.get ());
319+ }
320+ }
321+
312322 if (objectEntry.contains (" color_type" ))
313323 {
314324 if (objectEntry[" color_type" ] == " Base" || objectEntry.contains (" swap_base_detail" ) &&
@@ -339,7 +349,6 @@ std::shared_ptr<GameObject> GameObject::createFromString(std::string_view str)
339349 ptr->setupCustomObjects (objectEntry, ptr);
340350
341351 ptr->startPosition = ptr->getPosition ();
342- ptr->startRotation = ptr->getRotation ();
343352
344353 return ptr;
345354}
@@ -353,56 +362,21 @@ void GameObject::updateOpacity()
353362 opacityMultiplier *= GameLayer::instance->groups [i]->groupOpacity ;
354363 }
355364
356- setOpacity (opacity);
365+ setOpacityWithoutSend (opacity);
357366
358367 for (std::shared_ptr<Sprite>& sprite : childSprites)
359368 {
360369 sprite->opacityMultiplier = opacityMultiplier;
361- sprite->setOpacity (sprite->opacity );
370+ sprite->setOpacityWithoutSend (sprite->opacity );
362371 }
363372}
364373
365- void GameObject::updatePosition ()
374+ void GameObject::updatePosition (bool send )
366375{
367- if (groups.size () <= 0 )
368- return ;
369-
370- sf::Vector2f move = {0 , 0 };
371- float rotate = 0 ;
372- for (int i : groups)
373- {
374- move += GameLayer::instance->groups [i]->moveTotal ;
375- }
376-
377- sf::Vector2f newPosition = startPosition + rotateOffsetMovement;
378-
379- for (int i : groups)
380- {
381- std::shared_ptr<Group> group = GameLayer::instance->groups [i];
382- rotate += group->rotateTotal ;
383-
384- if (group->rotateAround )
385- {
386- sf::Vector2f rotationPoint = group->rotateAround ->getPosition ();
387- float rotationAngle = group->rotateTotalMovement ;
388-
389- sf::Transform transform;
390- transform.rotate (rotationAngle, rotationPoint);
391-
392- // newPosition += group->rotateAround->getPosition() - group->rotateAround->startPosition;
393- newPosition = transform.transformPoint (newPosition);
394- }
395- }
396-
397- rotate += rotateOffset;
398-
399- setPosition (newPosition + move);
400- setRotation (startRotation + rotate);
401-
402- this ->updateVerticesPosition ();
376+ this ->updateVerticesPosition (send);
403377
404378 for (std::shared_ptr<Sprite> child : childSprites)
405- child->updateVerticesPosition ();
379+ child->updateVerticesPosition (send );
406380}
407381
408382void GameObject::tryUpdateSection ()
@@ -416,9 +390,7 @@ void GameObject::tryUpdateSection()
416390 {
417391 removeFromChannel ();
418392 for (auto & spr : childSprites)
419- {
420393 spr->removeFromChannel ();
421- }
422394
423395 auto &thisSectionMap = GameLayer::instance->sectionObjects [this ->section ];
424396
@@ -433,24 +405,21 @@ void GameObject::tryUpdateSection()
433405 }
434406 GameLayer::instance->sectionObjects [section].insert ({this ->uniqueID , this });
435407
436- /* if (GameLayer::instance->dirtySections.find(section) == GameLayer::instance->dirtySections.end())
437- GameLayer::instance->dirtySections.insert(section); */
438-
439408 this ->section = section;
440409
441410 for (int i : groups)
442411 {
443412 std::shared_ptr<Group> group = GameLayer::instance->groups [i];
444- auto groupMap = &group->objects [oldSection];
413+ auto groupMap = &group->objectsInSections [oldSection];
445414
446415 groupMap->erase (uniqueID);
447416
448- if (!group->objects .contains (section))
417+ if (!group->objectsInSections .contains (section))
449418 {
450419 std::unordered_map<int , GameObject*> map;
451- group->objects .insert ({section, map});
420+ group->objectsInSections .insert ({section, map});
452421 }
453- group->objects [section].insert ({static_cast <int >(uniqueID), this });
422+ group->objectsInSections [section].insert ({static_cast <int >(uniqueID), this });
454423 }
455424
456425 removeFromBatcher ();
0 commit comments