private void AddTask(GameState s, RTSUnit unit) { // Init The Unit if (unit.CombatController != null) { unit.CombatController.Init(s, this, unit.Data.CombatControllerInitArgs); } if (unit.MovementController != null) { unit.MovementController.Init(s, this, unit.Data.MovementControllerInitArgs); } if (unit.AnimationController != null) { unit.AnimationController.Init(s, this, unit.Data.AnimationControllerInitArgs); } if (unit.ActionController != null) { unit.ActionController.Init(s, this, unit.Data.ActionControllerInitArgs); } var btu = new BTaskUnitDecision(s, unit); unit.OnDestruction += (o) => { tbEntityDecisions.RemoveTask(btu); }; tbEntityDecisions.AddTask(btu); }
public void Hook(RTSRenderer renderer, GameState s, int ti) { ImageWidth = s.CGrid.numCells.X; ImageHeight = s.CGrid.numCells.Y; Terrain = renderer.CreateRenderTarget2D(ImageWidth, ImageHeight, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, RenderTargetUsage.DiscardContents); TeamIndex = ti; Team = s.teams[TeamIndex]; Vector3 center = new Vector3(s.CGrid.size.X * 0.5f, 0, s.CGrid.size.Y * 0.5f); float h = Grey.Vox.Region.HEIGHT + Camera.INITIAL_HIGH_SETTINGS.MaxDistance; mV = Matrix.CreateLookAt(center + Vector3.Up * (h + 1f), center, -Vector3.UnitZ); mP = Matrix.CreateOrthographic(s.CGrid.size.X, s.CGrid.size.Y, 0, h + 2f); mVP = mV * mP; fxCamera = renderer.CreateEffect(); fxCamera.LightingEnabled = false; fxCamera.FogEnabled = false; fxCamera.TextureEnabled = false; fxCamera.VertexColorEnabled = true; fxCamera.View = mV; fxCamera.Projection = mP; fxCamera.World = Matrix.Identity; mapPlanes = new Plane[6]; float off = s.CGrid.size.Length() * 0.25f; mapPlanes[0] = new Plane(Vector3.UnitX, off); mapPlanes[1] = new Plane(Vector3.UnitY, 0); mapPlanes[2] = new Plane(Vector3.UnitZ, off); mapPlanes[3] = new Plane(-Vector3.UnitX, s.CGrid.size.X + off); mapPlanes[4] = new Plane(-Vector3.UnitY, h + 2f); mapPlanes[5] = new Plane(-Vector3.UnitZ, s.CGrid.size.Y + off); refreshFOW = true; s.CGrid.OnFOWChange += (x, y, p, f) => { refreshFOW = refreshFOW | (p == ti); }; TeamMap = renderer.CreateTexture2D(s.CGrid.numCells.X, s.CGrid.numCells.Y, SurfaceFormat.Color, false); qSeen = new Queue <SeenEntity>(); tbScanner = new TimeBudget(SCAN_BINS); float r = (float)s.CGrid.numCells.X / SCAN_BINS; for (int i = 0; i < SCAN_BINS - 1; i++) { tbScanner.AddTask(new ScanTask((int)(r * i), (int)(r * (i + 1)), s.CGrid, Team, qSeen)); } tbScanner.AddTask(new ScanTask((int)(r * (SCAN_BINS - 1)), s.CGrid.numCells.X, s.CGrid, Team, qSeen)); }
public void Init(GameState s, GCInitArgs args) { DevConsole.OnNewCommand += OnDevCommand; tbFOWCalculations.ClearTasks(); for (int ti = 0; ti < s.activeTeams.Length; ti++) { tbFOWCalculations.AddTask(new FOWTask(s, s.activeTeams[ti].Index)); } pathfinder = new Pathfinder(s); vManager = new WorldManager(s.VoxState); // Add All Tasks foreach (var at in s.activeTeams) { foreach (var unit in at.Team.Units) { AddTask(s, unit); } foreach (var building in at.Team.Buildings) { AddTask(s, building); } foreach (var squad in at.Team.Squads) { AddTask(s, squad); } } // Start The Game Type Controller s.scrGTC = s.Scripts[args.GameTypeScript]; s.gtC = s.scrGTC.CreateInstance <ACGameTypeController>(); s.gtC.Load(s, new FileInfo(s.LevelGrid.InfoFile).Directory); }
private void AddTask(GameState s, RTSSquad squad) { // Init The Squad if (squad.TargetingController != null) { squad.TargetingController.Init(s, this, squad.Team.Race.SCTargeting); } if (squad.MovementController != null) { squad.MovementController.Init(s, this, squad.Team.Race.SCMovementInitArgs); } if (squad.ActionController != null) { squad.ActionController.Init(s, this, squad.Team.Race.SCActionInitArgs); } var bts = new BTaskSquadDecision(s, squad); squad.OnDeath += (o) => { tbSquadDecisions.RemoveTask(bts); }; tbSquadDecisions.AddTask(bts); }