internal Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, WorldLighting lighting, int randomSeed, bool isDiagnosticScene = false) : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null) { _players = new List <Player>(); TeamFactory = new TeamFactory(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); WaterAreas = AddDisposable(new WaterAreaCollection()); Lighting = lighting; Roads = AddDisposable(new RoadCollection()); Bridges = Array.Empty <Bridge>(); Waypoints = new WaypointCollection(); Cameras = new CameraCollection(); CameraController = cameraController; }
private void CreateCustomRedTeam(Table table, string key) { var factory = new TeamFactory(); var redTeam = factory.CreateTeam("rouge"); redTeam.RemoveAll(); var nbEmploye = table.Rows.Count; var employes = table.Rows; for (int i = 0; i < nbEmploye; i++) { var name = employes[i][0]; if (redTeam.employes.Exists(e => e.Name == name)) { throw new ArgumentException($"{name} already exist."); } var currentPlace = employes[i][1]; Place place; if (Enum.TryParse(currentPlace, out place)) { redTeam.employes.Add(new Employe(name, place)); } else { throw new ArgumentException($"{currentPlace} doesn't exist"); } } ScenarioContext.Current.Set(redTeam, key); }
//private void Init() //{ // List<AndonAlertEntity> andon = AndonFactory.GetByTime(); // for (int i = 0; i < andon.Count; i++) // { // if (GridAndon.Rows.Count < andon.Count) // GridAndon.Rows.Add(); // StationEntity Stationen = StationFactory.GetByPrimaryKey(andon[i].LOCATION_CODE); // LocationEntity location = LocationFactory.GetByMasterKey(Stationen.RMES_ID); // GridAndon.Rows[i].Cells[0].Value = andon[i].ANDON_ALERT_TIME.ToString("MM/dd/HH:mm"); // GridAndon.Rows[i].Cells[1].Value = Stationen.STATION_NAME; // // GridAndon.Rows[i].Cells[2].Value = location.LOCATION_NAME; // GridAndon.Rows[i].Cells[3].Value = andon[i].ANDON_ALERT_CONTENT.Substring(3, 4); // } //} private void Init() { //textBox.Text = "123"; List <AndonAlertEntity> andon = AndonFactory.GetByTime(); string string1 = "";//, string2, string3; string string2 = ""; string string3 = ""; string string4 = ""; string str1 = ""; string[] str = new string[] { "", "", "" }; for (int i = 0; i < andon.Count; i++) { StationEntity Stationen = StationFactory.GetByPrimaryKey(andon[i].LOCATION_CODE); LocationEntity location = LocationFactory.GetByMasterKey(Stationen.RMES_ID); TeamEntity team = TeamFactory.GetByTeamCode(andon[i].TEAM_CODE); string1 = andon[i].ANDON_ALERT_TIME.ToString("MM/dd/HH:mm"); string2 = Stationen.STATION_NAME; string3 = team.TEAM_NAME; string4 = andon[i].ANDON_ALERT_CONTENT.ToString(); str[i] = string1 + " ," + string2 + string3 + string4; str1 = str1 + str[i] + "\r\n"; textBox.Text = str1; } }
public TeamService(IActionHandler handler, ITeamRepository teamRepository, TeamDTOMapper teamMapper, TeamFactory teamFactory, ITelemetryEventService telemetry) : base(handler) { _teamRepository = teamRepository; _teamFactory = teamFactory; _teamMapper = teamMapper; _telemetry = telemetry; }
protected override DeleteTeamCommand CreateCommand() { Arena arena = Arena.Create(1, "arena", 121); var model = TeamFactory.GetModel("TeamTestName", "ShortName", 20, "url", arena); return(new DeleteTeamCommand(model)); }
public Team Create(string name, string teamDelegate, string shieldImage, string teamImage) { { var Team = TeamFactory.Create(name, teamDelegate, shieldImage, teamImage); TeamRepository.Add(Team); TeamRepository.Context.Commit(); return(Team); } }
internal Scene3D( Game game, MapFile mapFile, string mapPath, int randomSeed, Data.Map.Player[] mapPlayers, Data.Map.Team[] mapTeams, ScriptList[] mapScriptLists, GameType gameType) : this(game, () => game.Viewport, game.InputMessageBuffer, randomSeed, false, mapFile, mapPath) { var contentManager = game.ContentManager; PlayerManager.OnNewGame(mapPlayers, game, gameType); TeamFactory = new TeamFactory(); TeamFactory.Initialize(mapTeams, PlayerManager); Audio = game.Audio; AssetLoadContext = game.AssetStore.LoadContext; Lighting = new WorldLighting( mapFile.GlobalLighting.LightingConfigurations.ToLightSettingsDictionary(), mapFile.GlobalLighting.Time); LoadObjects( game.AssetStore.LoadContext, Terrain.HeightMap, mapFile.ObjectsList.Objects, MapFile.NamedCameras, out var waypoints, out var roads, out var bridges, out var cameras); Roads = roads; Bridges = bridges; Waypoints = waypoints; Cameras = cameras; PlayerScripts = new PlayerScriptsList { ScriptLists = mapScriptLists }; CameraController = new RtsCameraController(game.AssetStore.GameData.Current, Camera, Terrain.HeightMap) { TerrainPosition = Terrain.HeightMap.GetPosition( Terrain.HeightMap.Width / 2, Terrain.HeightMap.Height / 2) }; contentManager.GraphicsDevice.WaitForIdle(); }
public Population(IPopulationParameters parameters) { Units = new List <Team>(); for (int i = 0; i < parameters.PopulationSize; i++) { Units.Add(TeamFactory.GetTeam(parameters)); } Best = Units.FirstOrDefault()?.GetClone(); }
public Team LoadTeam(string path, ITeamParameters parameters) { var team = TeamFactory.GetTeam(parameters); for (int i = 0; i < parameters.NumberOfShepherds; i++) { team.Members[i] = Load <Shepherd>(Path.Combine(path, i.ToString()) + ".xml"); } return(team); }
public PoolGroup Build() { PoolFactory poolFactory = new PoolFactory(); TeamFactory teamFactory = new TeamFactory(); GameFactory gameFactory = new GameFactory(); _poolGroup.Pools = poolFactory.Create(_numOfPools); _poolGroup.Pools = teamFactory.Create(_poolGroup.Pools, _numOfTeams, _seedMethod); _poolGroup.Pools = gameFactory.Create(_poolGroup.Pools, _numOfRounds); return(_poolGroup); }
public void AddTeam(string teamName, Guid teamOwnerId, string description) { if (Teams.Any(team => team.Name == teamName)) { throw new Exception(); } var team = TeamFactory.Create(teamName, teamOwnerId, Id, description); Teams.Add(team); }
public Team(TeamDTO teamDTO, string source) { TeamID = teamDTO.TeamID; TeamName = teamDTO.TeamName; MinimumAge = teamDTO.MinimumAge; MinimumElo = teamDTO.MinimumElo; IsPrivate = teamDTO.IsPrivate; Description = teamDTO.Description; Country = teamDTO.Country; Language = teamDTO.Language; PlayedGame = teamDTO.PlayedGame; teamDB = TeamFactory.GetTeamDB(source); }
private void txtBz_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar.ToString().Equals("\r")) { try { if (txtBz.Text == "") { txtBz.Focus(); return; } string team = txtBz.Text.Trim().ToUpper(); switch (team) { case "QUIT": Process.Start("shutdown.exe", "-s -t 10"); break; case "EXIT": this.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.Close(); break; case "CANC": txtBc.Focus(); txtBz.Text = ""; break; default: break; } DB.WriteConfigLocal("TEAM_CODE", team); LoginInfo.TeamInfo = TeamFactory.GetByTeamCode(team); txtBz.Text = ""; txtBz.Text = LoginInfo.TeamInfo.TEAM_NAME; e.Handled = true; //if (txtUser.Text == "") { txtUser.Focus(); return; } } catch { txtBz.Text = ""; txtBz.SelectionStart = 0; txtBz.SelectionLength = txtBc.Text.Length; txtBz.Focus(); } } }
public static void Main(string[] args) { string command = Console.ReadLine(); while (command.ToUpper() != "END") { try { var splitCommand = command.Split(";"); if (splitCommand[0] == "Team") { Team team = new Team(splitCommand[1]); TeamFactory.AddTeam(team); } else if (splitCommand[0] == "Add") { int index = TeamFactory.FindTeam(splitCommand[1]); Stats stats = new Stats(int.Parse(splitCommand[3]), int.Parse(splitCommand[4]), int.Parse(splitCommand[5]), int.Parse(splitCommand[6]), int.Parse(splitCommand[7])); Player player = new Player(splitCommand[2], stats); TeamFactory.AddPlayer(player, index); } else if (splitCommand[0] == "Remove") { int index = TeamFactory.FindTeam(splitCommand[1]); TeamFactory.RemovePlayer(splitCommand[2], index); } else if (splitCommand[0] == "Rating") { Team team = TeamFactory.Teams.FirstOrDefault(t => t.Name == splitCommand[1]); if (team == null) { throw new ArgumentException(String.Format(ExceptionMessage.MissingTeamException, splitCommand[1])); } Console.WriteLine($"{team.Name} - {team.Rating}"); } } catch (ArgumentException ae) { Console.WriteLine(ae.Message); } command = Console.ReadLine(); } }
private void initComboBoxByCompany() { initing = true; object val = null; val = comboBox1.SelectedValue; try { if (val != null) { comboBox2.DataSource = ProductLineFactory.GetByCompanyCode(val.ToString()); comboBox2.SelectedValue = DB.ReadConfigLocal("PRODUCTLINE_CODE"); setComboxBoxCurrent(comboBox2); val = comboBox2.SelectedValue; if (val != null) { comboBox3.DataSource = StationFactory.GetByProductLine(val.ToString()); } else { List <StationEntity> stas = StationFactory.GetAll(); var sta1 = from ss in stas where ss.COMPANY_CODE == LoginInfo.CompanyInfo.COMPANY_CODE select ss; comboBox3.DataSource = sta1.ToList <StationEntity>(); } comboBox6.SelectedValue = DB.ReadConfigLocal("WORKSHOP_CODE"); comboBox6.DataSource = WorkShopFactory.GetAll(); setComboxBoxCurrent(comboBox6); comboBox3.SelectedValue = DB.ReadConfigLocal("STATION_CODE"); setComboxBoxCurrent(comboBox3); comboBox4.DataSource = ShiftFactory.GetAll(); comboBox4.SelectedValue = DB.ReadConfigLocal("SHIFT_CODE"); setComboxBoxCurrent(comboBox4); comboBox5.DataSource = TeamFactory.GetByPlineCode(val.ToString()); comboBox5.SelectedValue = DB.ReadConfigLocal("TEAM_CODE"); setComboxBoxCurrent(comboBox5); } } catch { } initing = false; }
public void Given_Retrieve_When_PassedValidQuery_Then_Should_ReturnTeamById() { Arena arena = Arena.Create(1, "arena", 121); var teams = TeamFactory.GetEntity("TeamTestName", "ShortName", 20, "url", arena).ToQueryableCollection(); RepositoryMock.Setup(r => r.GetTeamsByLeagueId(leagueId)).Returns(teams); var models = TeamFactory.GetModel(teams.First()).ToReadOnlyCollection(); MapperMock.Setup(m => m.Map <IReadOnlyCollection <TeamModel> >(teams)).Returns(models); var result = ExecuteQuery(); result.Should().NotBeNull(); result.Teams.Should().NotBeNull(); }
public void Given_Retrieve_When_PassedValidQuery_Then_Should_ReturnTeamById() { Arena arena = Arena.Create(1, "arena", 121); var team = TeamFactory.GetEntity("TeamTestName", "ShortName", 20, "url", arena); RepositoryMock.Setup(r => r.GetById(id)).Returns(team); var model = TeamFactory.GetModel(team); MapperMock.Setup(m => m.Map <TeamModel>(team)).Returns(model); var result = ExecuteQuery(); result.Should().NotBeNull(); result.Team.Should().NotBeNull(); }
public List <TeamWithBoardsDTO> GetTeamsWithBoardsForUser(string userId) { var teams = _teamRepository.GetUserTeams(userId); var teamWithBoardsList = new List <TeamWithBoardsDTO>(teams.Count); teams.ForEach(team => { var boards = _boardRepository.GetTeamBoards(team.Id); var teamWithBoards = new TeamWithBoardsDTO { Team = TeamFactory.createReturnMinimalDTO(team), Boards = BoardFactory.createReturnDTOList(boards) }; teamWithBoardsList.Add(teamWithBoards); }); return(teamWithBoardsList); }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { if (initing) { return; } string plinermesid = comboBox2.SelectedValue.ToString(); DB.WriteConfigLocal("PRODUCTLINE_CODE", plinermesid); List <StationEntity> stations = StationFactory.GetAll(); var ss = from s in stations where s.PLINE_CODE == plinermesid && s.COMPANY_CODE == comboBox1.SelectedValue.ToString() select s; comboBox3.DataSource = ss.ToList <StationEntity>(); List <TeamEntity> teams = TeamFactory.GetByPlineCode(plinermesid); comboBox5.DataSource = teams; }
internal Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, WorldLighting lighting, int randomSeed, bool isDiagnosticScene = false) : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null) { TeamFactory = new TeamFactory(); WaterAreas = AddDisposable(new WaterAreaCollection()); Lighting = lighting; Roads = AddDisposable(new RoadCollection()); Bridges = Array.Empty <Bridge>(); Waypoints = new WaypointCollection(); Cameras = new CameraCollection(); CameraController = cameraController; }
private void StartHerding() { ButtonPause.Enabled = true; ButtonResume.Enabled = false; ButtonStepBack.Enabled = false; ButtonStepForward.Enabled = false; TransformPositions(); var parameters = (OptimizationParameters) new XmlSerializer(typeof(OptimizationParameters)).Deserialize(new StringReader(richTextBoxParameters.Text)); if (checkBoxRandom.Checked) { parameters.PositionsOfShepherds = parameters.PositionsOfShepherds.Randomize(0, 400).ToList(); parameters.PositionsOfSheep = parameters.PositionsOfSheep.Randomize(0, 400).ToList(); } var sheep = AgentFactory.GetSheep(parameters.PositionsOfSheep, parameters.SheepType, parameters.SeedForRandomSheepForBest); var shepherds = richTextBoxShepherds.Text.Split('\n') .Where(x => string.IsNullOrEmpty(x) == false) .Select(x => repository.LoadShepherd(x)); var team = TeamFactory.GetNotIdenticalTeam(shepherds.Cast <ThinkingAgent>().ToList()); team.Resize(parameters.PositionsOfShepherds.Count()); team.SetPositions(parameters.PositionsOfShepherds); world = new ViewableWorld( HerdingX, HerdingY, checkBoxAnimationMode.Checked ? MilisecondsBetweenSteps : 0, team, sheep); world.Start(parameters.TurnsOfHerding); paint = true; }
protected void Page_Load(object sender, EventArgs e) { userManager theUserManager = (userManager)Session["theUserManager"]; theUserId = theUserManager.getUserId(); dt.Columns.Add("PROJECT_CODE"); dt.Columns.Add("ASSEMBLY_CODE"); dt.Columns.Add("TEAM_CODE"); dt.Columns.Add("ITEM_CODE"); dt.Columns.Add("ITEM_NAME"); dt.Columns.Add("PLAN_QTY"); dt.Columns.Add("SEND_QTY"); dt.Columns.Add("RECEIVE_QTY"); dt.Columns.Add("CALCULATE_QTY"); if (!IsPostBack) { List <WorkShopEntity> workShop = WorkShopFactory.GetUserWorkShops(theUserId); string strWorkShop = workShop[0].RMES_ID; string sql = "select PROJECT_CODE,PROJECT_CODE||' | '||PROJECT_NAME as SHOWNAME from DATA_PROJECT WHERE STATUS='Y'and WORKSHOP_ID = '" + strWorkShop + "' order by project_code"; ASPxComboBoxProject.DataSource = dc.GetTable(sql); ASPxComboBoxProject.TextField = "SHOWNAME"; ASPxComboBoxProject.ValueField = "PROJECT_CODE"; ASPxComboBoxProject.DataBind(); List <TeamEntity> team = TeamFactory.GetByUserID(theUserId); List <TeamEntity> orderTeam = (from c in team orderby c.TEAM_NAME select c).ToList <TeamEntity>(); ASPxComboBoxTeam.DataSource = orderTeam; ASPxComboBoxTeam.TextField = "TEAM_NAME"; ASPxComboBoxTeam.ValueField = "RMES_ID"; ASPxComboBoxTeam.DataBind(); ASPxComboBoxTeam.SelectedIndex = -1; } BindData(); }
private void CreateTestData() { string message; bool createTestData; if (DataAlreadyExist(out message)) { Console.WriteLine("-------------------------"); Console.WriteLine(message); Console.WriteLine("-------------------------"); AskFor(out createTestData, "Do you want to continue?"); if (!createTestData) { return; } bool replaceData; AskFor(out replaceData, "Do you want to replace or add to existing data?", ConsoleKey.R, ConsoleKey.A, false); if (replaceData) { RemoveCurrentData(); } } else { createTestData = true; Console.WriteLine("-------------------------"); Console.WriteLine(message); Console.WriteLine("-------------------------"); } if (createTestData) { int maxInputAttempts = DefaultMaxInputAttempts, maxNumberOfSeries = 20, inputAttempts = 0; uint numberOfSeries = 0; Console.WriteLine($"Create test data.\nMaximum number of series to create: {maxNumberOfSeries}.\nEnter '0' to abort."); while (inputAttempts < maxInputAttempts) { AskFor(out numberOfSeries, "Enter the number of series that you want to create: "); if (0 < numberOfSeries && numberOfSeries <= maxNumberOfSeries) { break; } if (numberOfSeries == 0) { Console.WriteLine("Creating test data was aborted."); inputAttempts = maxInputAttempts; break; } if (numberOfSeries > maxNumberOfSeries) { Console.WriteLine("Will not create that many series. Try again."); inputAttempts++; } } if (inputAttempts == maxInputAttempts) { Console.WriteLine("No test data was created. Returning to main menu.\nPress any key to continue..."); Console.ReadKey(); return; } int playerCounter = 1, teamCounter = 1; List <Player> players = new List <Player>(); List <Team> teams = new List <Team>(); List <Match> matches = new List <Match>(); List <Serie> series = new List <Serie>(); for (int s = 0; s < numberOfSeries; s++) { List <List <Player> > playerLists = new List <List <Player> >(); List <Team> teamList = new List <Team>(); List <Match> matchList = new List <Match>(); for (int t = 0; t < 16; t++) { int amount = _Random.Next(24, 31); playerLists.Add(PlayerFactory.CreateListOfPlayerLists(amount, playerCounter)); playerCounter += amount; } teamList = TeamFactory.CreateTeamsAndSetPlayersTeamId(playerLists, teamCounter); teamCounter += Serie.NumberOfTeams; matchList = MatchTableFactory.CreateMatchTable(teamList, GetRandomDate(DateTime.Now, DateTime.Now.AddYears(2))); Serie serie = new Serie(new GeneralName($"Serie-{s + 1}"), teamList.Select(team => team.Id).ToHashSet(), matchList.Select(match => match.Id).ToHashSet()); foreach (Team team in teamList) { team.SerieIds.Add(serie.Id); } foreach (List <Player> playerList in playerLists) { players.AddRange(playerList); } teams.AddRange(teamList); matches.AddRange(matchList); series.Add(serie); } SaveTestData(players, teams, matches, series); } }
public void AddTeam(Team team) { Teams.Add(team); IAddTeamDal dal = TeamFactory.GetTeamDal(); }
private static void CreateTeamCommand(List <Team> teams, string teamName) { Team team = TeamFactory.Create(teamName); teams.Add(team); }
public TeamManager() { source = "release"; teamManagerDB = TeamFactory.GetTeamManagerDB("release"); }
public TeamManager(string source) { this.source = source; teamManagerDB = TeamFactory.GetTeamManagerDB(source); }
public TeamController() { _context = new ApplicationDbContext(); _factory = new TeamFactory(); //MappingProfile.Initialize(); }
public static void LoadFromStream(Stream stream, Game game) { using (var reader = new BinaryReader(stream, Encoding.Unicode, true)) { var chunkHeaders = new List <SaveChunkHeader>(); var chunkHeader = SaveChunkHeader.Parse(reader); GameState gameState = null; MapFile map = null; while (!chunkHeader.IsEof) { chunkHeaders.Add(chunkHeader); var end = stream.Position + chunkHeader.DataLength; switch (chunkHeader.Name) { case "CHUNK_GameState": { gameState = GameState.Parse(reader); // TODO: Start game after parsing players. break; } case "CHUNK_Campaign": { var side = reader.ReadBytePrefixedAsciiString(); var missionName = reader.ReadBytePrefixedAsciiString(); var unknown = reader.ReadUInt32(); var maybeDifficulty = reader.ReadUInt32(); if (chunkHeader.Version >= 5) { var unknown2 = reader.ReadBytes(5); } break; } case "CHUNK_GameStateMap": { var mapPath1 = reader.ReadBytePrefixedAsciiString(); var mapPath2 = reader.ReadBytePrefixedAsciiString(); var unknown = reader.ReadUInt32(); if (unknown != 0u && unknown != 2u) { throw new InvalidDataException(); } var mapFileSize = reader.ReadUInt32(); var mapEnd = stream.Position + mapFileSize; map = MapFile.FromStream(stream); game.StartGame( // TODO: Do this after parsing players. mapPath2.Replace("userdata\\", ""), new EchoConnection(), // TODO new PlayerSetting?[] { new PlayerSetting( null, game.AssetStore.PlayerTemplates.GetByName("FactionAmerica"), // TODO new ColorRgb(0, 0, 255)) }, localPlayerIndex: 0, // TODO isMultiPlayer: false, seed: Environment.TickCount, // TODO map); // TODO // This seems to be aligned, so it's sometimes more than what we just read. stream.Seek(mapEnd, SeekOrigin.Begin); var unknown2 = reader.ReadUInt32(); // 586 var unknown3 = reader.ReadUInt32(); // 3220 if (unknown == 2u) { var unknown4 = reader.ReadUInt32(); // 2 var unknown5 = reader.ReadUInt32(); // 25600 (160^2) var unknown6 = reader.ReadBooleanChecked(); var unknown7 = reader.ReadBooleanChecked(); var unknown8 = reader.ReadBooleanChecked(); var unknown9 = reader.ReadBooleanChecked(); var unknown10 = reader.ReadUInt32(); // 0 var numPlayers = reader.ReadUInt32(); // 8 var unknown11 = reader.ReadUInt32(); // 5 var players = new GameStateMapPlayer[numPlayers]; for (var i = 0; i < numPlayers; i++) { players[i] = GameStateMapPlayer.Parse(reader); } var mapPath3 = reader.ReadBytePrefixedAsciiString(); var mapFileCrc = reader.ReadUInt32(); var mapFileSize2 = reader.ReadUInt32(); if (mapFileSize != mapFileSize2) { throw new InvalidDataException(); } var unknown12 = reader.ReadUInt32(); var unknown13 = reader.ReadUInt32(); } break; } case "CHUNK_TerrainLogic": { var unknown = reader.ReadInt32(); if (unknown != 2u) { throw new InvalidDataException(); } var unknown2 = reader.ReadInt32(); if (unknown2 != 0u) { throw new InvalidDataException(); } var unknown3 = reader.ReadByte(); if (unknown3 != 0) { throw new InvalidDataException(); } break; } case "CHUNK_TeamFactory": { //var bytes = reader.ReadBytes((int) chunkHeader.DataLength); //File.WriteAllBytes($"CHUNK_TeamFactory_{gameState.Timestamp.Ticks}", bytes); var teamFactory = new TeamFactory(); teamFactory.Load(reader); break; } case "CHUNK_Players": { //var bytes = reader.ReadBytes((int)chunkHeader.DataLength); //File.WriteAllBytes($"CHUNK_Players_{gameState.Timestamp.Ticks}", bytes); var numPlayers = reader.ReadUInt32(); var players = new Logic.Player[numPlayers]; for (var i = 0; i < numPlayers; i++) { players[i] = new Logic.Player(null, new ColorRgb()); players[i].Load(reader); } break; } case "CHUNK_GameLogic": { //stream.Seek(chunkHeader.DataLength, SeekOrigin.Current); //break; var unknown1 = reader.ReadUInt32(); // Maybe some kind of frame counter var unknown2 = reader.ReadByte(); var numGameObjectDefinitions = reader.ReadUInt32(); var gameObjectDefinitionLookup = new Dictionary <ushort, string>(); for (var i = 0; i < numGameObjectDefinitions; i++) { var definitionName = reader.ReadBytePrefixedAsciiString(); var definitionId = reader.ReadUInt16(); gameObjectDefinitionLookup.Add(definitionId, definitionName); } var numGameObjects = reader.ReadUInt32(); for (var objectIndex = 0; objectIndex < numGameObjects; objectIndex++) { var definitionId = reader.ReadUInt16(); var gameObject = game.Scene3D.GameObjects.Add(gameObjectDefinitionLookup[definitionId]); var unknown3 = reader.ReadUInt32(); var unknown4 = reader.ReadByte(); // 7 var unknown5 = reader.ReadUInt16(); // Inverse of object ID?? var unknownBool1 = reader.ReadBooleanChecked(); // 0 var unknownBool2 = reader.ReadBooleanChecked(); // 0 var unknownBool3 = reader.ReadBooleanChecked(); // 1 var transform = reader.ReadMatrix4x3Transposed(); gameObject.SetTransformMatrix(transform.ToMatrix4x4()); var unknown8 = reader.ReadBytes(16); var someString = reader.ReadBytePrefixedAsciiString(); // ChinaCommandCenter var unknown8_1 = reader.ReadBytes(12); var unknown9 = reader.ReadSingle(); // 14 var unknown10 = reader.ReadSingle(); // 12 var unknown11 = reader.ReadSingle(); // 11 var unknown12 = reader.ReadSingle(); // 12 var unknown13 = reader.ReadSingle(); // 12 var unknown14 = reader.ReadByte(); var position = reader.ReadVector3(); var unknown = reader.ReadSingle(); // 360 var unknown15 = reader.ReadBytes(29); var unknown16 = reader.ReadSingle(); // 360 var unknown17 = reader.ReadSingle(); // 360 var unknown18 = reader.ReadBytes(5); var disabledCount = reader.ReadUInt32(); var disabledEnumMap = IniParser.GetEnumMap <DisabledType>(); for (var i = 0; i < disabledCount; i++) { var disabledType = (DisabledType)disabledEnumMap[reader.ReadBytePrefixedAsciiString()]; } var unknown18_1 = reader.ReadBytes(75); var numUpgrades = reader.ReadUInt16(); for (var i = 0; i < numUpgrades; i++) { var upgradeName = reader.ReadBytePrefixedAsciiString(); var upgrade = game.AssetStore.Upgrades.GetByName(upgradeName); gameObject.Upgrade(upgrade); } var team = reader.ReadBytePrefixedAsciiString(); // teamPlyrAmerica var unknown19 = reader.ReadBytes(16); var someCount = reader.ReadByte(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); for (var i = 0; i < someCount; i++) { var someString1 = reader.ReadBytePrefixedAsciiString(); // OuterPerimeter7, InnerPerimeter7 reader.ReadBooleanChecked(); reader.ReadBooleanChecked(); reader.ReadBooleanChecked(); } reader.ReadBytes(17); // Modules var numModules = reader.ReadUInt16(); for (var i = 0; i < numModules; i++) { var moduleTag = reader.ReadBytePrefixedAsciiString(); var moduleLengthInBytes = reader.ReadUInt32(); var moduleStart = reader.BaseStream.Position; var moduleEnd = moduleStart + moduleLengthInBytes; reader.ReadBytes((int)moduleLengthInBytes); //var module = gameObject.GetModuleByTag(moduleTag); //module.Load(reader); //if (reader.BaseStream.Position != moduleEnd) //{ // throw new InvalidDataException($"Error parsing module '{moduleTag}' (type {module.GetType().Name}, started at {moduleStart:X8}) in object with definition {gameObject.Definition.Name}. Expected stream to be at position {moduleEnd:X8} but was at {reader.BaseStream.Position:X8}."); //} } reader.ReadBytes(9); var someCount2 = reader.ReadUInt32(); for (var i = 0; i < someCount2; i++) { var condition = reader.ReadBytePrefixedAsciiString(); } reader.ReadBytes(8); var objectName = reader.ReadBytePrefixedAsciiString(); reader.ReadBooleanChecked(); var someCount3 = reader.ReadUInt32(); for (var i = 0; i < someCount3; i++) { var condition = reader.ReadBytePrefixedAsciiString(); } // 5 possible weapons... for (var i = 0; i < 5; i++) { var slotFilled = reader.ReadBooleanChecked(); // 1 if (slotFilled) { reader.ReadByte(); // 3 var weaponTemplateName = reader.ReadBytePrefixedAsciiString(); var weaponSlot = reader.ReadByteAsEnum <OpenSage.Logic.Object.WeaponSlot>(); reader.ReadBytes(55); } } reader.ReadBytes(21); var numSpecialPowers = reader.ReadUInt32(); for (var i = 0; i < numSpecialPowers; i++) { var specialPower = reader.ReadBytePrefixedAsciiString(); } reader.ReadBooleanChecked(); // 0 reader.ReadBooleanChecked(); // 1 reader.ReadBooleanChecked(); // 1 } reader.ReadByte(); // 3 var sideName = reader.ReadBytePrefixedAsciiString(); var missionName = reader.ReadBytePrefixedAsciiString(); reader.ReadBytes(12); var someCount4 = reader.ReadUInt32(); for (var i = 0; i < someCount4; i++) { var maybeIndex = reader.ReadUInt32(); reader.ReadBooleanChecked(); // 1 var someCount5 = reader.ReadUInt32(); for (var j = 0; j < someCount5; j++) { reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); } reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadSingle(); reader.ReadBooleanChecked(); } reader.ReadUInt32(); // 1000 reader.ReadUInt32(); // 0 reader.ReadBooleanChecked(); // 0 reader.ReadBooleanChecked(); // 1 reader.ReadBooleanChecked(); // 1 reader.ReadBooleanChecked(); // 1 reader.ReadUInt32(); // 0xFFFFFFFF reader.ReadUInt32(); // 0 reader.ReadBooleanChecked(); // 0 break; } case "CHUNK_ParticleSystem": { var unknown = reader.ReadUInt32(); var count = reader.ReadUInt32(); for (var i = 0; i < count; i++) { var name = reader.ReadBytePrefixedAsciiString(); if (name != string.Empty) { reader.ReadBytes(11); var texture = reader.ReadBytePrefixedAsciiString(); var angleX = reader.ReadRandomVariable(); var angleY = reader.ReadRandomVariable(); var angleZ = reader.ReadRandomVariable(); var unknown1 = reader.ReadRandomVariable(); // Maybe AngularRateX, Y, Z, if same order as ini files var unknown2 = reader.ReadRandomVariable(); var unknown3 = reader.ReadRandomVariable(); var angularDamping = reader.ReadRandomVariable(); var velocityDamping = reader.ReadRandomVariable(); var lifetime = reader.ReadRandomVariable(); var unknown4 = reader.ReadUInt32(); var size = reader.ReadRandomVariable(); var unknown5 = reader.ReadRandomVariable(); // Maybe StartSizeRate, if same order as ini files var sizeRate = reader.ReadRandomVariable(); var sizeRateDamping = reader.ReadRandomVariable(); for (var j = 0; j < 8; j++) { var alphaKeyframe = RandomAlphaKeyframe.ReadFromSaveFile(reader); } for (var j = 0; j < 8; j++) { var colorKeyframe = RgbColorKeyframe.ReadFromSaveFile(reader); } var unknown6 = reader.ReadRandomVariable(); // Maybe ColorScale, if same order as ini files, but value doesn't match ini file var burstDelay = reader.ReadRandomVariable(); var burstCount = reader.ReadRandomVariable(); var unknown7 = reader.ReadRandomVariable(); // Maybe InitialDelay, if same order as ini files var unknown8 = reader.ReadVector3(); // Maybe DriftVelocity, if same order as ini files var gravity = reader.ReadSingle(); var unknown9 = reader.ReadBytes(14); var velocityType = reader.ReadUInt32AsEnum <ParticleVelocityType>(); var unknown10 = reader.ReadUInt32(); switch (velocityType) { case ParticleVelocityType.Ortho: var velocityOrthoX = reader.ReadRandomVariable(); var velocityOrthoY = reader.ReadRandomVariable(); var velocityOrthoZ = reader.ReadRandomVariable(); break; case ParticleVelocityType.Spherical: var velocitySpherical = reader.ReadRandomVariable(); break; case ParticleVelocityType.Hemispherical: var velocityHemispherical = reader.ReadRandomVariable(); break; case ParticleVelocityType.Cylindrical: var velocityCylindricalRadial = reader.ReadRandomVariable(); var velocityCylindricalNormal = reader.ReadRandomVariable(); break; case ParticleVelocityType.Outward: var velocityOutward = reader.ReadRandomVariable(); var velocityOutwardOther = reader.ReadRandomVariable(); break; default: throw new NotImplementedException(); } var volumeType = reader.ReadUInt32AsEnum <ParticleVolumeType>(); switch (volumeType) { case ParticleVolumeType.Point: break; case ParticleVolumeType.Line: var lineStartPoint = reader.ReadVector3(); var lineEndPoint = reader.ReadVector3(); break; case ParticleVolumeType.Box: var halfSize = reader.ReadVector3(); break; case ParticleVolumeType.Sphere: var volumeSphereRadius = reader.ReadSingle(); // Interesting, value doesn't match ini file break; case ParticleVolumeType.Cylinder: var volumeCylinderRadius = reader.ReadSingle(); var volumeCylinderLength = reader.ReadSingle(); break; default: throw new NotImplementedException(); } var unknown11 = reader.ReadUInt32(); var windMotion = reader.ReadUInt32AsEnum <ParticleSystemWindMotion>(); var unknown12 = reader.ReadSingle(); var unknown13 = reader.ReadSingle(); // Almost same as WindAngleChangeMin var windAngleChangeMin = reader.ReadSingle(); var windAngleChangeMax = reader.ReadSingle(); var unknown14 = reader.ReadSingle(); var windPingPongStartAngleMin = reader.ReadSingle(); var windPingPongStartAngleMax = reader.ReadSingle(); var unknown15 = reader.ReadSingle(); var windPingPongEndAngleMin = reader.ReadSingle(); var windPingPongEndAngleMax = reader.ReadSingle(); var unknown16 = reader.ReadBooleanChecked(); var unknown17 = reader.ReadUInt32(); var unknown18 = reader.ReadBytes(9); var transform = reader.ReadMatrix4x3Transposed(); var unknown19 = reader.ReadBooleanChecked(); var transform2 = reader.ReadMatrix4x3Transposed(); var unknown20 = reader.ReadUInt32(); // Maybe _nextBurst var unknown21 = reader.ReadUInt32(); var unknown22 = reader.ReadUInt32(); var unknown23 = reader.ReadUInt32(); var unknown24 = reader.ReadUInt32(); reader.ReadBytes(6); for (var j = 0; j < 6; j++) { var unknown25 = reader.ReadSingle(); // All 1 } reader.ReadBytes(33); var numParticles = reader.ReadUInt32(); for (var j = 0; j < numParticles; j++) { var unknown26 = reader.ReadBooleanChecked(); var unknown27 = reader.ReadBooleanChecked(); var unknown28 = reader.ReadVector3(); var particlePosition = reader.ReadVector3(); var anotherPosition = reader.ReadVector3(); var particleVelocityDamping = reader.ReadSingle(); var unknown29 = reader.ReadSingle(); // 0 var unknown30 = reader.ReadSingle(); // 0 var unknown31 = reader.ReadSingle(); // 3.78, maybe AngleZ var unknown32 = reader.ReadSingle(); // 0 var unknown33 = reader.ReadSingle(); // 0 var unknown34 = reader.ReadSingle(); // 0 var unknown34_ = reader.ReadSingle(); var unknown35 = reader.ReadSingle(); // 17.8 var unknown36 = reader.ReadSingle(); // 0.04 var particleSizeRateDamping = reader.ReadSingle(); for (var k = 0; k < 8; k++) { var alphaKeyframeAlpha = reader.ReadSingle(); var alphaKeyframeTime = reader.ReadUInt32(); var alphaKeyframe = new ParticleAlphaKeyframe( alphaKeyframeTime, alphaKeyframeAlpha); } for (var k = 0; k < 8; k++) { var colorKeyframeColor = reader.ReadColorRgbF(); var colorKeyframeTime = reader.ReadUInt32(); var colorKeyframe = new ParticleColorKeyframe( colorKeyframeTime, colorKeyframeColor.ToVector3()); } var unknown37 = reader.ReadSingle(); var unknown38 = reader.ReadBooleanChecked(); var unknown39 = reader.ReadSingle(); reader.ReadBytes(28); // All 0 var unknown40 = reader.ReadUInt32(); // 49 var unknown41 = reader.ReadUInt32(); // 1176 var particleAlpha = reader.ReadSingle(); // 1.0 var unknown42 = reader.ReadUInt32(); // 0 var unknown43 = reader.ReadUInt32(); // 1 var unknown44 = reader.ReadVector3(); // (0.35, 0.35, 0.35) reader.ReadBytes(12); // All 0 var unknown45 = reader.ReadUInt32(); // 1 reader.ReadBytes(8); // All 0 } } } break; } case "CHUNK_Radar": { game.Scene3D.Radar.Load(reader); break; } case "CHUNK_ScriptEngine": game.Scripting.Load(reader); break; case "CHUNK_SidesList": { game.Scene3D.Terrain.Map.SidesList.Load(reader); break; } case "CHUNK_TacticalView": { var cameraAngle = reader.ReadSingle(); var cameraPosition = reader.ReadVector2(); var unknown2 = reader.ReadUInt32(); if (unknown2 != 0) { throw new InvalidDataException(); } break; } case "CHUNK_GameClient": { var unknown1 = reader.ReadUInt32(); // Maybe some kind of frame counter var unknown2 = reader.ReadByte(); var numGameObjects = reader.ReadUInt32(); var gameObjects = new List <GameObjectState>(); for (var i = 0; i < numGameObjects; i++) { gameObjects.Add(new GameObjectState { Name = reader.ReadBytePrefixedAsciiString(), Id = reader.ReadUInt16() }); } var numGameObjects2 = reader.ReadUInt16(); // 5 for (var i = 0; i < numGameObjects2; i++) { var objectID = reader.ReadUInt16(); reader.ReadBytes(14); var numModelConditionFlags = reader.ReadUInt32(); for (var j = 0; j < numModelConditionFlags; j++) { var modelConditionFlag = reader.ReadBytePrefixedAsciiString(); } reader.ReadByte(); var transform = reader.ReadMatrix4x3Transposed(); var unknownBool = reader.ReadBooleanChecked(); var unknownBool2 = reader.ReadBooleanChecked(); if (unknownBool) { for (var j = 0; j < 9; j++) { reader.ReadSingle(); } reader.ReadBytes(19); } reader.ReadBytes(56); var unknownBool3 = reader.ReadBooleanChecked(); if (unknownBool3) { for (var j = 0; j < 19; j++) { reader.ReadSingle(); } } reader.ReadBytes(3); var numModules = reader.ReadUInt16(); for (var moduleIndex = 0; moduleIndex < numModules; moduleIndex++) { var moduleTag = reader.ReadBytePrefixedAsciiString(); var moduleLengthInBytes = reader.ReadUInt32(); reader.ReadBytes((int)moduleLengthInBytes); } var numClientUpdates = reader.ReadUInt16(); for (var moduleIndex = 0; moduleIndex < numClientUpdates; moduleIndex++) { var moduleTag = reader.ReadBytePrefixedAsciiString(); var moduleLengthInBytes = reader.ReadUInt32(); reader.ReadBytes((int)moduleLengthInBytes); } reader.ReadBytes(81); } reader.ReadUInt32(); break; } case "CHUNK_InGameUI": { reader.ReadUInt32(); // 0 reader.ReadBooleanChecked(); reader.ReadBooleanChecked(); reader.ReadBooleanChecked(); reader.ReadUInt32(); // 0 var something = reader.ReadUInt32(); while (something != uint.MaxValue) // A way to store things the engine doesn't know the length of? { var someString1 = reader.ReadBytePrefixedAsciiString(); var someString2 = reader.ReadBytePrefixedAsciiString(); var unknown1 = reader.ReadUInt32(); var unknown2 = reader.ReadUInt32(); // 0xFFFFFFFF reader.ReadBooleanChecked(); reader.ReadBooleanChecked(); reader.ReadBooleanChecked(); something = reader.ReadUInt32(); } } break; case "CHUNK_Partition": { var partitionCellSize = reader.ReadSingle(); var count = reader.ReadUInt32(); for (var i = 0; i < count; i++) { reader.ReadBytes(65); } var someOtherCount = reader.ReadUInt32(); for (var i = 0; i < someOtherCount; i++) { reader.ReadBooleanChecked(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadUInt16(); reader.ReadUInt32(); } break; } case "CHUNK_TerrainVisual": reader.ReadBytes(6); for (var i = 0; i < map.HeightMapData.Area; i++) { var unknown = reader.ReadByte(); } break; case "CHUNK_GhostObject": { reader.ReadBooleanChecked(); reader.ReadUInt32(); var count = reader.ReadUInt16(); for (var i = 0; i < count; i++) { var someId = reader.ReadUInt32(); reader.ReadBooleanChecked(); // 1 reader.ReadBooleanChecked(); // 1 var someId2 = reader.ReadUInt32(); // Same as someId reader.ReadUInt32(); reader.ReadByte(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadSingle(); reader.ReadBytes(14); var otherCount = reader.ReadByte(); for (var j = 0; j < otherCount; j++) { var modelName = reader.ReadBytePrefixedAsciiString(); var someFloat = reader.ReadSingle(); var someInt = reader.ReadUInt32(); var someBool = reader.ReadBooleanChecked(); var modelTransform = reader.ReadMatrix4x3Transposed(); var numMeshes = reader.ReadUInt32(); for (var k = 0; k < numMeshes; k++) { var meshName = reader.ReadBytePrefixedAsciiString(); var meshBool = reader.ReadBooleanChecked(); var meshTransform = reader.ReadMatrix4x3Transposed(); } } reader.ReadBooleanChecked(); reader.ReadUInt32(); reader.ReadUInt32(); reader.ReadUInt32(); var unknown = reader.ReadBooleanChecked(); if (unknown) { reader.ReadByte(); reader.ReadUInt32(); } } break; } default: throw new InvalidDataException($"Unknown chunk type '{chunkHeader.Name}'."); } if (stream.Position != end) { throw new InvalidDataException($"Error parsing chunk '{chunkHeader.Name}'. Expected stream to be at position {end} but was at {stream.Position}."); } chunkHeader = SaveChunkHeader.Parse(reader); } if (stream.Position != stream.Length) { throw new InvalidDataException(); } } }
// ReSharper disable once UnusedMember.Global public void Construct(Data.BattleGame data, TeamFactory teamFactory) { _data = data; _teamFactory = teamFactory; }