コード例 #1
0
ファイル: SprinklerEx.cs プロジェクト: Robobeurre/NRaas
 public static void SpawnPuddles(Sprinkler sprinkler)
 {           
     // this calls SetPuddles(true) in the core
     bool set = true;
     LotLocation location = new LotLocation();
     ulong lotLocation = World.GetLotLocation(sprinkler.PositionOnFloor, ref location);
     int num2 = (int)(Math.Sqrt(2.0) * Sprinkler.kRangeOfSpray);
     Vector2[] vectorArray = new Vector2[4];
     for (int i = 0; i <= 3; i++)
     {
         vectorArray[i].x = sprinkler.mDiscourageFootprintPoints[i].x;
         vectorArray[i].y = sprinkler.mDiscourageFootprintPoints[i].z;
     }
     Vector2 vector = new Vector2(vectorArray[1].x - vectorArray[0].x, vectorArray[1].y - vectorArray[0].y);
     Vector2 vector2 = new Vector2(vectorArray[3].x - vectorArray[0].x, vectorArray[3].y - vectorArray[0].y);
     float num4 = vector.Length();
     vector.Normalize();
     vector2.Normalize();
     Vector3 worldPos = new Vector3();
     Vector2 vector4 = new Vector2();
     LotLocation location2 = new LotLocation();
     short startingRoomId = World.GetRoomId(lotLocation, location, eRoomDefinition.LightBlocking);
     for (int j = location.mX - num2; j <= (location.mX + num2); j++)
     {
         for (int k = location.mZ - num2; k <= (location.mZ + num2); k++)
         {
             location2.mX = j;
             location2.mZ = k;
             location2.mLevel = location.mLevel;
             location2.mRoom = location.mRoom;
             World.GetWorldPosition(lotLocation, location2, ref worldPos);
             vector4.x = worldPos.x - vectorArray[0].x;
             vector4.y = worldPos.z - vectorArray[0].y;
             float num8 = (float)(vector4 * vector);
             float num9 = (float)(vector4 * vector2);
             if (((num8 >= 0f) && (num8 <= num4)) && ((num9 >= 0f) && (num9 <= num4)))
             {
                 PlacePuddleIfSprayableEx(lotLocation, location2, worldPos, set, startingRoomId);
             }
         }
     }
 }
コード例 #2
0
ファイル: Vector2.cs プロジェクト: granthess/S3ToolKit.Utils
 public static Vector2 Normalize(Vector2 vec, out float length)
 {
     length = vec.Length();
     if (Math.Abs(length) < 1E-05f)
     {
         return Vector2.Zero;
     }
     float num = 1f / length;
     return new Vector2(vec.x * num, vec.y * num);
 }