You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.0 KiB
113 lines
4.0 KiB
3 years ago
|
using System;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
[FriendClass(typeof(Unit))]
|
||
|
public static class CheatHelper
|
||
|
{
|
||
|
public static async ETTask<int> AddItem(Unit unit, int id, int type, uint num)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
C2M_Cheat msg = new C2M_Cheat() { Type = type, Id = id, Num = num };
|
||
|
M2C_Cheat resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_Cheat;
|
||
|
if (resp.Error == ErrorCode.ERR_Success)
|
||
|
{
|
||
|
if (type == 1)
|
||
|
{
|
||
|
StoreComponent storeComponent = unit.GetComponent<StoreComponent>();
|
||
|
if (num >= 0)
|
||
|
{
|
||
|
storeComponent.Add(id, num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
storeComponent.Remove(id, (int)Math.Abs(num));
|
||
|
}
|
||
|
}
|
||
|
else if (type == 2)
|
||
|
{
|
||
|
if (id == NumericType.Water)
|
||
|
{
|
||
|
unit.Water += num;
|
||
|
}
|
||
|
else if (id == NumericType.Food)
|
||
|
{
|
||
|
unit.Food += num;
|
||
|
}
|
||
|
else if (id == NumericType.SilverTael)
|
||
|
{
|
||
|
if (num >= 0)
|
||
|
{
|
||
|
unit.SilverTael += (int) Math.Abs(num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
unit.SilverTael -= (int) Math.Abs(num);
|
||
|
}
|
||
|
}
|
||
|
else if (id == NumericType.GoldIngot)
|
||
|
{
|
||
|
if (num >= 0)
|
||
|
{
|
||
|
unit.GoldIngot += (int) Math.Abs(num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
unit.GoldIngot -= (int) Math.Abs(num);
|
||
|
}
|
||
|
}
|
||
|
else if (id == NumericType.Season)
|
||
|
{
|
||
|
if (num >= 0)
|
||
|
{
|
||
|
unit.Season += (int) Math.Abs(num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
unit.Season -= (int) Math.Abs(num);
|
||
|
}
|
||
|
}
|
||
|
else if (id == NumericType.Scale)
|
||
|
{
|
||
|
if (num >= 0)
|
||
|
{
|
||
|
unit.Scale += (int) Math.Abs(num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
unit.Scale -= (int) Math.Abs(num);
|
||
|
}
|
||
|
}
|
||
|
else if (id == NumericType.Prosperity)
|
||
|
{
|
||
|
if (num >= 0)
|
||
|
{
|
||
|
unit.Prosperity += (int) Math.Abs(num);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
unit.Prosperity -= (int) Math.Abs(num);
|
||
|
}
|
||
|
}
|
||
|
else if (id == NumericType.Time)
|
||
|
{
|
||
|
unit.GameTime = (int) num;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
Log.Error(resp.Error.ToString());
|
||
|
}
|
||
|
|
||
|
return resp.Error;
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
Log.Error(e.ToString());
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|