usingSystem;namespaceJEngine.AntiCheat{publicclassJRandom{privatestaticRandom _random =newRandom();privateJRandom(){}publicstaticintRandomNum(int max =1024){return _random.Next(0, max <0?1024: max);}}}
//// JInt.cs//// Author:// JasonXuDeveloper(傑) <jasonxudeveloper@gmail.com>//// Copyright (c) 2020 JEngine//// Permission is hereby granted, free of charge, to any person obtaining a copy// of this software and associated documentation files (the "Software"), to deal// in the Software without restriction, including without limitation the rights// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell// copies of the Software, and to permit persons to whom the Software is// furnished to do so, subject to the following conditions://// The above copyright notice and this permission notice shall be included in// all copies or substantial portions of the Software.//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN// THE SOFTWARE.namespaceJEngine.AntiCheat{publicstructJInt{internalint ObscuredInt;internalint ObscuredKey;internalint OriginalValue;privateint Value
{get{var result = ObscuredInt - ObscuredKey;if(!OriginalValue.Equals(result)){
AntiCheatHelper.OnDetected();}return result;}set{
OriginalValue =value;unchecked{
ObscuredKey = JRandom.RandomNum(int.MaxValue -value);
ObscuredInt =value+ ObscuredKey;}}}publicJInt(int val =0){
ObscuredInt =0;
ObscuredKey =0;
OriginalValue =0;
Value = val;}publicstaticimplicitoperatorJInt(int val)=>newJInt(val);publicstaticimplicitoperatorint(JInt val)=> val.Value;publicstaticbooloperator==(JInt a,JInt b)=> a.Value == b.Value;publicstaticbooloperator==(JInt a,int b)=> a.Value == b;publicstaticbooloperator!=(JInt a,JInt b)=> a.Value != b.Value;publicstaticbooloperator!=(JInt a,int b)=> a.Value != b;publicstatic JInt operator++(JInt a){
a.Value++;return a;}publicstatic JInt operator--(JInt a){
a.Value--;return a;}publicstatic JInt operator+(JInt a,JInt b)=>newJInt(a.Value + b.Value);publicstatic JInt operator+(JInt a,int b)=>newJInt(a.Value + b);publicstatic JInt operator-(JInt a,JInt b)=>newJInt(a.Value - b.Value);publicstatic JInt operator-(JInt a,int b)=>newJInt(a.Value - b);publicstatic JInt operator*(JInt a,JInt b)=>newJInt(a.Value * b.Value);publicstatic JInt operator*(JInt a,int b)=>newJInt(a.Value * b);publicstatic JInt operator/(JInt a,JInt b)=>newJInt(a.Value / b.Value);publicstatic JInt operator/(JInt a,int b)=>newJInt(a.Value / b);publicstatic JInt operator%(JInt a,JInt b)=>newJInt(a.Value % b.Value);publicstatic JInt operator%(JInt a,int b)=>newJInt(a.Value % b);publicoverridestringToString()=> Value.ToString();publicoverrideintGetHashCode()=> Value.GetHashCode();publicoverrideboolEquals(object obj)=> Value.Equals(obj isJInt ?((JInt) obj).Value : obj);}}