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.
 
 
 
 
 
 

83 lines
2.9 KiB

using System;
using System.Linq;
namespace ET
{
public static class CuisineHelper
{
public static async ETTask<int> StartCuisine(Unit unit, int configId, long maxAmount)
{
try
{
C2M_StartCuisine msg = new C2M_StartCuisine() { Id = configId, MaxAmount = maxAmount };
M2C_StartCuisine resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_StartCuisine;
if (resp.Error == ErrorCode.ERR_Success)
{
var err = CuisineOperate.StartCuisine(unit, configId, maxAmount);
//Game.EventSystem.Publish(new EventType.AfterCreateConstruct(){Unit = unit, Cuisine = cuisine, IsNew = true});
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
public static async ETTask<int> DevelopRecipes(Unit unit, int[] ids)
{
try
{
C2M_DevelopRecipe msg = new C2M_DevelopRecipe() { Ids = ids.ToList() };
M2C_DevelopRecipe resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_DevelopRecipe;
if (resp.Error == ErrorCode.ERR_Success)
{
var err = CuisineOperate.DevelopRecipes(unit, ids.ToList());
Game.EventSystem.Publish(new EventType.CookingGameStart() { Unit = unit, SynthesisID = resp.Id });
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
public static async ETTask<int> EndCuisine(Unit unit, int result, int selectedCuisine)
{
try
{
C2M_StopRecipeGame msg = new C2M_StopRecipeGame() { Result = result };
M2C_StopRecipeGame resp = await unit.ZoneScene().GetComponent<SessionComponent>().Session.Call(msg) as M2C_StopRecipeGame;
if (resp.Error == ErrorCode.ERR_Success)
{
CuisineOperate.EndCuisine(unit, result);
Game.EventSystem.Publish(new EventType.CookingFinish(){Unit = unit, MixtureID = resp.MixtureId, SelectedCuisine = selectedCuisine});
}
else
{
Log.Error(resp.Error.ToString());
}
return resp.Error;
}
catch (Exception e)
{
Log.Error(e.ToString());
throw;
}
}
}
}