////////////////////////////////////////////////////////////////////////// // onAttach //virtual void GaRobotComponent::onAttach( ScnEntityWeakRef Parent ) { Super::onAttach( Parent ); StartPosition_ = Parent->getLocalPosition(); TargetPosition_ = Parent->getLocalPosition(); Canvas_ = Parent->getComponentAnyParentByType< ScnCanvasComponent >(); Material_ = Parent->getComponentAnyParent( "DefaultCanvasMaterial_0" ); View_ = ScnCore::pImpl()->findEntity( "CameraEntity_0" )->getComponentByType< ScnViewComponent >(); auto spawnPart = [ & ]( const BcName PartName ) { ScnEntitySpawnParams EntityParams = { "default", PartName, BcName( PartName.getValue(), getParentEntity()->getName().getID() ), MaMat4d(), getParentEntity() }; return ScnCore::pImpl()->spawnEntity( EntityParams ); }; Base_ = spawnPart( "RobotBase" ); Turret_ = spawnPart( "RobotTurret" ); MoveAngle_ = getName().getID() == 0 ? 0.0f : BcPI; }