/// <summary> /// テンプレートを検証<br /> /// <br /> /// このAPIの検証内容は簡易検証を行うに過ぎず、<br /> /// このAPIで検証をパスしたとしても、実行したらエラーが発生する場合もあります<br /> /// </summary> /// /// <returns>IEnumerator</returns> /// <param name="callback">コールバックハンドラ</param> /// <param name="request">リクエストパラメータ</param> public IEnumerator Validate( Request.ValidateRequest request, UnityAction <AsyncResult <Result.ValidateResult> > callback ) { var task = new ValidateTask(request, callback); return(Gs2WebSocketSession.Execute(task)); }
/// <summary> /// テンプレートを検証<br /> /// <br /> /// このAPIの検証内容は簡易検証を行うに過ぎず、<br /> /// このAPIで検証をパスしたとしても、実行したらエラーが発生する場合もあります<br /> /// </summary> /// /// <returns>IEnumerator</returns> /// <param name="callback">コールバックハンドラ</param> /// <param name="request">リクエストパラメータ</param> public IEnumerator Validate( Request.ValidateRequest request, UnityAction <AsyncResult <Result.ValidateResult> > callback ) { var task = new ValidateTask(request, callback); if (_certificateHandler != null) { task.UnityWebRequest.certificateHandler = _certificateHandler; } return(Gs2RestSession.Execute(task)); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Common.StringBuilder log = new Common.StringBuilder("Run"); try { Lot targetLot = Porter.GetLot(parameters.mTarget); if (targetLot == null) { return(OptionResult.Failure); } Dictionary <ulong, IMiniSimDescription> preExistingSims = SimListing.GetSims <IMiniSimDescription>(null, true); Household me = targetLot.Household; if (me == null) { me = GetImportSelection(targetLot); if (me == null) { return(OptionResult.Failure); } } Dictionary <ulong, IMiniSimDescription> allSims = SimListing.GetSims <IMiniSimDescription>(null, true); Dictionary <int, HouseData> houses = new Dictionary <int, HouseData>(); Dictionary <int, HouseData> doppleHouses = new Dictionary <int, HouseData>(); List <SimDescription> cleanUp = new List <SimDescription>(); List <SimDescription> fixUp = new List <SimDescription>(); List <Household> importedHouses = new List <Household>(); importedHouses.Add(me); List <SimDescription> checkSims = new List <SimDescription>(); log += Common.NewLine + "A"; List <SimDescription> sims = new List <SimDescription>(me.AllSimDescriptions); foreach (SimDescription sim in sims) { if (sim == null) { continue; } log += Common.NewLine + sim.FullName; Porter.AddExport(sim); string description = sim.mBio; if (string.IsNullOrEmpty(description)) { continue; } if (!description.Contains("NRaas.Porter:")) { continue; } description = description.Replace("NRaas.Porter:", ""); if (string.IsNullOrEmpty(description)) { continue; } HouseData lookup = new HouseData(description); lookup.Reconcile(sim); ValidateTask.Perform(sim); List <SimDescription> dependents = new List <SimDescription>(); if (HandleDoppleganger(sim, preExistingSims, allSims, dependents)) { if (!houses.ContainsKey(lookup.mID)) { if (!doppleHouses.ContainsKey(lookup.mID)) { doppleHouses.Add(lookup.mID, lookup); } } checkSims.AddRange(dependents); cleanUp.Add(sim); continue; } else { fixUp.Add(sim); } HouseData data; if (!houses.TryGetValue(lookup.mID, out data)) { data = lookup; houses.Add(data.mID, data); } doppleHouses.Remove(lookup.mID); data.mSims.Add(sim); } log += Common.NewLine + "B"; foreach (SimDescription sim in fixUp) { log += Common.NewLine + sim.FullName; new Relationships.RepairParents().Perform(sim, UnusedLog, allSims); new Relationships.RepairChildren().Perform(sim, UnusedLog, allSims); new Relationships.RepairSiblings().Perform(sim, UnusedLog, allSims); } log += Common.NewLine + "C"; foreach (SimDescription cleanup in cleanUp) { log += Common.NewLine + cleanup.FullName; try { if (cleanup.Household != null) { cleanup.Household.Remove(cleanup); } checkSims.Remove(cleanup); cleanup.Genealogy.ClearAllGenealogyInformation(); cleanup.Dispose(); } catch (Exception e) { Common.DebugException(log, e); } } log += Common.NewLine + "D"; if (houses.Count == 0) { SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:NotProper")); return(OptionResult.Failure); } else if (houses.Count == 1) { int funds = -1; foreach (HouseData data in houses.Values) { if (data.mID != 0) { funds = data.mFunds; } } if (funds >= 0) { me.SetFamilyFunds(funds); SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:Unneeded")); return(OptionResult.Failure); } } log += Common.NewLine + "E"; int unpacked = 0, failed = 0; List <HouseData> sorted = new List <HouseData>(houses.Values); sorted.Sort(new Comparison <HouseData>(HouseData.SortByCost)); foreach (HouseData data in sorted) { log += Common.NewLine + "House: " + data.mID; if (data.mID != 1) { Household house = null; if (data.mID != 0) { Lot lot = FindLot(data.mFunds, data.mSims); if (lot == null) { lot = FindLot(-1, null); if (lot == null) { failed++; continue; } } house = Household.Create(); importedHouses.Add(house); lot.MoveIn(house); house.Name = data.mName; int finalFunds = (data.mFunds - lot.Cost); if (finalFunds >= 0) { house.SetFamilyFunds(finalFunds); me.ModifyFamilyFunds(-data.mFunds); } else { house.SetFamilyFunds(0); me.ModifyFamilyFunds(-data.mFunds); me.ModifyFamilyFunds(finalFunds); } if (me.FamilyFunds < 0) { me.SetFamilyFunds(0); } if (house.FamilyFunds < 0) { house.SetFamilyFunds(0); } unpacked++; } foreach (SimDescription sim in data.mSims) { log += Common.NewLine + sim.FullName; if (house != null) { log += Common.NewLine + "Moved"; me.Remove(sim); house.Add(sim); Instantiation.Perform(sim, null); } else { log += Common.NewLine + "PlaceGrave"; Porter.PlaceGraveTask.Perform(sim); } } if (house != null) { string name = house.LotHome.Name; if (string.IsNullOrEmpty(name)) { name = house.LotHome.Address; } Porter.Notify(Common.Localize("Unpack:Success", false, new object[] { house.Name, name }), house.LotHome.ObjectId); } } else { unpacked++; } foreach (SimDescription sim in data.mSims) { sim.mBio = null; } } log += Common.NewLine + "F"; foreach (SimDescription checkSim in checkSims) { log += Common.NewLine + checkSim.FullName; if (checkSim.ChildOrBelow) { bool found = false; Household parentHousehold = null; foreach (SimDescription parent in Relationships.GetParents(checkSim)) { if ((checkSim.Household != null) && (parent.Household == checkSim.Household)) { found = true; break; } else { parentHousehold = parent.Household; } } if (!found) { if (parentHousehold == null) { if ((checkSim.Household != null) && (checkSim.Household.NumMembers == 1)) { foreach (Household house in Household.sHouseholdList) { foreach (SimDescription sim in Households.All(house)) { if (Relationships.IsCloselyRelated(checkSim, sim, false)) { parentHousehold = house; break; } } if (parentHousehold != null) { break; } } } } if (parentHousehold != null) { if (checkSim.Household != null) { checkSim.Household.Remove(checkSim); } parentHousehold.Add(checkSim); Instantiation.AttemptToPutInSafeLocation(checkSim.CreatedSim, false); } } } } log += Common.NewLine + "G"; foreach (Household house in importedHouses) { foreach (Sim sim in Households.AllSims(house)) { foreach (GameObject obj in Inventories.QuickFind <GameObject>(sim.Inventory)) { bool moveToFamily = false; if (!sim.Inventory.ValidForThisInventory(obj)) { moveToFamily = true; } else if (obj is IStageProp) { moveToFamily = true; } if (moveToFamily) { sim.Inventory.RemoveByForce(obj); Inventories.TryToMove(obj, house.SharedFamilyInventory.Inventory); } } } } log += Common.NewLine + "H"; int doppleFunds = 0; foreach (HouseData data in doppleHouses.Values) { doppleFunds += data.mFunds; } me.ModifyFamilyFunds(-doppleFunds); if (me.FamilyFunds < 0) { me.SetFamilyFunds(0); } SimpleMessageDialog.Show(Common.Localize("Title"), Common.Localize("Unpack:Completion", false, new object[] { unpacked, failed })); } catch (Exception e) { Common.Exception(log, e); } return(OptionResult.SuccessClose); }