Esempio n. 1
0
 public static modMath.sXY_int GetRotatedPos(sTileOrientation Orientation, modMath.sXY_int Pos, modMath.sXY_int Limits)
 {
     modMath.sXY_int _int2;
     if (Orientation.SwitchedAxes)
     {
         if (Orientation.ResultXFlip)
         {
             _int2.X = Limits.Y - Pos.Y;
         }
         else
         {
             _int2.X = Pos.Y;
         }
         if (Orientation.ResultYFlip)
         {
             _int2.Y = Limits.X - Pos.X;
             return _int2;
         }
         _int2.Y = Pos.X;
         return _int2;
     }
     if (Orientation.ResultXFlip)
     {
         _int2.X = Limits.X - Pos.X;
     }
     else
     {
         _int2.X = Pos.X;
     }
     if (Orientation.ResultYFlip)
     {
         _int2.Y = Limits.Y - Pos.Y;
         return _int2;
     }
     _int2.Y = Pos.Y;
     return _int2;
 }
Esempio n. 2
0
 public bool Pos_Get_Screen_XY(Position.XYZ_dbl Pos, ref modMath.sXY_int Result)
 {
     if (Pos.Z > 0.0)
     {
         try
         {
             double num = 1.0 / (this.FOVMultiplier * Pos.Z);
             Result.X = (int) Math.Round((double) ((((double) this.MapView.GLSize.X) / 2.0) + (Pos.X * num)));
             Result.Y = (int) Math.Round((double) ((((double) this.MapView.GLSize.Y) / 2.0) - (Pos.Y * num)));
             return true;
         }
         catch (Exception exception1)
         {
             ProjectData.SetProjectError(exception1);
             ProjectData.ClearProjectError();
         }
     }
     return false;
 }
Esempio n. 3
0
 private bool MakePassageNodes(modMath.sXY_int Pos, bool IsOnBorder)
 {
     int num;
     modMath.sXY_int _int;
     modMath.sXY_int _int3;
     modMath.sXY_int[] _intArray = new modMath.sXY_int[4];
     _int3.X = (int) Math.Round((double) (((double) (this.TileSize.X * 0x80)) / ((double) this.SymmetryBlockCountXY.X)));
     _int3.Y = (int) Math.Round((double) (((double) (this.TileSize.Y * 0x80)) / ((double) this.SymmetryBlockCountXY.Y)));
     _int.X = _int3.X - 1;
     _int.Y = _int3.Y - 1;
     int num3 = this.SymmetryBlockCount - 1;
     for (num = 0; num <= num3; num++)
     {
         modMath.sXY_int _int2 = TileOrientation.GetRotatedPos(this.SymmetryBlocks[num].Orientation, Pos, _int);
         _intArray[num].X = (this.SymmetryBlocks[num].XYNum.X * _int3.X) + _int2.X;
         _intArray[num].Y = (this.SymmetryBlocks[num].XYNum.Y * _int3.Y) + _int2.Y;
         int num4 = num - 1;
         for (int i = 0; i <= num4; i++)
         {
             modMath.sXY_int _int4 = _intArray[num] - _intArray[i];
             if (_int4.ToDoubles().GetMagnitude() < ((this.NodeScale * 128f) * 2.0))
             {
                 return false;
             }
         }
     }
     int num5 = this.SymmetryBlockCount - 1;
     for (num = 0; num <= num5; num++)
     {
         clsPassageNode node = new clsPassageNode();
         this.PassageNodes[num, this.PassageNodeCount] = node;
         node.Num = this.PassageNodeCount;
         node.MirrorNum = num;
         node.Pos = _intArray[num];
         node.IsOnBorder = IsOnBorder;
     }
     this.PassageNodeCount++;
     return true;
 }
Esempio n. 4
0
 private PathfinderNode GetNearestNodeConnection(PathfinderNetwork Network, modMath.sXY_int Pos, int MinClearance, float MaxDistance)
 {
     PathfinderNode[] nodeArray = new PathfinderNode[((Network.get_GetNodeLayer(0).GetNodeCount * 10) - 1) + 1];
     float[] numArray = new float[(Network.get_GetNodeLayer(0).GetNodeCount - 1) + 1];
     int index = 0;
     PathfinderNode node = null;
     int num5 = Network.get_GetNodeLayer(0).GetNodeCount - 1;
     int num = 0;
     while (num <= num5)
     {
         numArray[num] = float.MaxValue;
         num++;
     }
     nodeArray[0] = this.GetNearestNode(Network, Pos, 1);
     if (nodeArray[0] == null)
     {
         return null;
     }
     int num3 = 1;
     numArray[nodeArray[0].Layer_NodeNum] = 0f;
     while (index < num3)
     {
         PathfinderNode self = nodeArray[index];
         if (self.Clearance >= MinClearance)
         {
             if (node == null)
             {
                 node = self;
             }
             else if (numArray[self.Layer_NodeNum] < numArray[node.Layer_NodeNum])
             {
                 node = self;
             }
         }
         int num6 = self.GetConnectionCount - 1;
         for (num = 0; num <= num6; num++)
         {
             bool flag;
             PathfinderConnection connection = self.get_GetConnection(num);
             PathfinderNode otherNode = connection.GetOtherNode(self);
             float num2 = numArray[self.Layer_NodeNum] + connection.GetValue;
             if (node == null)
             {
                 flag = true;
             }
             else if (num2 < numArray[node.Layer_NodeNum])
             {
                 flag = true;
             }
             else
             {
                 flag = false;
             }
             if (flag & (num2 < numArray[otherNode.Layer_NodeNum]))
             {
                 numArray[otherNode.Layer_NodeNum] = num2;
                 nodeArray[num3] = otherNode;
                 num3++;
             }
         }
         index++;
     }
     return node;
 }
Esempio n. 5
0
 public sWorldPos(modMath.sXY_int NewHorizontal, int NewAltitude)
 {
     this = new modProgram.sWorldPos();
     this.Horizontal = NewHorizontal;
     this.Altitude = NewAltitude;
 }
Esempio n. 6
0
 public void LookAtTile(modMath.sXY_int TileNum)
 {
     modMath.sXY_int _int;
     _int.X = (int) Math.Round((double) ((TileNum.X + 0.5) * 128.0));
     _int.Y = (int) Math.Round((double) ((TileNum.Y + 0.5) * 128.0));
     this.LookAtPos(_int);
 }
Esempio n. 7
0
 public bool IsViewPosOverMinimap(modMath.sXY_int Pos)
 {
     return ((((Pos.X >= 0) & (Pos.X < (((double) this.Map.Terrain.TileSize.X) / this.Tiles_Per_Minimap_Pixel))) & (Pos.Y >= 0)) & (Pos.Y < (((double) this.Map.Terrain.TileSize.Y) / this.Tiles_Per_Minimap_Pixel)));
 }
Esempio n. 8
0
 public void ViewPosChange(modMath.sXYZ_int Displacement)
 {
     this.ViewPos.X += Displacement.X;
     this.ViewPos.Z += Displacement.Z;
     this.ViewPos.Y += Displacement.Y;
     this.ViewPosClamp();
     this.MapView.DrawViewLater();
 }
Esempio n. 9
0
 public static void GetTileRotatedTexCoords(sTileOrientation TileOrientation, ref modMath.sXY_sng CoordA, ref modMath.sXY_sng CoordB, ref modMath.sXY_sng CoordC, ref modMath.sXY_sng CoordD)
 {
     sTileOrientation orientation = TileOrientation;
     orientation.Reverse();
     if (orientation.SwitchedAxes)
     {
         if (orientation.ResultXFlip)
         {
             CoordA.X = 1f;
             CoordB.X = 1f;
             CoordC.X = 0f;
             CoordD.X = 0f;
         }
         else
         {
             CoordA.X = 0f;
             CoordB.X = 0f;
             CoordC.X = 1f;
             CoordD.X = 1f;
         }
         if (orientation.ResultYFlip)
         {
             CoordA.Y = 1f;
             CoordB.Y = 0f;
             CoordC.Y = 1f;
             CoordD.Y = 0f;
         }
         else
         {
             CoordA.Y = 0f;
             CoordB.Y = 1f;
             CoordC.Y = 0f;
             CoordD.Y = 1f;
         }
     }
     else
     {
         if (orientation.ResultXFlip)
         {
             CoordA.X = 1f;
             CoordB.X = 0f;
             CoordC.X = 1f;
             CoordD.X = 0f;
         }
         else
         {
             CoordA.X = 0f;
             CoordB.X = 1f;
             CoordC.X = 0f;
             CoordD.X = 1f;
         }
         if (orientation.ResultYFlip)
         {
             CoordA.Y = 1f;
             CoordB.Y = 1f;
             CoordC.Y = 0f;
             CoordD.Y = 0f;
         }
         else
         {
             CoordA.Y = 0f;
             CoordB.Y = 0f;
             CoordC.Y = 1f;
             CoordD.Y = 1f;
         }
     }
 }
Esempio n. 10
0
 public static modMath.sXY_sng GetTileRotatedPos_sng(sTileOrientation TileOrientation, modMath.sXY_sng Pos)
 {
     modMath.sXY_sng _sng2;
     if (TileOrientation.SwitchedAxes)
     {
         if (TileOrientation.ResultXFlip)
         {
             _sng2.X = 1f - Pos.Y;
         }
         else
         {
             _sng2.X = Pos.Y;
         }
         if (TileOrientation.ResultYFlip)
         {
             _sng2.Y = 1f - Pos.X;
             return _sng2;
         }
         _sng2.Y = Pos.X;
         return _sng2;
     }
     if (TileOrientation.ResultXFlip)
     {
         _sng2.X = 1f - Pos.X;
     }
     else
     {
         _sng2.X = Pos.X;
     }
     if (TileOrientation.ResultYFlip)
     {
         _sng2.Y = 1f - Pos.Y;
         return _sng2;
     }
     _sng2.Y = Pos.Y;
     return _sng2;
 }
Esempio n. 11
0
 private void PerformAction(clsMap.clsAction Action, sPosNum PosNum, modMath.sXY_int LastValidNum)
 {
     if (Action.Map == null)
     {
         Debugger.Break();
     }
     else
     {
         modMath.sXY_int posNum = this.GetPosNum(PosNum);
         Action.Effect = 1.0;
         int introduced11 = modMath.Clamp_int(this.Tiles.YMin + posNum.Y, 0, LastValidNum.Y);
         int introduced12 = modMath.Clamp_int(this.Tiles.YMax + posNum.Y, 0, LastValidNum.Y);
         int num4 = introduced12 - posNum.Y;
         for (int i = introduced11 - posNum.Y; i <= num4; i++)
         {
             Action.PosNum.Y = posNum.Y + i;
             int index = i - this.Tiles.YMin;
             int introduced13 = modMath.Clamp_int(this.Tiles.XMin[index] + posNum.X, 0, LastValidNum.X);
             int introduced14 = modMath.Clamp_int(this.Tiles.XMax[index] + posNum.X, 0, LastValidNum.X);
             int num5 = introduced14 - posNum.X;
             for (int j = introduced13 - posNum.X; j <= num5; j++)
             {
                 modMath.sXY_int _int2;
                 Action.PosNum.X = posNum.X + j;
                 if (Action.UseEffect && (this.Tiles.ResultRadius > 0.0))
                 {
                     switch (this._Shape)
                     {
                         case enumShape.Circle:
                         {
                             if (!this._Alignment)
                             {
                                 goto Label_01DD;
                             }
                             Position.XY_dbl _dbl = new Position.XY_dbl((double) Action.PosNum.X, (double) Action.PosNum.Y);
                             Position.XY_dbl _dbl2 = new Position.XY_dbl(posNum.X - 0.5, posNum.Y - 0.5);
                             Position.XY_dbl _dbl3 = _dbl - _dbl2;
                             Action.Effect = 1.0 - (_dbl3.GetMagnitude() / (this.Tiles.ResultRadius + 0.5));
                             break;
                         }
                         case enumShape.Square:
                         {
                             if (!this._Alignment)
                             {
                                 goto Label_02A3;
                             }
                             double introduced15 = Math.Abs((double) (Action.PosNum.X - (posNum.X - 0.5)));
                             Action.Effect = 1.0 - (Math.Max(introduced15, Math.Abs((double) (Action.PosNum.Y - (posNum.Y - 0.5)))) / (this.Tiles.ResultRadius + 0.5));
                             break;
                         }
                     }
                 }
                 goto Label_02FF;
             Label_01DD:
                 _int2 = posNum - Action.PosNum;
                 Action.Effect = 1.0 - (_int2.ToDoubles().GetMagnitude() / (this.Tiles.ResultRadius + 0.5));
                 goto Label_02FF;
             Label_02A3:
                 int introduced16 = Math.Abs((int) (Action.PosNum.X - posNum.X));
                 Action.Effect = 1.0 - (((double) Math.Max(introduced16, Math.Abs((int) (Action.PosNum.Y - posNum.Y)))) / (this.Tiles.ResultRadius + 0.5));
             Label_02FF:
                 Action.ActionPerform();
             }
         }
     }
 }
Esempio n. 12
0
 public clsXY_int(modMath.sXY_int XY)
 {
     this.XY = XY;
 }
Esempio n. 13
0
 public bool IsInRange(modMath.sXY_int Minimum, modMath.sXY_int Maximum)
 {
     return ((((this.X >= Minimum.X) & (this.X <= Maximum.X)) & (this.Y >= Minimum.Y)) & (this.Y <= Maximum.Y));
 }
Esempio n. 14
0
 public static modMath.sXY_int Min(modMath.sXY_int a, modMath.sXY_int b)
 {
     modMath.sXY_int _int2;
     _int2.X = Math.Min(a.X, b.X);
     _int2.Y = Math.Min(a.Y, b.Y);
     return _int2;
 }
Esempio n. 15
0
 private void SelectUnits(modMath.sXY_int VertexA, modMath.sXY_int VertexB)
 {
     clsMap.clsUnit unit;
     clsMap mainMap = this.MainMap;
     clsViewInfo.clsMouseOver.clsOverTerrain mouseOverTerrain = mainMap.ViewInfo.GetMouseOverTerrain();
     if (((Math.Abs((int) (VertexA.X - VertexB.X)) <= 1) & (Math.Abs((int) (VertexA.Y - VertexB.Y)) <= 1)) & (mouseOverTerrain != null))
     {
         if (mouseOverTerrain.Units.Count > 0)
         {
             if (mouseOverTerrain.Units.Count == 1)
             {
                 unit = mouseOverTerrain.Units[0];
                 if (unit.MapSelectedUnitLink.IsConnected)
                 {
                     unit.MapDeselect();
                 }
                 else
                 {
                     unit.MapSelect();
                 }
             }
             else
             {
                 this.ListSelectBegin(false);
             }
         }
     }
     else
     {
         modMath.sXY_int _int;
         modMath.sXY_int _int2;
         modMath.sXY_int _int3;
         modMath.sXY_int _int4;
         modMath.sXY_int _int5;
         modMath.sXY_int _int6;
         modMath.sXY_int _int7;
         modMath.ReorderXY(VertexA, VertexB, ref _int7, ref _int2);
         _int6.X = _int7.X * 0x80;
         _int6.Y = _int7.Y * 0x80;
         _int.X = _int2.X * 0x80;
         _int.Y = _int2.Y * 0x80;
         _int5.X = Math.Min((int) Math.Round(((double) (((double) _int7.X) / 8.0))), mainMap.SectorCount.X - 1);
         _int5.Y = Math.Min((int) Math.Round(((double) (((double) _int7.Y) / 8.0))), mainMap.SectorCount.Y - 1);
         _int3.X = Math.Min((int) Math.Round(((double) (((double) _int2.X) / 8.0))), mainMap.SectorCount.X - 1);
         _int3.Y = Math.Min((int) Math.Round(((double) (((double) _int2.Y) / 8.0))), mainMap.SectorCount.Y - 1);
         int y = _int3.Y;
         _int4.Y = _int5.Y;
         while (_int4.Y <= y)
         {
             int x = _int3.X;
             _int4.X = _int5.X;
             while (_int4.X <= x)
             {
                 IEnumerator enumerator;
                 try
                 {
                     enumerator = mainMap.Sectors[_int4.X, _int4.Y].Units.GetEnumerator();
                     while (enumerator.MoveNext())
                     {
                         clsMap.clsUnitSectorConnection current = (clsMap.clsUnitSectorConnection) enumerator.Current;
                         unit = current.Unit;
                         if (((((unit.Pos.Horizontal.X >= _int6.X) & (unit.Pos.Horizontal.Y >= _int6.Y)) & (unit.Pos.Horizontal.X <= _int.X)) & (unit.Pos.Horizontal.Y <= _int.Y)) && !unit.MapSelectedUnitLink.IsConnected)
                         {
                             unit.MapSelect();
                         }
                     }
                 }
                 finally
                 {
                     if (enumerator is IDisposable)
                     {
                         (enumerator as IDisposable).Dispose();
                     }
                 }
                 _int4.X++;
             }
             _int4.Y++;
         }
     }
     modMain.frmMainInstance.SelectedObject_Changed();
     this.DrawViewLater();
 }
Esempio n. 16
0
 public bool ScreenXY_Get_TerrainPos(modMath.sXY_int ScreenPos, ref modProgram.sWorldPos ResultPos)
 {
     try
     {
         Position.XYZ_dbl _dbl;
         Position.XY_dbl _dbl3;
         Position.XY_dbl _dbl4;
         modMath.sXY_int _int;
         modMath.sXY_int _int2;
         Position.XYZ_dbl _dbl5;
         Position.XYZ_dbl _dbl6;
         Position.XYZ_dbl _dbl8;
         _dbl5.X = this.ViewPos.X;
         _dbl5.Y = this.ViewPos.Y;
         _dbl5.Z = 0 - this.ViewPos.Z;
         _dbl8.X = (ScreenPos.X - (((double) this.MapView.GLSize.X) / 2.0)) * this.FOVMultiplier;
         _dbl8.Y = ((((double) this.MapView.GLSize.Y) / 2.0) - ScreenPos.Y) * this.FOVMultiplier;
         _dbl8.Z = 1.0;
         Matrix3DMath.VectorRotationByMatrix(this.ViewAngleMatrix, _dbl8, ref _dbl6);
         _dbl6.Y = -_dbl6.Y;
         _dbl6.Z = -_dbl6.Z;
         double num2 = (_dbl5.Y - (0xff * this.Map.HeightMultiplier)) / _dbl6.Y;
         _dbl3.X = _dbl5.X + (_dbl6.X * num2);
         _dbl3.Y = _dbl5.Z + (_dbl6.Z * num2);
         num2 = _dbl5.Y / _dbl6.Y;
         _dbl4.X = _dbl5.X + (_dbl6.X * num2);
         _dbl4.Y = _dbl5.Z + (_dbl6.Z * num2);
         _int2.X = Math.Max((int) Math.Round(Conversion.Int((double) (Math.Min(_dbl3.X, _dbl4.X) / 128.0))), 0);
         _int2.Y = Math.Max((int) Math.Round(Conversion.Int((double) (Math.Min(_dbl3.Y, _dbl4.Y) / 128.0))), 0);
         _int.X = Math.Min((int) Math.Round(Conversion.Int((double) (Math.Max(_dbl3.X, _dbl4.X) / 128.0))), this.Map.Terrain.TileSize.X - 1);
         _int.Y = Math.Min((int) Math.Round(Conversion.Int((double) (Math.Max(_dbl3.Y, _dbl4.Y) / 128.0))), this.Map.Terrain.TileSize.Y - 1);
         double maxValue = double.MaxValue;
         _dbl.X = double.NaN;
         _dbl.Y = double.NaN;
         _dbl.Z = double.NaN;
         int y = _int.Y;
         for (int i = _int2.Y; i <= y; i++)
         {
             int x = _int.X;
             for (int j = _int2.X; j <= x; j++)
             {
                 Position.XYZ_dbl _dbl2;
                 double magnitude;
                 double num4;
                 double num5;
                 Position.XY_dbl _dbl7;
                 double num6;
                 double num7;
                 double num8;
                 _dbl7.X = j * 0x80;
                 _dbl7.Y = i * 0x80;
                 if (this.Map.Terrain.Tiles[j, i].Tri)
                 {
                     num8 = this.Map.Terrain.Vertices[j, i].Height * this.Map.HeightMultiplier;
                     num6 = (this.Map.Terrain.Vertices[j + 1, i].Height * this.Map.HeightMultiplier) - num8;
                     num7 = (this.Map.Terrain.Vertices[j, i + 1].Height * this.Map.HeightMultiplier) - num8;
                     _dbl8.Y = (num8 + ((((num6 * (_dbl5.X - _dbl7.X)) + (num7 * (_dbl5.Z - _dbl7.Y))) + ((((num6 * _dbl6.X) + (num7 * _dbl6.Z)) * _dbl5.Y) / _dbl6.Y)) / 128.0)) / (1.0 + (((num6 * _dbl6.X) + (num7 * _dbl6.Z)) / (_dbl6.Y * 128.0)));
                     _dbl8.X = _dbl5.X + ((_dbl6.X * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     _dbl8.Z = _dbl5.Z + ((_dbl6.Z * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     num4 = (_dbl8.X / 128.0) - j;
                     num5 = (_dbl8.Z / 128.0) - i;
                     if (((((num5 <= (1.0 - num4)) & (num4 >= 0.0)) & (num5 >= 0.0)) & (num4 <= 1.0)) & (num5 <= 1.0))
                     {
                         _dbl2 = _dbl8 - _dbl5;
                         magnitude = _dbl2.GetMagnitude();
                         if (magnitude < maxValue)
                         {
                             maxValue = magnitude;
                             _dbl = _dbl8;
                         }
                     }
                     num8 = this.Map.Terrain.Vertices[j + 1, i + 1].Height * this.Map.HeightMultiplier;
                     num6 = (this.Map.Terrain.Vertices[j, i + 1].Height * this.Map.HeightMultiplier) - num8;
                     num7 = (this.Map.Terrain.Vertices[j + 1, i].Height * this.Map.HeightMultiplier) - num8;
                     _dbl8.Y = (((num8 + num6) + num7) + ((((num6 * (_dbl7.X - _dbl5.X)) + (num7 * (_dbl7.Y - _dbl5.Z))) - ((((num6 * _dbl6.X) + (num7 * _dbl6.Z)) * _dbl5.Y) / _dbl6.Y)) / 128.0)) / (1.0 - (((num6 * _dbl6.X) + (num7 * _dbl6.Z)) / (_dbl6.Y * 128.0)));
                     _dbl8.X = _dbl5.X + ((_dbl6.X * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     _dbl8.Z = _dbl5.Z + ((_dbl6.Z * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     num4 = (_dbl8.X / 128.0) - j;
                     num5 = (_dbl8.Z / 128.0) - i;
                     if (((((num5 >= (1.0 - num4)) & (num4 >= 0.0)) & (num5 >= 0.0)) & (num4 <= 1.0)) & (num5 <= 1.0))
                     {
                         _dbl2 = _dbl8 - _dbl5;
                         magnitude = _dbl2.GetMagnitude();
                         if (magnitude < maxValue)
                         {
                             maxValue = magnitude;
                             _dbl = _dbl8;
                         }
                     }
                 }
                 else
                 {
                     num8 = this.Map.Terrain.Vertices[j + 1, i].Height * this.Map.HeightMultiplier;
                     num6 = (this.Map.Terrain.Vertices[j, i].Height * this.Map.HeightMultiplier) - num8;
                     num7 = (this.Map.Terrain.Vertices[j + 1, i + 1].Height * this.Map.HeightMultiplier) - num8;
                     _dbl8.Y = ((num8 + num6) + ((((num6 * (_dbl7.X - _dbl5.X)) + (num7 * (_dbl5.Z - _dbl7.Y))) - ((((num6 * _dbl6.X) - (num7 * _dbl6.Z)) * _dbl5.Y) / _dbl6.Y)) / 128.0)) / (1.0 - (((num6 * _dbl6.X) - (num7 * _dbl6.Z)) / (_dbl6.Y * 128.0)));
                     _dbl8.X = _dbl5.X + ((_dbl6.X * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     _dbl8.Z = _dbl5.Z + ((_dbl6.Z * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     num4 = (_dbl8.X / 128.0) - j;
                     num5 = (_dbl8.Z / 128.0) - i;
                     if (((((num5 <= num4) & (num4 >= 0.0)) & (num5 >= 0.0)) & (num4 <= 1.0)) & (num5 <= 1.0))
                     {
                         _dbl2 = _dbl8 - _dbl5;
                         magnitude = _dbl2.GetMagnitude();
                         if (magnitude < maxValue)
                         {
                             maxValue = magnitude;
                             _dbl = _dbl8;
                         }
                     }
                     num8 = this.Map.Terrain.Vertices[j, i + 1].Height * this.Map.HeightMultiplier;
                     num6 = (this.Map.Terrain.Vertices[j + 1, i + 1].Height * this.Map.HeightMultiplier) - num8;
                     num7 = (this.Map.Terrain.Vertices[j, i].Height * this.Map.HeightMultiplier) - num8;
                     _dbl8.Y = ((num8 + num7) + ((((num6 * (_dbl5.X - _dbl7.X)) + (num7 * (_dbl7.Y - _dbl5.Z))) + ((((num6 * _dbl6.X) - (num7 * _dbl6.Z)) * _dbl5.Y) / _dbl6.Y)) / 128.0)) / (1.0 + (((num6 * _dbl6.X) - (num7 * _dbl6.Z)) / (_dbl6.Y * 128.0)));
                     _dbl8.X = _dbl5.X + ((_dbl6.X * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     _dbl8.Z = _dbl5.Z + ((_dbl6.Z * (_dbl5.Y - _dbl8.Y)) / _dbl6.Y);
                     num4 = (_dbl8.X / 128.0) - j;
                     num5 = (_dbl8.Z / 128.0) - i;
                     if (((((num5 >= num4) & (num4 >= 0.0)) & (num5 >= 0.0)) & (num4 <= 1.0)) & (num5 <= 1.0))
                     {
                         magnitude = (_dbl8 - _dbl5).GetMagnitude();
                         if (magnitude < maxValue)
                         {
                             maxValue = magnitude;
                             _dbl = _dbl8;
                         }
                     }
                 }
             }
         }
         if (_dbl.X == double.NaN)
         {
             return false;
         }
         ResultPos.Horizontal.X = (int) Math.Round(_dbl.X);
         ResultPos.Altitude = (int) Math.Round(_dbl.Y);
         ResultPos.Horizontal.Y = (int) Math.Round(_dbl.Z);
     }
     catch (Exception exception1)
     {
         ProjectData.SetProjectError(exception1);
         ProjectData.ClearProjectError();
         return false;
     }
     return true;
 }
Esempio n. 17
0
 public bool ScreenXY_Get_ViewPlanePos(modMath.sXY_int ScreenPos, double PlaneHeight, ref Position.XY_dbl ResultPos)
 {
     try
     {
         Position.XYZ_dbl _dbl;
         Position.XYZ_dbl _dbl2;
         _dbl.X = (ScreenPos.X - (((double) this.MapView.GLSize.X) / 2.0)) * this.FOVMultiplier;
         _dbl.Y = ((((double) this.MapView.GLSize.Y) / 2.0) - ScreenPos.Y) * this.FOVMultiplier;
         _dbl.Z = 1.0;
         Matrix3DMath.VectorRotationByMatrix(this.ViewAngleMatrix, _dbl, ref _dbl2);
         double num = (PlaneHeight - this.ViewPos.Y) / _dbl2.Y;
         ResultPos.X = this.ViewPos.X + (_dbl2.X * num);
         ResultPos.Y = this.ViewPos.Z + (_dbl2.Z * num);
     }
     catch (Exception exception1)
     {
         ProjectData.SetProjectError(exception1);
         ProjectData.ClearProjectError();
         return false;
     }
     return true;
 }
Esempio n. 18
0
 public static modMath.sXY_int GetTileRotatedOffset(sTileOrientation TileOrientation, modMath.sXY_int Pos)
 {
     modMath.sXY_int _int2;
     if (TileOrientation.SwitchedAxes)
     {
         if (TileOrientation.ResultXFlip)
         {
             _int2.X = 0x80 - Pos.Y;
         }
         else
         {
             _int2.X = Pos.Y;
         }
         if (TileOrientation.ResultYFlip)
         {
             _int2.Y = 0x80 - Pos.X;
             return _int2;
         }
         _int2.Y = Pos.X;
         return _int2;
     }
     if (TileOrientation.ResultXFlip)
     {
         _int2.X = 0x80 - Pos.X;
     }
     else
     {
         _int2.X = Pos.X;
     }
     if (TileOrientation.ResultYFlip)
     {
         _int2.Y = 0x80 - Pos.Y;
         return _int2;
     }
     _int2.Y = Pos.Y;
     return _int2;
 }
Esempio n. 19
0
 public void ViewPosSet(modMath.sXYZ_int NewViewPos)
 {
     this.ViewPos = NewViewPos;
     this.ViewPosClamp();
     this.MapView.DrawViewLater();
 }
Esempio n. 20
0
 public PathfinderNode GetNearestNode(PathfinderNetwork Network, modMath.sXY_int Pos, int MinClearance)
 {
     double maxValue = double.MaxValue;
     PathfinderNode node = null;
     int num4 = Network.get_GetNodeLayer(0).GetNodeCount - 1;
     for (int i = 0; i <= num4; i++)
     {
         PathfinderNode node3 = Network.get_GetNodeLayer(0).get_GetNode(i);
         if (node3.GetClearance >= MinClearance)
         {
             clsNodeTag tag = (clsNodeTag) node3.Tag;
             modMath.sXY_int _int = tag.Pos - Pos;
             double magnitude = _int.ToDoubles().GetMagnitude();
             if (magnitude < maxValue)
             {
                 maxValue = magnitude;
                 node = node3;
             }
         }
     }
     return node;
 }
Esempio n. 21
0
 public void LookAtPos(modMath.sXY_int Horizontal)
 {
     Position.XYZ_dbl _dbl;
     modMath.sXYZ_int _int;
     Matrix3DMath.Matrix3D matrix = new Matrix3DMath.Matrix3D();
     Matrix3DMath.VectorForwardsRotationByMatrix(this.ViewAngleMatrix, ref _dbl);
     double terrainHeight = this.Map.GetTerrainHeight(Horizontal);
     int num = ((int) Math.Round(Math.Ceiling(terrainHeight))) + 0x80;
     if (this.ViewPos.Y < num)
     {
         this.ViewPos.Y = num;
     }
     if (_dbl.Y > -0.33333333333333331)
     {
         Angles.AnglePY epy;
         _dbl.Y = -0.33333333333333331;
         Matrix3DMath.VectorToPY(_dbl, ref epy);
         Matrix3DMath.MatrixSetToPY(matrix, epy);
         this.ViewAngleSet(matrix);
     }
     terrainHeight = (this.ViewPos.Y - terrainHeight) / _dbl.Y;
     _int.X = (int) Math.Round((double) (Horizontal.X + (terrainHeight * _dbl.X)));
     _int.Y = this.ViewPos.Y;
     _int.Z = (int) Math.Round((double) ((0 - Horizontal.Y) + (terrainHeight * _dbl.Z)));
     this.ViewPosSet(_int);
 }
Esempio n. 22
0
 public clsMap.clsUnit PlaceUnitNear(clsUnitType Type, modMath.sXY_int Pos, clsMap.clsUnitGroup UnitGroup, int Clearance, int Rotation, int MaxDistFromPos)
 {
     modMath.sXY_int _int;
     modMath.sXY_int _int3;
     modMath.sXY_int _int4;
     PathfinderNode node = this.GetNearestNodeConnection(this.TilePathMap, Pos, Clearance, (float) MaxDistFromPos);
     if (node == null)
     {
         return null;
     }
     clsNodeTag tag = (clsNodeTag) node.Tag;
     modMath.sXY_int _int5 = Pos - tag.Pos;
     if (_int5.ToDoubles().GetMagnitude() > MaxDistFromPos)
     {
         return null;
     }
     clsMap.clsUnitAdd add = new clsMap.clsUnitAdd {
         Map = this.Map,
         StoreChange = true
     };
     clsMap.clsUnit unit2 = new clsMap.clsUnit();
     add.NewUnit = unit2;
     unit2.Type = Type;
     unit2.UnitGroup = UnitGroup;
     _int.X = (int) Math.Round(((double) (((double) tag.Pos.X) / 128.0)));
     _int.Y = (int) Math.Round(((double) (((double) tag.Pos.Y) / 128.0)));
     modMath.sXY_int _int2 = Type.get_GetFootprintSelected(Rotation);
     int num = _int2.X % 2;
     if (num > 0)
     {
         unit2.Pos.Horizontal.X = tag.Pos.X;
     }
     else if (App.Random.Next() >= 0.5f)
     {
         unit2.Pos.Horizontal.X = tag.Pos.X - 0x40;
     }
     else
     {
         unit2.Pos.Horizontal.X = tag.Pos.X + 0x40;
     }
     num = _int2.Y % 2;
     if (num > 0)
     {
         unit2.Pos.Horizontal.Y = tag.Pos.Y;
     }
     else if (App.Random.Next() >= 0.5f)
     {
         unit2.Pos.Horizontal.Y = tag.Pos.Y - 0x40;
     }
     else
     {
         unit2.Pos.Horizontal.Y = tag.Pos.Y + 0x40;
     }
     _int3.X = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.X) / 128.0) - (((double) _int2.X) / 2.0)) + 0.5)));
     _int3.Y = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.Y) / 128.0) - (((double) _int2.Y) / 2.0)) + 0.5)));
     _int4.X = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.X) / 128.0) + (((double) _int2.X) / 2.0)) - 0.5)));
     _int4.Y = (int) Math.Round(((double) (((((double) unit2.Pos.Horizontal.Y) / 128.0) + (((double) _int2.Y) / 2.0)) - 0.5)));
     unit2.Rotation = Rotation;
     add.Perform();
     int num4 = Math.Min(_int4.Y, this.Map.Terrain.TileSize.Y - 1);
     for (int i = Math.Max(_int3.Y, 0); i <= num4; i++)
     {
         int num5 = Math.Min(_int4.X, this.Map.Terrain.TileSize.X - 1);
         for (int j = Math.Max(_int3.X, 0); j <= num5; j++)
         {
             this.TileNodeBlock(j, i);
         }
     }
     this.TilePathMap.FindCalc();
     return unit2;
 }
Esempio n. 23
0
 private void SetScrollLimits(ref modMath.sXY_int Min, ref modMath.sXY_uint Max)
 {
     Min.X = 0;
     Min.Y = 0;
     Max.X = (uint) this.Map.Terrain.TileSize.X;
     Max.Y = (uint) this.Map.Terrain.TileSize.Y;
     if (!this.cbxAutoScrollLimits.Checked)
     {
         modIO.InvariantParse_int(this.txtScrollMinX.Text, ref Min.X);
         modIO.InvariantParse_int(this.txtScrollMinY.Text, ref Min.Y);
         modIO.InvariantParse_uint(this.txtScrollMaxX.Text, ref Max.X);
         modIO.InvariantParse_uint(this.txtScrollMaxY.Text, ref Max.Y);
     }
 }
Esempio n. 24
0
 public static bool PosIsWithinTileArea(modMath.sXY_int WorldHorizontal, modMath.sXY_int StartTile, modMath.sXY_int FinishTile)
 {
     return ((((WorldHorizontal.X >= (StartTile.X * 0x80)) & (WorldHorizontal.Y >= (StartTile.Y * 0x80))) & (WorldHorizontal.X < (FinishTile.X * 0x80))) & (WorldHorizontal.Y < (FinishTile.Y * 0x80)));
 }