public GVAppearanceType(FITFile spriteFile) : base(spriteFile) { if (!spriteFile.SeekSection("States")) { return; } if (!spriteFile.GetInt("NumStates", out numStates)) { return; } for (int i = 0; i < numStates; i++) { if (spriteFile.SeekSection("State" + i)) { var state = new GVActorData(); int stat; if (!spriteFile.GetInt("State", out stat)) { return; } state.state = (GVActorStates)stat; if (!spriteFile.GetInt("NumFrames", out state.numFrames)) { return; } if (!spriteFile.GetFloat("FrameRate", out state.frameRate)) { return; } if (!spriteFile.GetInt("BasePacketNumber", out state.basePacketNumber)) { return; } if (!spriteFile.GetInt("NumRotations", out state.numRotations)) { return; } state.shapeId = state.basePacketNumber; AppearStates.Add(state); } } }
public bool GetMapPreview(string Mapname, out Texture2D preview) { preview = new Texture2D(1, 1); if (!isReady || Mapname == "") { return(false); } var mapPreviewPath = Path.Combine(MapFitPath, Mapname + ".tga").ToUpper(); var fileData = MechCommanderUnity.Instance.FileManager.File(mapPreviewPath); if (fileData != null) { MechCommanderUnity.LogMessage("TGA file " + mapPreviewPath); preview = TGALoader.LoadTGA(new MemoryStream(fileData)); return(true); } else { var missionFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "missions", Mapname + ".fit" }))); missionFile.SeekSection("TerrainSystem"); missionFile.GetString("TerrainFileName", out string terrainFileName); mapPreviewPath = Path.Combine(MapFitPath, terrainFileName + ".tga").ToUpper(); fileData = MechCommanderUnity.Instance.FileManager.File(mapPreviewPath); if (fileData != null) { MechCommanderUnity.LogMessage("TGA file DIFFERENT NAME " + mapPreviewPath); preview = TGALoader.LoadTGA(new MemoryStream(fileData)); return(true); } } MechCommanderUnity.LogMessage("Can´t Find TGA file " + mapPreviewPath); return(false); }
public Terrain(string terrainFileName)//FITFile terrainFitFile) { terrainName = terrainFileName; string TerrainFileName = System.IO.Path.ChangeExtension(terrainFileName, "fit"); FITFile terrainFitFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "terrain", TerrainFileName }))); terrainFitFile.SeekSection("TerrainData"); terrainFitFile.GetInt("VerticesBlockSide", out this.verticesBlockSide); terrainFitFile.GetInt("BlocksMapSide", out this.blocksMapSide); terrainFitFile.GetFloat("MetersPerElevLevel", out this.MetersPerElevLevel); terrainFitFile.GetFloat("MetersPerVertex", out this.MetersPerVertex); terrainFitFile.GetInt("VisibleVerticesPerSide", out this.visibleVerticesPerSide); terrainFitFile.SeekSection("TileData"); string TerrainTileFile; terrainFitFile.GetString("TerrainTileFile", out TerrainTileFile); this.realVerticesMapSide = this.verticesBlockSide * this.blocksMapSide; this.halfVerticesMapSide = this.realVerticesMapSide / 2; this.worldUnitsMapSide = this.realVerticesMapSide * MetersPerVertex; this.numObjBlocks = this.blocksMapSide * this.blocksMapSide; this.numObjVertices = this.verticesBlockSide * this.verticesBlockSide; //Init TerrainTiles TerrainTiles = new TerrainTiles(terrainFileName, TerrainTileFile, (int)this.blocksMapSide, (int)this.verticesBlockSide); //Init MapBlockManager MapBlock = new MapBlockManager(terrainFileName, (int)this.blocksMapSide, (int)this.verticesBlockSide); //Init VertexManager //Init TerrainTileManager //Init ObjectManager ObjBlock = new ObjectBlockManager(terrainFileName); //Init TacticalMap }
public AppearanceType(FITFile spriteFile) { spriteFile.SeekSection("Main Info"); spriteFile.GetString("Name", out name); if (!spriteFile.GetInt("Delta", out delta)) { delta = 0; } if (spriteFile.SeekSection("Bounds")) { designerTypeBounds = true; spriteFile.GetInt("UpperLeftX", out boundsUpperLeftX); spriteFile.GetInt("UpperLeftY", out boundsUpperLeftY); spriteFile.GetInt("LowerRightX", out boundsLowerRightX); spriteFile.GetInt("LowerRightY", out boundsLowerRightY); } }
public ExplosionType(FITFile objFitFile) : base(objFitFile) { objectTypeClass = (int)ObjectTypeClass.EXPLOSION_TYPE; objectClass = ObjectClass.EXPLOSION; damageLevel = 0f; soundEffectId = -1; explosionRadius = 0; chunkSize = 0f; delayUntilCollidable = 0.5f; lightMinMaxRadius = 0.0f; lightMaxMaxRadius = 0.0f; lightOutMinRadius = 0.0f; lightOutMaxRadius = 0.0f; //lightRGB = 0x00000000; maxIntensity = 0.0f; minIntensity = 0.0f; duration = 0.0f; if (!objFitFile.SeekSection("ExplosionData")) { return; } objFitFile.GetFloat("DmgLevel", out damageLevel); if (!objFitFile.GetInt("SoundEffectId", out soundEffectId)) { return; } if (!objFitFile.GetInt("LightObjectId", out lightObjectId)) { lightObjectId = -1; } if (!objFitFile.GetInt("ExplosionRadius", out explosionRadius)) { explosionRadius = 0; } if (!objFitFile.GetFloat("DamageChunkSize", out chunkSize)) { chunkSize = 5f; } //TODO: objFitFile.SeekSection("LightData"); NOT EXISTS IN MCG?¿? }
public ObjectType(FITFile objFitFile) { objFitFile.SeekSection("ObjectType"); objFitFile.GetString("Name", out name); objFitFile.GetInt("Appearance", out appearName); objFitFile.GetInt("ExplosionObject", out int obj); ExplosionObject = obj; objFitFile.GetInt("DestroyedObject", out obj); DestroyedObject = obj; objFitFile.GetFloat("ExtentRadius", out extentRadius); keepMe = true; //Never cache out anymore! teamId = -1; //Everything starts out Neutral now. }
public BuildAppearanceType(FITFile spriteFile) : base(spriteFile) { spriteFile.SeekSection("Main Info"); spriteFile.GetInt("NumFrames", out numFrames); var state = new ActorData(); state.state = ActorStates.STATE_NORMAL; state.basePacketNumber = 0; state.numFrames = 1; state.numRotations = 1; state.frameRate = 1; state.symmetrical = 1; state.delta = 1; AppearStates.Add(state); state = new ActorData(); state.state = ActorStates.STATE_BLOWING_UP1; state.basePacketNumber = 0; state.numFrames = numFrames; state.numRotations = 1; state.frameRate = 15; state.symmetrical = 1; state.delta = 1; AppearStates.Add(state); state = new ActorData(); state.state = ActorStates.STATE_DESTROYED; state.basePacketNumber = 0; state.numFrames = 1; state.numRotations = 1; state.frameRate = 1; state.symmetrical = 1; state.delta = 1; AppearStates.Add(state); //0 To 11 is the building "Shadow" normal & destroyed }
public GateType(FITFile objFitFile) : base(objFitFile) { objectTypeClass = (int)ObjectTypeClass.GATE_TYPE; objectClass = ObjectClass.GATE; damageLevel = 0; blownEffectId = -1; normalEffectId = -1; damageEffectId = -1; explDmg = explRad = 0f; baseTonnage = 0f; gateTypeName = 0; if (!objFitFile.SeekSection("GateData")) { return; } objFitFile.GetFloat("DmgLevel", out damageLevel); if (!objFitFile.GetInt("BlownEffectId", out blownEffectId)) { blownEffectId = -1; } if (!objFitFile.GetInt("NormalEffectId", out normalEffectId)) { normalEffectId = -1; } if (!objFitFile.GetInt("DamageEffectId", out damageEffectId)) { damageEffectId = -1; } }
public TerrainObjectType(FITFile objFitFile) : base(objFitFile) { objectTypeClass = (int)ObjectTypeClass.TERRAINOBJECT_TYPE; objectClass = ObjectClass.TERRAINOBJECT; subType = (int)TerrainObjectSubType.TERROBJ_NONE; damageLevel = 0f; collisionOffsetX = 0; collisionOffsetY = 0; setImpassable = false; xImpasse = 0; yImpasse = 0; extentRadius = -1.0f; explDmg = 0.0f; explRad = 0.0f; fireTypeHandle = 0; if (!objFitFile.SeekSection("TerrainObjectData")) { if (!objFitFile.SeekSection("TreeData")) { return; } subType = (int)TerrainObjectSubType.TERROBJ_TREE; objectClass = ObjectClass.TREE; } objFitFile.GetFloat("DmgLevel", out damageLevel); if (!objFitFile.GetInt("CollisionOffsetX", out collisionOffsetX)) { collisionOffsetX = 0; } if (!objFitFile.GetInt("CollisionOffsetY", out collisionOffsetY)) { collisionOffsetY = 0; } int setImpass; objFitFile.GetInt("SetImpassable", out setImpass); setImpassable = setImpass == 1 ? true : false; if (!objFitFile.GetInt("XImpasse", out xImpasse)) { xImpasse = 0; } if (!objFitFile.GetInt("YImpasse", out yImpasse)) { yImpasse = 0; } float realExtent = 0f; if (!objFitFile.GetFloat("ExtentRadius", out realExtent)) { realExtent = -1f; } if (!objFitFile.GetFloat("ExplosionRadius", out explRad)) { explRad = 0f;// if this fails, explosion radius is not set and no splash damage. } if (!objFitFile.GetFloat("ExplosionDamage", out explDmg)) { explDmg = 0f; // if this fails, explosion damage is not set and no splash damage. } //------------------------------------------------------- // Initialize the base object Type from the current file. extentRadius = realExtent; }
public TurretType(FITFile objFitFile) : base(objFitFile) { objectTypeClass = (int)ObjectTypeClass.TURRET_TYPE; objectClass = ObjectClass.TURRET; damageLevel = 0f; blownEffectId = -1; normalEffectId = -1; damageEffectId = -1; explDmg = explRad = 0f; baseTonnage = 0f; weaponMasterId[0] = weaponMasterId[1] = weaponMasterId[2] = weaponMasterId[3] = -1; pilotSkill = 0; punch = 0f; turretYawRate = 0f; turretTypeName = 0; blocksLineOfFire = false; lowTemplate = 0; highTemplate = 0; if (!objFitFile.SeekSection("TurretData")) { return; } objFitFile.GetBool("BlocksLineOfFire", out blocksLineOfFire); objFitFile.GetFloat("DmgLevel", out damageLevel); if (!objFitFile.GetInt("BlownEffectId", out blownEffectId)) { blownEffectId = -1; } if (!objFitFile.GetInt("NormalEffectId", out normalEffectId)) { normalEffectId = -1; } if (!objFitFile.GetInt("DamageEffectId", out damageEffectId)) { damageEffectId = -1; } objFitFile.GetInt("LowTemplate", out lowTemplate); objFitFile.GetInt("HighTemplate", out highTemplate); if (!objFitFile.GetFloat("ExplosionRadius", out explRad)) { explRad = 0f;// if this fails, explosion radius is not set and no splash damage. } if (!objFitFile.GetFloat("ExplosionDamage", out explDmg)) { explDmg = 0f; // if this fails, explosion damage is not set and no splash damage. } if (!objFitFile.GetFloat("Tonnage", out baseTonnage)) { baseTonnage = 20f; } if (!objFitFile.GetFloat("AttackRadius", out engageRadius)) { return; } if (!objFitFile.GetFloat("MaxTurretYawRate", out turretYawRate)) { return; } if (!objFitFile.GetInt("WeaponType", out weaponMasterId[0])) { return; } //SPOTLIGHTS!!!! if (weaponMasterId[0] != -1) { punch = 99999f;//TODO: MASTERCOMPONENTLIST MasterComponent::masterList[weaponMasterId[0]].getCV(); } else { punch = 0.0f; } if (!objFitFile.GetInt("WeaponType1", out weaponMasterId[1])) { weaponMasterId[1] = -1; } else { punch += 99999f;//TODO: MasterComponent::masterList[weaponMasterId[1]].getCV(); } if (!objFitFile.GetInt("WeaponType2", out weaponMasterId[2])) { weaponMasterId[2] = -1; } else { punch += 99999f;//TODO: MasterComponent::masterList[weaponMasterId[2]].getCV(); } if (!objFitFile.GetInt("WeaponType3", out weaponMasterId[3])) { weaponMasterId[3] = -1; } else { punch += 99999f;//TODO: MasterComponent::masterList[weaponMasterId[3]].getCV(); } if (!objFitFile.GetInt("PilotSkill", out pilotSkill)) { return; } if (!objFitFile.GetInt("BuildingName", out turretTypeName)) { turretTypeName = 30164;// IDS_TRTOBJ_NAME; } }
public BuildingType(FITFile objFitFile) : base(objFitFile) { objectTypeClass = (int)ObjectTypeClass.BUILDING_TYPE; //any reason to record TREEBUILDING_TYPE? objectClass = ObjectClass.BUILDING; damageLevel = 0f; sensorRange = -1f; teamId = -1; explDmg = explRad = 0f; baseTonnage = 0f; buildingTypeName = 0; buildingDescriptionID = -1; startBR = 0; numMarines = 0; canRefit = false; mechBay = false; blocksLineOfFire = false; lowTemplate = 0; highTemplate = 0; if (!objFitFile.SeekSection("TreeData") || !objFitFile.SeekSection("BuildingData")) { return; } //objFitFile.SeekSection("BuildingData"); objFitFile.GetFloat("DmgLevel", out damageLevel); objFitFile.GetBool("CanRefit", out canRefit); if (canRefit) { objFitFile.GetBool("MechBay", out mechBay); } objFitFile.GetBool("BlocksLineOfFire", out blocksLineOfFire); objFitFile.GetInt("LowTemplate", out lowTemplate); objFitFile.GetInt("HighTemplate", out highTemplate); if (!objFitFile.GetFloat("ExplosionRadius", out explRad)) { explRad = 0f;// if this fails, explosion radius is not set and no splash damage. } if (!objFitFile.GetFloat("ExplosionDamage", out explDmg)) { explDmg = 0f; // if this fails, explosion damage is not set and no splash damage. } if (!objFitFile.GetFloat("Tonnage", out baseTonnage)) { baseTonnage = 20f; } if (!objFitFile.GetInt("BattleRating", out startBR)) { startBR = 20; } if (!objFitFile.GetInt("NumMarines", out numMarines)) { numMarines = 0; } float realExtent = 0f; if (!objFitFile.GetFloat("ExtentRadius", out realExtent)) { realExtent = -1f; } //---------------------------- // Init sensor-related data... if (!objFitFile.GetInt("TeamID", out teamId)) { teamId = -1; } if (!objFitFile.GetFloat("SensorRange", out sensorRange)) { sensorRange = -1f; } int buildingNameInt = 30163; if (!objFitFile.GetInt("BuildingName", out buildingNameInt)) { buildingNameInt = 30163; } buildingName = buildingNameInt.ToString(); if (!objFitFile.GetInt("BattleRating", out resourcePoints)) { resourcePoints = -1; } if (!objFitFile.GetInt("BasePixelOffsetX", out basePixelOffsetX)) { basePixelOffsetX = 0; } if (!objFitFile.GetInt("BasePixelOffsetY", out basePixelOffsetY)) { basePixelOffsetY = 0; } if (!objFitFile.GetInt("CollisionOffsetX", out collisionOffsetX)) { collisionOffsetX = 0; } if (!objFitFile.GetInt("CollisionOffsetY", out collisionOffsetY)) { collisionOffsetY = 0; } objFitFile.GetInt("HighTemplate", out highTemplate); objFitFile.GetInt("LowTemplate", out lowTemplate); // impassability = (highTemplate << 32) | lowTemplate; //------------------------------------------------------- // Initialize the base object Type from the current file. extentRadius = realExtent; }
public VFXAppearanceType(FITFile spriteFile) : base(spriteFile) { if (!spriteFile.SeekSection("States")) { return; } if (!spriteFile.GetInt("NumStates", out numStates)) { return; } if (!spriteFile.GetInt("Scaled", out scaled)) { scaled = 0; } int ScaledOffset = scaled == 1 ? -1 : 0; for (int i = 0; i < numStates; i++) { if (spriteFile.SeekSection("State" + i)) { if (!spriteFile.GetInt("SubStates", out subStates)) { subStates = 0; } var state = new ActorData(); if (!spriteFile.GetInt("State", out var stat)) { return; } state.state = (ActorStates)stat; if (!spriteFile.GetInt("NumFrames", out state.numFrames)) { return; } if (!spriteFile.GetFloat("FrameRate", out state.frameRate)) { return; } if (!spriteFile.GetInt("BasePacketNumber", out state.basePacketNumber)) { return; } if (!spriteFile.GetInt("NumRotations", out state.numRotations)) { return; } if (!spriteFile.GetInt("Symmetrical", out state.symmetrical)) { return; } if (!spriteFile.GetInt("Loop", out int loop)) { loop = 0; } //delta ==1 First is Shadow?¿ && state.numFrames>1 && loop==1 state.delta = (delta == 1 && state.numFrames > 1) ? 1: 0; // state.numFrames += state.delta; state.shapeId = (state.basePacketNumber + ((1 + ScaledOffset) * 1)); AppearStates.Add(state); //Do something with the state data int numFrames, basePacketNumber; float frameRate; int numRotations, symmetrical; for (int j = 0; j < subStates; j++) { treeBuilding = true; if (spriteFile.SeekSection("Sub" + j + "State" + i)) { if (!spriteFile.GetInt("NumFrames", out numFrames)) { return; } if (!spriteFile.GetFloat("FrameRate", out frameRate)) { return; } if (!spriteFile.GetInt("BasePacketNumber", out basePacketNumber)) { return; } if (!spriteFile.GetInt("NumRotations", out numRotations)) { return; } if (!spriteFile.GetInt("Symmetrical", out symmetrical)) { return; } if (!spriteFile.GetInt("Loop", out loop)) { return; } //Do something with the substate data } } } } }
//public float* fireOffsetX; //public float* fireOffsetY; //public float* fireDelay; //public long* fireRandomOffsetX; //public long* fireRandomOffsetY; //public long* fireRandomDelay; #endregion #region Class Structures #endregion #region Constructors public FireType(FITFile objFitFile) : base(objFitFile) { objectTypeClass = (int)ObjectTypeClass.FIRE_TYPE; objectClass = ObjectClass.FIRE; damageLevel = 0f; soundEffectId = -1; maxExtentRadius = 0f; timeToMaxExtent = 0f; totalFireShapes = 1; //fireOffsetX = NULL; //fireOffsetY = NULL; //fireDelay = NULL; //fireRandomOffsetX = NULL; //fireRandomOffsetY = NULL; //fireRandomDelay = NULL; if (!objFitFile.SeekSection("FireData")) { return; } objFitFile.GetFloat("DmgLevel", out damageLevel); if (!objFitFile.GetInt("SoundEffectId", out soundEffectId)) { return; } if (!objFitFile.GetInt("LightObjectId", out lightObjectId)) { lightObjectId = -1; } if (!objFitFile.GetInt("startLoopFrame", out startLoopFrame)) { return; } if (!objFitFile.GetInt("numLoops", out numLoops)) { return; } if (!objFitFile.GetInt("endLoopFrame", out endLoopFrame)) { return; } if (!objFitFile.GetFloat("maxExtentRadius", out maxExtentRadius)) { maxExtentRadius = 0f; } if (!objFitFile.GetFloat("TimeToMaxExtent", out timeToMaxExtent)) { timeToMaxExtent = 20f; } if (!objFitFile.GetInt("TotalFireShapes", out totalFireShapes)) { totalFireShapes = 1; } }
public void Init(string missionName, MissionLoadType loadType) //public Mission(string missionName, MissionLoadType loadType) { this.Init(); float loadProgress = 0f; MechCommanderUnity.LogMessage("Loading Mission: " + missionName); var auxStr = ""; //LoadType mission SP (quick or logistic) and MP //define team relations loadProgress = 4.0f; //-------------------------- // Load Game System stuff... //Define General Game Settings var generalFitFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "missions", "gamesys.fit" }))); if (generalFitFile.SectionNumber == 0) { MechCommanderUnity.LogMessage("Error Loading General FitFile :" + MCGExtensions.PathCombine(new string[] { MechCommanderUnity.Instance.MCGPath, "missions", "gamesys.fit" })); return; } //---------------------------------------------------------------------- // Now that we have some base values, load the master component table... //--------------------------------------- // Read in difficulty here if it exits. //InitDifficultySettings(gameSystemFile); //--------------------------------------- // Read Mission File missionFileName = Path.ChangeExtension(missionName, "fit"); //Read Mission Fit File missionFile = new FITFile(MechCommanderUnity.Instance.FileManager.File(MCGExtensions.PathCombine(new string[] { "missions", missionFileName }))); if (missionFile.SectionNumber == 0) { MechCommanderUnity.LogMessage("Error Loading Mission FitFile :" + MCGExtensions.PathCombine(new string[] { MechCommanderUnity.Instance.MCGPath, "missions", missionFileName })); } //----------------------------------------- // Begin Setting up Teams and Commanders... loadProgress = 10.0f; //NULL ANY TEAMS & COMMANDERS //------------------------------------------------------------ // First, let's see how many teams and commanders there are... long maxTeamID = -1; long maxCommanderID = -1; if (loadType == MissionLoadType.MISSION_LOAD_MP_LOGISTICS) { //MP TEAMS & COMMANDERS } else { missionFile.SeekSection("Parts"); int numParts; missionFile.GetInt("NumParts", out numParts); if (numParts > 0) { for (int i = 1; i < (long)numParts + 1; i++) { //SP TEAMS & COMMANDERS //------------------------------------------------------------------ // Find the object to load missionFile.SeekSection("Part" + i); int teamID = -1; missionFile.GetInt("TeamId", out teamID); int commanderID = -1; if (missionFile.GetInt("CommanderId", out commanderID)) { int cID; missionFile.GetInt("CommanderId", out cID); commanderID = (sbyte)cID; } //if (MPlayer && dropZoneList) //{ // //------------------------------------------------------------- // // Since dropZoneList is not NULL, we know this was not started // // from the command-line... // long origCommanderID = commanderID; // commanderID = commandersToLoad[origCommanderID][0]; // teamID = commandersToLoad[origCommanderID][1]; //} if (commanderID > maxCommanderID) { maxCommanderID = commanderID; } if (teamID > maxTeamID) { maxTeamID = teamID; } } } } missionFile.SeekSection("PaletteSystem"); missionFile.GetString("PaletteSystem", out string paletteName); ContentReader.PaletteXpansion = paletteName == "palettex"; //---------------------------------------------- // Now, init the teams and commanders we need... //INIT TEAMS & COMMANDERS //----------------------------- // Init Trigger Area Manager... //----------------------------------- // Setup the Sensor System Manager... //INIT SENSOR MANAGER //INITIAL DROPZONE FROM missionFIle missionFile.SeekSection("DropZone0"); missionFile.GetFloat("PositionX", out dropZone.x); missionFile.GetFloat("PositionY", out dropZone.y); //----------------------------------------------------------------- // Load the names of the scenario tunes. missionFile.SeekSection("Music"); missionFile.GetInt("scenarioTuneNum", out missionTuneNum); //auxStr = ""; //missionFile.getKeyValueBySection("Music", "scenarioTuneNum", out auxStr); //missionTuneNum=int.Parse(auxStr); //INIT CRATER MANAGER!!?¿? //result = craterManager->init(1000,20479,"feet"); // MechCommanderUnity.LogMessage("Starting ObjectManager"); //----------------------------------------------------------------- // Start the object system next. ObjectManager = GameObjectManager.Instance; // MechCommanderUnity.LogMessage("Finished ObjectManager"); //----------------------------------------------------------------- // Start the collision detection system. -- Doesn't need objects? //------------------------------------------------------------ // Start the Terrain System missionFile.SeekSection("TerrainSystem"); string terrainFileName; missionFile.GetString("TerrainFileName", out terrainFileName);//System.IO.Path.ChangeExtension(missionName, "fit"); //Read Terrain Fit File //INIT TERRAIN FILE // MechCommanderUnity.LogMessage("Starting Terrain"); Terrain = new Terrain(terrainFileName); var Map = new GameObject(); this.MapGO = Map; // MechCommanderUnity.LogMessage("Finished Terrain"); loadProgress = 15.0f; //INIT TERRAIN GENERATION // MechCommanderUnity.LogMessage("Starting TerrainTiles"); StartCoroutine(Terrain.InitTerrainTiles(GenerateMapIsoMeshes)); // MechCommanderUnity.LogMessage("Finished TerrainTiles"); //long terrainInitResult = land->init(&pakFile, 0, GameVisibleVertices, loadProgress, 20.0 ); loadProgress = 35.0f; // land->load(missionFile); loadProgress = 36.0f; //---------------------------------------------------- // Start GameMap for Movement System // PathManager = new MovePathManager; loadProgress = 40.0f; //---------------------- // Load ABL Libraries... //--------------------------- // Load the mission script... //----------------------------------------------------------------- // We now read in the mission Script File Name loadProgress = 41.0f; //------------------------------------------- // Load all MechWarriors for this mission... //Get Num Warrior from missionFile //foreach warrior //------------------------- // Find the warrior to load //-------------------------------------- // Load the mechwarrior into the mech... //---------------------------- // Read in the Brain module... //------------------------------------------------------------ // For now, all mplayer brains are pbrain. Need to change when // we allow ai brains in mplayer... //--------------------------------------------------------------- // Load the brain parameter file and load 'em for each warrior... loadProgress = 43.0f; //----------------------------------------------------------------- // All systems are GO if we reach this point. Now we need to // parse the scenario file for the Objects we need for this scenario // We then create each object and place it in the world at the // position we read in with the frame we read in. //-------------------------------------------------------------------------------- // IMPORTANT NOTE: mission parts should always start with Part 1. // Part 0 is reserved as a "NULL" id for routines that reference the mission // parts. AI routines, Brain keywords, etc. use PART ID 0 as an "object not found" // error code. DO NOT USE PART 0!!!!!!! Start with Part 1... loadProgress = 43.5f; //READ SPECIAL PARTS & LOAD THEM loadProgress = 48.5f; //-------------------------------------------------------------------------- // Now that the parts data has been loaded, let's prep the ObjectManager for // the real things. First, count the number of objects we need... long numMechs = 0; long numVehicles = 0; //foreach part load in Objectmanager calculate total nummechs & vehicles loadProgress = 55.0f; //pakFile.seekPacket(1); //ObjectManager->countTerrainObjects(&pakFile, (numMechs + MAX_TEAMS * MAX_REINFORCEMENTS_PER_TEAM) + (numVehicles + MAX_TEAMS * MAX_REINFORCEMENTS_PER_TEAM)/* + ObjectManager->maxElementals*/ + 1); loadProgress = 58.0f; //ObjectManager->setNumObjects(numMechs, numVehicles, 0, -1, -1, -1, 100, 50, 0, 130, -1); //------------------------- // Load the mech objects... loadProgress = 68.0f; // ObjectManager->loadTerrainObjects(&pakFile, loadProgress, 30); ObjectManager.terrain = Terrain; StartCoroutine(ObjectManager.LoadTerrainObjects(Terrain.ObjBlock.objDataBlock, GenerateMapObj)); //Terrain.InitTerrainObjects(); loadProgress = 98.0f; //---------------------------------------------- // Read in the Mission Time Limit. //---------------------------------------------- // Read in the Objectives. Safe to have none. //---------------------------- // Read in Commander Groups... //----------------------------------------------------------------------- // Now that the parts are loaded, let's build the roster for each team... //--------------------------------------------------------------------------------- // If we're not playing multiplayer, make sure all home commander movers have their // localMoverId set to 0, so the iface can at least check if a mover is player // controlled... //----------------------------------------------------- // This tracks time since scenario started in seconds. //---------------------------- // Create and load the Weather //--------------------------------------------------------------- // Start the Camera and Lists //---------------------------------------------------------------------------- // Start the Mission GUI //-------------------------------------------------- // Close all walls and open gates and landbridges... // MechCommanderUnity.LogMessage(loadProgress.ToString()); }
public ObjectType Load(int objTypeNum, bool noCacheOut = true, bool forceLoad = false) { if (ObjectTypeList.ContainsKey(objTypeNum)) { return(ObjectTypeList[objTypeNum]); } int objectTypeNum = -1; var objFitData = objPakFile.GetFileInner(objTypeNum); if (objFitData == null) { return(null); } var objFitFile = new FITFile(objFitData); objFitFile.SeekSection("ObjectClass"); objFitFile.GetInt("ObjectTypeNum", out objectTypeNum); ObjectType objType = new ObjectType(objectTypeNum); switch ((ObjectTypeClass)objectTypeNum) { case ObjectTypeClass.CRAPPY_OBJECT: //---------------------------------------------- // In theory we can't ever get here. // Because we did our jobs correctly!! throw new Exception(); break; case ObjectTypeClass.BATTLEMECH_TYPE: { //objType = new ObjectType(objFitFile); //objType.init(objFitFile); //objType = new BattleMechType; //objType->setObjTypeNum(objTypeNum); ////if ((objType->init(objectFile,objectFile->getPacketSize()) != NO_ERR) && (objType->init(tmp1) != NO_ERR)) //if ((objType->init(objectFile, objectFile->getPacketSize(), tmp1) != NO_ERR))// && (objType->init(tmp1) != NO_ERR)) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Mech type "); } break; case ObjectTypeClass.VEHICLE_TYPE: { //objType = new GroundVehicleType; //objType->setObjTypeNum(objTypeNum); //if ((objType->init(objectFile, objectFile->getPacketSize(), tmp1) != NO_ERR))// && (objType->init(tmp1,3) != NO_ERR)) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Vehicle type "); } break; case ObjectTypeClass.TREEBUILDING_TYPE: case ObjectTypeClass.BUILDING_TYPE: { objType = new BuildingType(objFitFile); //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize(), tmp1) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Building type "); } break; case ObjectTypeClass.TREE_TYPE: { objType = new TerrainObjectType(objFitFile); //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize()) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init TerrainObject:Tree type "); } break; case ObjectTypeClass.TERRAINOBJECT_TYPE: { objType = new TerrainObjectType(objFitFile); //objType->setObjTypeNum(objTypeNum); //if (isMiscTerrObj) // ((TerrainObjectTypePtr)objType)->initMiscTerrObj(objTypeNum); //else if (objType->init(objectFile, objectFile->getPacketSize()) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init TerrainObject type "); } break; case ObjectTypeClass.WEAPONBOLT_TYPE: { //objType = new WeaponBoltType; //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize()) != NO_ERR) //Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init WeaponBolt type "); } break; case ObjectTypeClass.TURRET_TYPE: { objType = new TurretType(objFitFile); //objType = new TurretType; //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize(), tmp1) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Turret type "); } break; case ObjectTypeClass.EXPLOSION_TYPE: { objType = new ExplosionType(objFitFile); //objType = new ExplosionType; //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize()) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Explosion type "); } break; case ObjectTypeClass.FIRE_TYPE: { objType = new FireType(objFitFile); //objType = new FireType; //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize()) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Fire type "); } break; case ObjectTypeClass.GATE_TYPE: { objType = new GateType(objFitFile); //objType = new GateType; //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize(), tmp1) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Gate type "); } break; case ObjectTypeClass.ARTILLERY_TYPE: { } break; case ObjectTypeClass.MINE_TYPE: { objType = new ObjectType(objFitFile); objType.objectClass = ObjectClass.MINE; //objType = new ArtilleryType; //objType->setObjTypeNum(objTypeNum); //if (objType->init(objectFile, objectFile->getPacketSize()) != NO_ERR) // Fatal(objectTypeNum, " ObjectTypeManager.load: unable to init Artillery type "); } break; default: return(null); } if (noCacheOut) { objType.NoCacheOut(); if (objType.ExplosionObject > 0) { Load((int)objType.ExplosionObject, false); } } ObjectTypeList.Add(objTypeNum, objType); return(objType); }