public CircleElement(GLEffect a_oDefaultEffect, Vector3 a_oPosition, OrbitingEntity a_oOrbitEntity, System.Drawing.Color a_oColor) : base() { m_oPrimaryPrimitive = new GLCircle(a_oDefaultEffect, a_oPosition, a_oOrbitEntity, a_oColor, UIConstants.Textures.DEFAULT_TEXTURE); m_lPrimitives.Add(m_oPrimaryPrimitive); }
public SystemBody(OrbitingEntity parent, PlanetType type) : base() { /// <summary> /// create these or else anything that relies on a unique global id will break. /// </summary> Id = Guid.NewGuid(); Type = type; // set the type ASAP in case anthing needs to know it. Moons = new BindingList <SystemBody>(); Populations = new BindingList <Population>(); SSEntity = StarSystemEntityType.Body; Parent = parent; Position = parent.Position; TaskGroupsInOrbit = new BindingList <TaskGroupTN>(); GeoSurveyList = new Dictionary <Faction, bool>(); /// <summary> /// Default mineral amount is zero. /// do mineral generation elsewhere. /// </summary> m_aiMinerialReserves = new float[Constants.Minerals.NO_OF_MINERIALS]; m_aiMinerialAccessibility = new float[Constants.Minerals.NO_OF_MINERIALS]; for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++) { m_aiMinerialReserves[mineralIterator] = 0.0f; m_aiMinerialAccessibility[mineralIterator] = 0.0f; } _MineralsGenerated = false; _BodyMineralType = MineralType.NotGenerated; #warning planet generation needs minerals, anomalies, and ruins generation. PlanetaryRuins = new Ruins(); Atmosphere = new Atmosphere(this); if (Type != PlanetType.GasDwarf && Type != PlanetType.GasGiant && Type != PlanetType.IceGiant) { SupportsPopulations = true; } }
public Planet(Star primary, OrbitingEntity parent) : base() { /// <summary> /// create these or else anything that relies on a unique global id will break. /// </summary> Id = Guid.NewGuid(); Moons = new BindingList <Planet>(); Gases = new BindingList <Gas>(); Populations = new BindingList <Population>(); GeoSurveyList = new Dictionary <Faction, bool>(); GeoTeamSurvey = false; SSEntity = StarSystemEntityType.Body; Primary = primary; Parent = parent; TaskGroupsInOrbit = new BindingList <TaskGroupTN>(); #warning planet generation needs minerals, anomalies, and ruins generation. PlanetaryRuins = new Ruins(); PlanetaryTectonics = Tectonics.Dead; /// <summary> /// Default mineral amount is zero. /// do mineral generation elsewhere. /// </summary> m_aiMinerialReserves = new float[Constants.Minerals.NO_OF_MINERIALS]; m_aiMinerialAccessibility = new float[Constants.Minerals.NO_OF_MINERIALS]; for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++) { m_aiMinerialReserves[mineralIterator] = 0.0f; m_aiMinerialAccessibility[mineralIterator] = 0.0f; } }
public SystemBody(OrbitingEntity parent, PlanetType type) : base() { /// <summary> /// create these or else anything that relies on a unique global id will break. /// </summary> Id = Guid.NewGuid(); Type = type; // set the type ASAP in case anthing needs to know it. Moons = new BindingList<SystemBody>(); Populations = new BindingList<Population>(); SSEntity = StarSystemEntityType.Body; Parent = parent; Position = parent.Position; TaskGroupsInOrbit = new BindingList<TaskGroupTN>(); GeoSurveyList = new Dictionary<Faction, bool>(); /// <summary> /// Default mineral amount is zero. /// do mineral generation elsewhere. /// </summary> m_aiMinerialReserves = new float[Constants.Minerals.NO_OF_MINERIALS]; m_aiMinerialAccessibility = new float[Constants.Minerals.NO_OF_MINERIALS]; for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++) { m_aiMinerialReserves[mineralIterator] = 0.0f; m_aiMinerialAccessibility[mineralIterator] = 0.0f; } #warning planet generation needs minerals, anomalies, and ruins generation. PlanetaryRuins = new Ruins(); Atmosphere = new Atmosphere(this); }
/// <summary> /// Adds a new taskgroup to the taskgroups list at location StartBody in System StartSystem. /// </summary> /// <param name="Title">Name.</param> /// <param name="StartBody">Body with population that built the ship that will be put into the TG.</param> /// <param name="StartSystem">System in which the TG starts in.</param> public void AddNewTaskGroup(String Title, OrbitingEntity StartBody, StarSystem StartSystem) { TaskGroupTN TG = new TaskGroupTN(Title, this, StartBody, StartSystem); TaskGroups.Add(TG); }
public GLCircle(GLEffect a_oEffect, Vector3 a_v3Pos, OrbitingEntity a_oOrbitEntity, System.Drawing.Color a_oColor, string a_szTexture = "") : base() { // Save some stuff to member vars: //double dKMperAUdevby10 = (Pulsar4X.Constants.Units.KM_PER_AU / 10); // we scale everthing down by 10 to avoid float buffer overflows. m_v3Position = a_v3Pos; m_v2Size.X = 1; // set verts to 360, looks good at any zoom. int iNumOfVerts = 360; //create our Vertex and index arrays: m_aoVerticies = new GLVertex[iNumOfVerts]; m_auiIndicies = new ushort[iNumOfVerts + 1]; // make this one longer so it can loop back around to the begining!! for (int i = 0; i < iNumOfVerts; ++i) { double dAngle = i * (MathHelper.TwoPi / iNumOfVerts); double x, y; a_oOrbitEntity.Orbit.GetPosition(dAngle, out x, out y); m_aoVerticies[i].m_v4Position.X = (float)x; m_aoVerticies[i].m_v4Position.Y = (float)y; m_aoVerticies[i].m_v4Position.Z = 0; m_aoVerticies[i].SetColor(a_oColor); m_auiIndicies[i] = (ushort)i; } // set last index: m_auiIndicies[iNumOfVerts] = 0; // Setup Matrix: m_m4ModelMatrix = Matrix4.Identity * Matrix4.CreateTranslation(a_v3Pos); // Set our shader program: m_oEffect = a_oEffect; // Load texture if specified: if (a_szTexture != "") { // We can assuem we have been provided with a texture to load: m_uiTextureID = Helpers.ResourceManager.Instance.LoadTexture(a_szTexture); } else { m_uiTextureID = 0; // set texture to none! } // tell Opgl about our VBOs: GL.GenVertexArrays(1, out m_uiVextexArrayHandle); // Generate Our Vertex Array and get the handle to it. GL.BindVertexArray(m_uiVextexArrayHandle); // Lets OpenGL that this is the current "active" vertex array. //#if DEBUG // logger.Info("OpenGL Generate VAO: " + GL.GetError().ToString()); //#endif GL.GenBuffers(1, out m_uiVertexBufferHandle); // Generate our Vertex Buffer Object and get the handle to it. GL.BindBuffer(BufferTarget.ArrayBuffer, m_uiVertexBufferHandle);// Lets Open GL know that this is the current active buffer object. GL.BufferData<GLVertex>(BufferTarget.ArrayBuffer, new IntPtr(m_aoVerticies.Length * GLVertex.SizeInBytes()), m_aoVerticies, BufferUsageHint.StaticDraw); // tells OpenGL about the structure of the data. //#if DEBUG // logger.Info("OpenGL Generate VBO: " + GL.GetError().ToString()); //#endif GL.GenBuffers(1, out m_uiIndexBufferHandle); //Generate Our index Buffer and get handle to it. GL.BindBuffer(BufferTarget.ElementArrayBuffer, m_uiIndexBufferHandle); // Lets Open GL know that this is the current active buffer object. GL.BufferData(BufferTarget.ElementArrayBuffer, new IntPtr(m_auiIndicies.Length * sizeof(ushort)), m_auiIndicies, BufferUsageHint.StaticDraw); // Tells OpenGL how the data is structured. //#if DEBUG // logger.Info("OpenGL Generate EBO: " + GL.GetError().ToString()); //#endif GL.BindBuffer(BufferTarget.ArrayBuffer, m_uiVertexBufferHandle); // Switch back to our Buffer Object as the current buffer. GL.VertexAttribPointer(0, 4, VertexAttribPointerType.Float, false, GLVertex.SizeInBytes(), 0); // Tells OpenGL about the first three doubles in the vbo, i.e the position of the vertex. GL.VertexAttribPointer(1, 4, VertexAttribPointerType.Float, true, GLVertex.SizeInBytes(), Vector4.SizeInBytes); // tells OpenGL about the 4 floats used to repesent color. GL.VertexAttribPointer(2, 2, VertexAttribPointerType.Float, false, GLVertex.SizeInBytes(), (Vector4.SizeInBytes + Vector4.SizeInBytes)); // tells OpenGL about the 2 floats in the vertgexc used to repesent UV coords. //#if DEBUG // logger.Info("OpenGL Create Vertes Attribute Pointers: " + GL.GetError().ToString()); //#endif // Turn on the Vertex Attribs: GL.EnableVertexAttribArray(0); GL.EnableVertexAttribArray(1); GL.EnableVertexAttribArray(2); // #if DEBUG // logger.Info("OpenGL Create Circle Primitive: " + GL.GetError().ToString()); //#endif }
/// <summary> /// Constructor for the taskgroup, sets name, faction, planet the TG starts in orbit of. /// </summary> /// <param name="Title">Name</param> /// <param name="FID">Faction</param> /// <param name="StartingBody">body taskgroup will orbit at creation.</param> public TaskGroupTN(string Title, Faction FID, OrbitingEntity StartingBody, StarSystem StartingSystem) { Name = Title; /// <summary> /// create these or else anything that relies on a unique global id will break. /// </summary> Id = Guid.NewGuid(); TaskGroupFaction = FID; IsOrbiting = true; OrbitingBody = StartingBody; (OrbitingBody as SystemBody).TaskGroupsInOrbit.Add(this); SSEntity = StarSystemEntityType.TaskGroup; Position.System = StartingSystem; Position.X = OrbitingBody.Position.X; Position.Y = OrbitingBody.Position.Y; Contact = new SystemContact(TaskGroupFaction, this); Contact.LastPosition.X = Contact.Position.X; Contact.LastPosition.Y = Contact.Position.Y; StartingSystem.SystemContactList.Add(Contact); DrawTravelLine = 3; CurrentSpeed = 1; MaxSpeed = 1; CurrentSpeedX = 0.0; CurrentSpeedY = 0.0; CurrentHeading = 0.0; TimeRequirement = 0; TaskGroupOrders = new BindingList<Order>(); TotalOrderDistance = 0.0; /// <summary> /// Change this for PDCS and starbases. /// </summary> CanOrder = Constants.ShipTN.OrderState.AcceptOrders; /// <summary> /// Ships start in the unordered state, so new orders will have to have GetHeading/speed/other functionality performed. /// </summary> NewOrders = true; Ships = new BindingList<ShipTN>(); ShipOutOfFuel = false; ActiveSensorQue = new BindingList<ActiveSensorTN>(); ActiveSensorCount = new BindingList<int>(); TaskGroupLookUpST = new BindingList<int>(); /// <summary> /// Resolution Max needs to go into global constants, or ship constants I think. /// </summary> for (int loop = 0; loop < Constants.ShipTN.ResolutionMax; loop++) { /// <summary> /// TaskGroupLookUpST will be initialized to zero. /// </summary> TaskGroupLookUpST.Add(0); } TaskGroupLookUpMT = new BindingList<int>(); for (int loop = 0; loop < 15; loop++) { /// <summary> /// TaskGroupLookUpMT will be initialized to zero. /// </summary> TaskGroupLookUpMT.Add(0); } BestThermalCount = 0; BestEMCount = 0; ThermalSortList = new LinkedList<int>(); EMSortList = new LinkedList<int>(); ActiveSortList = new LinkedList<int>(); TotalCargoTonnage = 0; CurrentCargoTonnage = 0; TotalCryoCapacity = 0; CurrentCryoStorage = 0; TaskGroupsOrdered = new BindingList<TaskGroupTN>(); TaskGroupPDL = new PointDefenseList(); IsInShipyard = false; SensorUpdateAck = 0; //add default legal order for targeting TGs. _legalOrders.Add(Constants.ShipTN.OrderType.Follow); _legalOrders.Add(Constants.ShipTN.OrderType.Join); _legalOrders.Add(Constants.ShipTN.OrderType.Absorb); _legalOrders.Add(Constants.ShipTN.OrderType.RefuelTargetFleet); _legalOrders.Add(Constants.ShipTN.OrderType.ResupplyTargetFleet); _legalOrders.Add(Constants.ShipTN.OrderType.ReloadTargetFleet); _legalOrders.Add(Constants.ShipTN.OrderType.LandOnAssignedMothership); _legalOrders.Add(Constants.ShipTN.OrderType.LandOnMotherShipNoAssign); _legalOrders.Add(Constants.ShipTN.OrderType.LandOnMothershipAssign); _legalOrders.Add(Constants.ShipTN.OrderType.TractorSpecifiedShip); _legalOrders.Add(Constants.ShipTN.OrderType.TractorSpecifiedShipyard); }