summaryrefslogtreecommitdiff
path: root/src/T2DLL/T2PeopleAnimeDef.cpp
blob: 19044895cb805310d714d5c4954651fbebb610e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "StdAfx.h"
#include "CResFile.h"
#include "T2People.h"
#include "T2PeopleAnimeDef.h"
#include "T2PeopleAnimeDefElem.h"
#include "UT2Utils.h"

T2PeopleAnimeDef::T2PeopleAnimeDef(CResFile& resFile) {
    Init();

    resFile >> m4;
    resFile >> m8;
    resFile >> mNumOfElems;

    mElems = new T2PeopleAnimeDefElem[mNumOfElems];
    for (int i = 0; i < mNumOfElems; i++)
        mElems[i].Initialize(resFile);
}

void T2PeopleAnimeDef::Init() {
    m4 = 0;
    m8 = 0;
    mNumOfElems = 0;
    mElems = NULL;
}

/*virtual*/ T2PeopleAnimeDef::~T2PeopleAnimeDef() {
    if (mElems)
        delete[] mElems;
}

void T2PeopleAnimeDef::Set(T2People* people, int h, int inIndex) {
    if (inIndex < mNumOfElems) {
        int index = inIndex;
        if (inIndex < 0)
            index = UT2Utils::Randomize(mNumOfElems);
        mElems[index].Set(people, h);
    }
}