public static Unit NewUnit(this Place place, Guid descriptorId, Guid?playerId = null)
{
var descriptor = GameHost.GameRules.GetDataItem <UnitDescriptor>(descriptorId);
var owner = playerId ?? place.Owner ?? Guid.Empty;
if (owner == Guid.Empty)
{
throw new ArgumentNullException("playerId", "无法从地块找到单位所有者,必须指定单位所有玩家");
}
return(Unit.CreateUnit(place.DataService, descriptor, owner, place.Coordinate, Guid.NewGuid(), place.DataService.NameService.AllocateName()));
}