@@ -20,6 +20,8 @@ export class SS6Player extends Container {
2020 private prevCellID : number [ ] = [ ] ; // 各パーツ(レイヤー)で前回使用したセルID
2121 private prevPartObject : ( SS6Player | Mesh | Container ) [ ] = [ ] ;
2222 private changeCellID : number [ ] = [ ] ;
23+ private changeVisible : boolean [ ] = [ ] ;
24+ private changeTint : number [ ] = [ ] ;
2325
2426 // for change instance
2527 private substituteOverWrite : boolean [ ] = [ ] ;
@@ -128,6 +130,8 @@ export class SS6Player extends Container {
128130 this . prevCellID = new Array ( partsLength ) ;
129131 this . prevPartObject = new Array ( partsLength ) ;
130132 this . changeCellID = new Array ( partsLength ) ;
133+ this . changeVisible = new Array ( partsLength ) ;
134+ this . changeTint = new Array ( partsLength ) ;
131135 this . substituteOverWrite = new Array ( partsLength ) ;
132136 this . substituteKeyParam = new Array ( partsLength ) ;
133137
@@ -138,6 +142,8 @@ export class SS6Player extends Container {
138142 this . prevCellID [ index ] = - 1 ; // 初期値(最初は必ず設定が必要)
139143 this . prevPartObject [ index ] = null ;
140144 this . changeCellID [ index ] = - 1 ;
145+ this . changeVisible [ index ] = true ;
146+ this . changeTint [ index ] = null ;
141147 this . substituteOverWrite [ index ] = null ;
142148 this . substituteKeyParam [ index ] = null ;
143149 }
@@ -457,7 +463,13 @@ export class SS6Player extends Container {
457463 return changeCellIndex ;
458464 }
459465
460- private getPartIndexFromName ( partsname : string ) : number {
466+ /**
467+ * Retrieves the index of a part based on its name from the anime pack data.
468+ *
469+ * @param {string } partsname - The name of the part to search for.
470+ * @return {number } The index of the part if found, or -1 if the part is not found.
471+ */
472+ public GetPartIndexFromName ( partsname : string ) : number {
461473 const animePackData : AnimePackData = this . playerLib . animePackData ;
462474 const partsLength = animePackData . partsLength ( ) ;
463475
@@ -482,16 +494,92 @@ export class SS6Player extends Container {
482494 * @param {string } sscename - セルマップ名
483495 * @param {string } cellname - 表示させたいセル名
484496 *
485- * @return {void }
497+ * @return {[number, number] } [パーツ名の index, セル名 index] のタプルを返します。見つからない場合は -1 を返します。
486498 */
487- public SetPartCell ( partsname : string , sscename : string , cellname : string ) : void {
499+ public SetPartCell ( partsname : string , sscename : string , cellname : string ) : [ number , number ] {
500+ let changeCellIndex = - 1 ;
501+ let partIndex = - 1
488502 if ( this . playerLib . animationData ) {
489- const changeCellIndex : number = this . getCellIndex ( sscename , cellname ) ;
490- const partIndex = this . getPartIndexFromName ( partsname ) ;
491- if ( partIndex !== - 1 ) {
492- this . changeCellID [ partIndex ] = changeCellIndex ;
493- }
503+ changeCellIndex = this . getCellIndex ( sscename , cellname ) ;
504+ partIndex = this . GetPartIndexFromName ( partsname ) ;
505+ this . SetPartCellByIndex ( partIndex , changeCellIndex ) ;
506+ }
507+ return [ partIndex , changeCellIndex ] ;
508+ }
509+
510+ /**
511+ * パーツに割り当たるセルをインデックスで指定して変更します。
512+ *
513+ * @param {number } partIndex - The index of the part to be updated. Must not be -1 to perform the update.
514+ * @param {number } changeCellIndex - The new cell index to set for the specified partIndex.
515+ * @return {void } This method does not return a value.
516+ */
517+ public SetPartCellByIndex ( partIndex : number , changeCellIndex : number ) : boolean {
518+ if ( partIndex !== - 1 ) {
519+ this . changeCellID [ partIndex ] = changeCellIndex ;
520+ return true ;
521+ }
522+ return false ;
523+ }
524+
525+ /**
526+ * Sets the visibility of a specific part by its name.
527+ *
528+ * @param {string } partsname - The name of the part whose visibility is to be set.
529+ * @param {boolean } visible - A boolean indicating whether the part should be visible (true) or hidden (false).
530+ * @return {boolean } Returns true if the operation was successful, false otherwise.
531+ */
532+ public SetPartVisible ( partsname : string , visible : boolean ) : boolean {
533+ if ( this . playerLib . animationData ) {
534+ const partIndex = this . GetPartIndexFromName ( partsname ) ;
535+ return this . SetPartVisibleByIndex ( partIndex , visible ) ;
536+ }
537+ return false ;
538+ }
539+
540+ /**
541+ * Sets the visibility of a part identified by its index.
542+ *
543+ * @param {number } partIndex - The index of the part to update. Must not be -1.
544+ * @param {boolean } visible - A boolean indicating whether the part should be visible (true) or hidden (false).
545+ * @return {boolean } Returns true if the visibility was successfully updated, otherwise returns false.
546+ */
547+ public SetPartVisibleByIndex ( partIndex : number , visible : boolean ) : boolean {
548+ if ( partIndex !== - 1 ) {
549+ this . changeVisible [ partIndex ] = visible ;
550+ return true ;
494551 }
552+ return false ;
553+ }
554+
555+ /**
556+ * Sets the tint color for a specific part of the player's animation.
557+ *
558+ * @param {string } partName - The name of the part to apply the tint to.
559+ * @param {number } tint - The tint value to apply, represented as a number.
560+ * @return {boolean } Returns true if the tint was successfully applied; otherwise, returns false.
561+ */
562+ public SetPartTint ( partName : string , tint : number ) : boolean {
563+ if ( this . playerLib . animationData ) {
564+ const partIndex = this . GetPartIndexFromName ( partName ) ;
565+ return this . SetPartTintByIndex ( partIndex , tint ) ;
566+ }
567+ return false ;
568+ }
569+
570+ /**
571+ * Updates the tint color of a specific part identified by its index.
572+ *
573+ * @param {number } partIndex - The index of the part for which the tint needs to be set. A value of -1 indicates no part is targeted.
574+ * @param {number } tint - The tint value to be applied to the specified part.
575+ * @return {boolean } Returns true if the tint is successfully applied, otherwise returns false.
576+ */
577+ public SetPartTintByIndex ( partIndex : number , tint : number ) : boolean {
578+ if ( partIndex !== - 1 ) {
579+ this . changeTint [ partIndex ] = tint ;
580+ return true ;
581+ }
582+ return false ;
495583 }
496584
497585 /**
@@ -614,6 +702,10 @@ export class SS6Player extends Container {
614702 // 優先度に変換
615703 const i = this . playerLib . prio2index [ ii ] ;
616704
705+ if ( ! this . changeVisible [ i ] ) {
706+ continue ;
707+ }
708+
617709 const data = fd [ i ] ;
618710 const origCellID = data . cellIndex ;
619711 const cellID = ( this . changeCellID [ i ] !== - 1 ) ? this . changeCellID [ i ] : origCellID ;
@@ -943,7 +1035,9 @@ export class SS6Player extends Container {
9431035 }
9441036
9451037 // 小西 - tintデータがあれば適用
946- if ( data . tint ) {
1038+ if ( this . changeTint [ i ] !== null ) {
1039+ mesh . tint = this . changeTint [ i ] ;
1040+ } else if ( data . tint ) {
9471041 mesh . tint = data . tint ;
9481042 // パーツカラーのAを不透明度に乗算して処理する
9491043 const ca = ( ( data . partsColorARGB & 0xff000000 ) >>> 24 ) / 255 ;
0 commit comments