Project

General

Profile

Download (4.49 KB) Statistics
| Branch: | Tag: | Revision:

magiccube / src / main / java / org / distorted / objects / RubikObject.java @ f12e4de9

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2021 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is free software: you can redistribute it and/or modify                            //
7
// it under the terms of the GNU General Public License as published by                          //
8
// the Free Software Foundation, either version 2 of the License, or                             //
9
// (at your option) any later version.                                                           //
10
//                                                                                               //
11
// Magic Cube is distributed in the hope that it will be useful,                                 //
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of                                //
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                 //
14
// GNU General Public License for more details.                                                  //
15
//                                                                                               //
16
// You should have received a copy of the GNU General Public License                             //
17
// along with Magic Cube.  If not, see <http://www.gnu.org/licenses/>.                           //
18
///////////////////////////////////////////////////////////////////////////////////////////////////
19

    
20
package org.distorted.objects;
21

    
22
import org.distorted.dmesh.ObjectMesh;
23
import org.distorted.jsons.ObjectJson;
24
import org.distorted.objectlib.main.ObjectType;
25
import org.distorted.patterns.RubikPatternList;
26

    
27
import static org.distorted.config.ConfigScreenPane.MESH_NICE;
28

    
29
///////////////////////////////////////////////////////////////////////////////////////////////////
30

    
31
public class RubikObject
32
{
33
  private static final int NUM = 4;
34

    
35
  private final String mName;
36
  private final int mNumScramble;
37
  private final int mOrdinal;
38
  private final int mJsonID, mMeshID;
39
  private final int[] mIconID;
40
  private final String[][] mPatterns;
41

    
42
  private int mMeshState;
43

    
44
///////////////////////////////////////////////////////////////////////////////////////////////////
45

    
46
  RubikObject(ObjectType type)
47
    {
48
    mIconID = new int[NUM];
49
    for(int i=0; i<NUM; i++) mIconID[i] = type.getIconID(i);
50

    
51
    mName        = type.name();
52
    mNumScramble = type.getNumScramble();
53
    mOrdinal     = type.ordinal();
54
    mJsonID      = ObjectJson.getJsonID(mOrdinal);
55
    mMeshID      = ObjectMesh.getMeshID(mOrdinal);
56

    
57
    int patternOrdinal  = RubikPatternList.getOrdinal(mOrdinal);
58
    mPatterns = RubikPatternList.getPatterns(patternOrdinal);
59

    
60
    mMeshState = MESH_NICE;
61
    }
62

    
63
///////////////////////////////////////////////////////////////////////////////////////////////////
64

    
65
  public void setMeshState(int state)
66
    {
67
    mMeshState = state;
68
    }
69

    
70
///////////////////////////////////////////////////////////////////////////////////////////////////
71

    
72
  public int getMeshState()
73
    {
74
    return mMeshState;
75
    }
76

    
77
///////////////////////////////////////////////////////////////////////////////////////////////////
78
// PUBLIC API
79

    
80
  public String getName()
81
    {
82
    return mName;
83
    }
84

    
85
///////////////////////////////////////////////////////////////////////////////////////////////////
86

    
87
  public int getIconID(int size)
88
    {
89
    return size>=0 && size<NUM ? mIconID[size] : 0;
90
    }
91

    
92
///////////////////////////////////////////////////////////////////////////////////////////////////
93

    
94
  public int getNumScramble()
95
    {
96
    return mNumScramble;
97
    }
98

    
99
///////////////////////////////////////////////////////////////////////////////////////////////////
100

    
101
  public int getOrdinal()
102
    {
103
    return mOrdinal;
104
    }
105

    
106
///////////////////////////////////////////////////////////////////////////////////////////////////
107

    
108
  public int getJsonID()
109
    {
110
    return mJsonID;
111
    }
112

    
113
///////////////////////////////////////////////////////////////////////////////////////////////////
114

    
115
  public int getMeshID()
116
    {
117
    return mMeshID;
118
    }
119

    
120
///////////////////////////////////////////////////////////////////////////////////////////////////
121

    
122
  public String[][] getPatterns()
123
    {
124
    return mPatterns;
125
    }
126
}
(1-1/2)