public InserterCopy(InserterCopy_V1 model, BlueprintData_V1 data) { FieldInfo[] fields = GetType().GetFields(); foreach (FieldInfo field in fields) { FieldInfo fieldOrg = model.GetType().GetField(field.Name); if (fieldOrg != null && field.FieldType == fieldOrg.FieldType) { field.SetValue(this, fieldOrg.GetValue(model)); } } BuildingCopy_V1 building = data.copiedBuildings[referenceBuildingId]; Vector2 buildingSprPos = building.originalPos.ToSpherical(); Vector2 oldPosDelta = (building.originalPos + building.originalRot * model.posDelta).ToSpherical(); Vector2 oldPos2Delta = (building.originalPos + building.originalRot * model.pos2Delta).ToSpherical(); posDelta = (oldPosDelta - buildingSprPos).Clamp(); pos2Delta = (oldPos2Delta - buildingSprPos).Clamp(); posDeltaCount = oldPosDelta.GetSegmentsCount(); pos2DeltaCount = oldPos2Delta.GetSegmentsCount(); Vector2 oldOtherSprPos = BlueprintData_V1.GetPointFromMoves(building.originalPos, model.movesFromReference, building.originalRot).ToSpherical(); otherPosDelta = oldOtherSprPos - buildingSprPos; otherPosDeltaCount = oldOtherSprPos.GetSegmentsCount(); }
public BlueprintData(BlueprintData_V1 model) { Debug.Log("Converting from v1!"); name = model.name; referencePos = model.referencePos.ToSpherical(); foreach (BuildingCopy_V1 building in model.copiedBuildings.Values) { copiedBuildings.Add(new BuildingCopy(building, referencePos, model.referenceYaw)); } foreach (BeltCopy_V1 belt in model.copiedBelts.Values) { copiedBelts.Add(new BeltCopy(belt, referencePos)); } foreach (InserterCopy_V1 building in model.copiedInserters.Values) { copiedInserters.Add(new InserterCopy(building, model)); } }