示例#1
0
文件: Setup.cs 项目: darelc/ACViewer
        public Setup(uint setupID, FileTypes.ObjDesc objDesc, Dictionary <int, uint> customPaletteColors)
        {
            // make simple setup if gfxobj. These don't have
            if (setupID >> 24 == 0x1)
            {
                MakeSimpleSetup(setupID);
                BuildBoundingBox();
                return;
            }
            _setup = DatManager.PortalDat.ReadFromDat <SetupModel>(setupID);

            Parts = new List <GfxObj>();

            for (byte i = 0; i < _setup.Parts.Count; i++)
            {
                GfxObj gfxObj;

                if (objDesc.AnimPartChanges.TryGetValue(i, out var apChange))
                {
                    var gfxObjID = apChange.PartID;
                    gfxObj = new GfxObj(gfxObjID, false);

                    objDesc.TextureChanges.TryGetValue(i, out var tmChanges);

                    gfxObj.LoadTextures(tmChanges, customPaletteColors, false);

                    gfxObj.BuildPolygons();
                }
                else
                {
                    var gfxObjID = _setup.Parts[i];
                    gfxObj = new GfxObj(gfxObjID, false);

                    gfxObj.LoadTextures(null, customPaletteColors);

                    gfxObj.BuildPolygons();
                }

                Parts.Add(gfxObj);
            }

            PlacementFrames = new List <Matrix>();

            if (!_setup.PlacementFrames.TryGetValue((int)Placement.Resting, out var placementFrames))
            {
                _setup.PlacementFrames.TryGetValue((int)Placement.Default, out placementFrames);
            }

            foreach (var placementFrame in placementFrames.AnimFrame.Frames)
            {
                PlacementFrames.Add(placementFrame.ToXna());
            }

            BuildBoundingBox();
        }
示例#2
0
        public Setup(uint setupID, ObjDesc objDesc)
        {
            // make simple setup if gfxobj. These don't have
            if (setupID >> 24 == 0x1)
            {
                MakeSimpleSetup(setupID);
                BuildBoundingBox();
                return;
            }
            _setup = DatManager.PortalDat.ReadFromDat <SetupModel>(setupID);

            Parts = new List <GfxObj>();

            for (var i = 0; i < _setup.Parts.Count; i++)
            {
                GfxObj gfxObj;

                if (objDesc.PartChanges != null && objDesc.PartChanges.TryGetValue((uint)i, out var partChange))
                {
                    gfxObj = new GfxObj(partChange.NewGfxObjId, false);

                    gfxObj.LoadTextures(partChange.TextureChanges, objDesc.PaletteChanges);

                    gfxObj.BuildPolygons();
                }
                else
                {
                    var gfxObjID = _setup.Parts[i];
                    gfxObj = new GfxObj(gfxObjID, false);

                    gfxObj.LoadTextures(null, objDesc.PaletteChanges);

                    gfxObj.BuildPolygons();
                }

                Parts.Add(gfxObj);
            }

            PlacementFrames = new List <Matrix>();

            if (!_setup.PlacementFrames.TryGetValue((int)Placement.Resting, out var placementFrames))
            {
                _setup.PlacementFrames.TryGetValue((int)Placement.Default, out placementFrames);
            }

            foreach (var placementFrame in placementFrames.AnimFrame.Frames)
            {
                PlacementFrames.Add(placementFrame.ToXna());
            }

            BuildBoundingBox();
        }