Example #1
0
    static int Equals(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <GameVersion>(L, 2))
            {
                GameVersion obj  = (GameVersion)ToLua.CheckObject <GameVersion>(L, 1);
                GameVersion arg0 = (GameVersion)ToLua.ToObject(L, 2);
                bool        o    = obj != null?obj.Equals(arg0) : arg0 == null;

                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <object>(L, 2))
            {
                GameVersion obj  = (GameVersion)ToLua.CheckObject <GameVersion>(L, 1);
                object      arg0 = ToLua.ToVarObject(L, 2);
                bool        o    = obj != null?obj.Equals(arg0) : arg0 == null;

                LuaDLL.lua_pushboolean(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: GameVersion.Equals"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #2
0
        public void EqualityWorksCorrectly(GameVersion a, GameVersion b, bool areEqual)
        {
            // Act
            var genericEquality            = a.Equals(b);
            var nonGenericEquality         = a.Equals((object)b);
            var operatorEquality           = a == b;
            var operatorInequality         = a != b;
            var genericReferenceEquality   = a.Equals(a);
            var nonGenericRefereneEquality = a.Equals((object)a);

            // Assert
            Assert.AreEqual(areEqual, genericEquality);
            Assert.AreEqual(areEqual, nonGenericEquality);
            Assert.AreEqual(areEqual, operatorEquality);
            Assert.AreNotEqual(areEqual, operatorInequality);
            Assert.IsTrue(genericReferenceEquality);
            Assert.IsTrue(nonGenericRefereneEquality);
        }
Example #3
0
 /// <summary>
 /// Changes the current game version to the desired game version.
 /// </summary>
 /// <param name="newVersion"></param>
 public void ChangeGameVersion(GameVersion newVersion)
 {
     foreach (GameVersionSettings gameVersionSetting in GameVersionSettings)
     {
         if (newVersion.Equals(gameVersionSetting.Game_Version))
         {
             current_GameVersionSettings = gameVersionSetting;
             return;
         }
     }
 }
Example #4
0
        public override bool SingleVersionsCompatible(GameVersion gameVersion, CkanModule module)
        {
            // Otherwise, check if it's "generally recognise as safe".

            // If we're running KSP 1.0.4, then allow the mod to run if we would have
            // considered it compatible under 1.0.3 (as 1.0.4 was "just a hotfix").
            if (gameVersion.Equals(v104))
            {
                return(strict.SingleVersionsCompatible(v103, module));
            }

            return(false);
        }
Example #5
0
    public bool Equals(World other)
    {
        bool eq = Id == other.Id &&
                  Name.Equals(other.Name) &&
                  WorldVersion.Equals(other.WorldVersion) &&
                  GameVersion.Equals(other.GameVersion) &&
                  AuthorId == other.AuthorId;

        if (eq)
        {
            foreach (KeyValuePair <int, Cell> entry in this.DefaultCells)
            {
                if (!(other.DefaultCells.ContainsKey(entry.Key) &&
                      other.DefaultCells[entry.Key].Equals(entry.Value)))
                {
                    Debug.Log("Default Cells " + entry);
                    return(false);
                }
            }
        }

        if (eq)
        {
            foreach (KeyValuePair <Coordinates, Cell> entry in this.Map)
            {
                if (!(other.Map.ContainsKey(entry.Key) &&
                      other.Map[entry.Key].Equals(entry.Value)))
                {
                    Debug.Log("Map " + entry);
                    return(false);
                }
            }
            return(true);
        }
        return(false);
    }