public void SendTranscationWithReceiptDecodeTest() { var contractService = new ContractService(BaseConfig.DefaultUrl, BaseConfig.DefaultRpcId, BaseConfig.DefaultChainId, BaseConfig.DefaultGroupId, privateKey); string contractAddress = "0x149d743274d91eeea8f646901fc8dd79551dccda";//上面测试部署合约得到合约地址 var inputsParameters = new[] { BuildParams.CreateParam("string", "n") }; var paramsValue = new object[] { "123" }; string functionName = "set";//调用合约方法 ReceiptResultDto receiptResultDto = contractService.SendTranscationWithReceipt(abi, contractAddress, functionName, inputsParameters, paramsValue); Assert.NotEmpty(receiptResultDto.Output); Assert.NotEmpty(receiptResultDto.Input); Assert.NotEmpty(receiptResultDto.Logs); var solidityAbi = new SolidityABI(abi); var inputList = solidityAbi.InputDecode(functionName, receiptResultDto.Input); Assert.True(inputList[0].Parameter.Name == "n" && inputList[0].Result.ToString() == "123"); string eventName = "SetEvent"; var eventList = solidityAbi.EventDecode(eventName, receiptResultDto.Logs); var eventpramas1 = eventList[0].Event.Find(x => x.Parameter.Name == "paramsStr"); var eventpramas2 = eventList[0].Event.Find(x => x.Parameter.Name == "operationTimeStamp"); Assert.True(eventpramas1.Result.ToString() == "123"); Assert.NotNull(eventpramas2.Result); }
protected IList<int> BuildListRL2(IList<int> list, int maxvalue, BuildParams config) { var L = new ListRL2 (); // L.Build (list, maxvalue, new EliasGamma (), 63); L.Build (list, maxvalue, config.coder, config.block_size); return L; }
public static BuildParams DefaultParams() { var ret = new BuildParams(); ret.Cellsize = 0.3f; ret.Cellheight = 0.3f; ret.SlopeAngle = 30.0f; ret.AgentHeight = 2.0f; ret.AgentClimb = 0.1f; ret.AgentRadius = 0.5f; ret.MinRegionArea = 3; return(ret); }
public BuildLesserMinionCommand(int damage, int range, int health, int mining, int speed, int vision, int x, int y) { CommandName = "build lesser"; MinionId = null; Params = new BuildParams(new Stats { Damage = damage, Range = range, Health = health, Mining = mining, Speed = speed, Vision = vision }, x, y); }
/// <summary> /// Creates an instance of the specified entity type and sets provided parameters /// </summary> /// <param name="type">Type of instance</param> /// <param name="par">Parameters to set</param> public static Entity Create(Type type, BuildParams par) { if (!type.IsSubclassOf(typeof(Entity))) { throw new ReflectionException("Passed an non-entity type to the Entity.Create method"); } var tmp = (Entity)Activator.CreateInstance(type); foreach (KeyValuePair <String, object> pair in par) { ReflectionHelper.SetAnything(type, tmp, pair.Key, pair.Value); } return(tmp); }
internal static void OnBeforeBuildPackage(BuildParams buildParam) { //GenXLua(); EditorSceneManager.OpenScene(buildParam.startScene); var init = GameObject.Find(BuildConfig.startSceneInitObjectPath); if (init != null) { var startScript = init.gameObject.GetComponent <GameStart>(); startScript.IsAbRes = true; startScript.IsAbLua = true; startScript.IsAbCfg = true; EditorSceneManager.SaveOpenScenes(); } }
public void GetContructorParamsTest() { //var data = "0x2dc9".HexToBigInteger(true); var contractService = new ContractService(BaseConfig.DefaultUrl, BaseConfig.DefaultRpcId, BaseConfig.DefaultChainId, BaseConfig.DefaultGroupId, privateKey); string contractAddress = "0x1be74c68f3fec43b2360dd7456748121e1216960";//上面测试部署合约得到合约地址 var funcInputsParameters = new[] { BuildParams.CreateParam("uint256", "temp") }; var funcParamsValue = new object[] { 1 }; string functionName = "get";//调用合约方法 ReceiptResultDto receiptResultDto = contractService.CallRequest(contractAddress, abi, functionName, funcInputsParameters, funcParamsValue); Assert.NotEmpty(receiptResultDto.Output); var solidityAbi = new SolidityABI(abi); var outputList = solidityAbi.OutputDecode(functionName, receiptResultDto.Output); Assert.Equal("123", outputList[0].Result); }
public void ImportMap(string filename) { var xml = new XmlDocument(); xml.Load(filename); var root = xml.DocumentElement; foreach (XmlNode ch in root.ChildNodes) { var el = (XmlElement)ch; switch (el.Name) { case "entity": // Spawning entities foreach (XmlNode anode in el.ChildNodes) { var par = new BuildParams(); string type = ""; foreach (XmlElement attr in ((XmlElement)anode).Attributes) { if (attr.Name != "type") { par.Add(attr.Name, attr.Value); } else { type = attr.Value; } } AddEntity(Entity.Create(Type.GetType(type), par)); } break; } } }
public BuildTriggerRequest(HookInfo hookInfo, BuildParams buildParams) { hook_info = hookInfo; build_params = buildParams; }
/// <summary> /// Make some items pickable /// </summary> /// <returns>return list of pickalbe items</returns> private List <SceneItem> MakeSomeSceneItemsPickable(List <SceneItem> visibleItemList, BuildParams buildParams) { List <SceneItem> pickableItemList = new List <SceneItem>(); int maxPickableItemCount = Math.Min(buildParams.PickableItemCount, visibleItemList.Count); for (int i = 0; i < maxPickableItemCount; i++) { SceneItem item = visibleItemList[i]; var spriteRenderer = item.gameObject.GetComponent <SpriteRenderer>(); if (spriteRenderer != null) { var boxCollider = item.gameObject.GetComponent <BoxCollider2D>(); if (boxCollider == null) { var size = spriteRenderer.sprite.bounds.size; boxCollider = item.gameObject.AddComponent <BoxCollider2D>(); boxCollider.size = new Vector2(size.x, size.y); } } PickableItem component = item.gameObject.AddComponent <PickableItem>(); component.Controller = buildParams.Controller; pickableItemList.Add(item); } return(pickableItemList); }
public PickableItemsBuilder(BuildParams buildParams) { _buildParams = buildParams; }
/// <summary> /// Create a build /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='branch'> /// The branch name /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> /// <param name='paramsParameter'> /// Parameters of the build /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Build> CreateAsync(this IBuilds operations, string branch, string ownerName, string appName, BuildParams paramsParameter = default(BuildParams), CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.CreateWithHttpMessagesAsync(branch, ownerName, appName, paramsParameter, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Create constrained count of visible SceneItems /// /// BuildParams defines constraint on visible SceneItems count /// </summary> /// <returns></returns> private List <SceneItem> CreateVisibleItems(List <ItemDescriptor> itemDescriptors, Transform sceneFolder, SpritesCache cache, BuildParams buildParams) { List <SceneItem> visibleItems = new List <SceneItem>(); if (buildParams.ItemPrefab == null) { #if DEBIG_PICKABLE_ITEMS_BUILDER Debug.LogError("Item Prefab does not exist"); #endif return(visibleItems); } CollisionController collisionController = new CollisionController(sceneFolder.gameObject.GetComponent <SceneComponent>().SceneSize); foreach (ItemDescriptor itemDescriptor in itemDescriptors) { if (itemDescriptor.placeHolders.Count == 0) { #if DEBIG_PICKABLE_ITEMS_BUILDER Debug.LogWarningFormat("Item Descriptor {0} does not have placeholders", itemDescriptor.name); #endif continue; } var shuffledPlaceHolders = shuffle(itemDescriptor.placeHolders).ToList(); foreach (ItemPlaceHolderDescriptor placeHolder in shuffledPlaceHolders) { if (collisionController.CheckCollision(placeHolder.image)) { continue; } Sprite sprite = cache.Get(placeHolder.image.assetPath, placeHolder.image.name); if (sprite == null) { continue; } GameObject sceneItem = Instantiate(buildParams.ItemPrefab, sceneFolder); sceneItem.name = placeHolder.image.name; AttachSpriteToObject(sceneItem.transform, placeHolder.image, sprite); SceneItem sceneItemComponent = sceneItem.GetComponent <SceneItem>(); sceneItemComponent.DisplayName = itemDescriptor.displayName; Sprite silhouette = cache.Get(itemDescriptor.displayImage.assetPath, itemDescriptor.displayImage.name); if (silhouette != null) { sceneItemComponent.Silhouette = silhouette; } foreach (var shadow in placeHolder.shadows) { var obj = CreateSpriteInstance(shadow, cache); // NOTE in game mode shadows attached to scene, not to scene item obj.transform.SetParent(sceneFolder); var childComponent = obj.gameObject.AddComponent <SceneItemChildLayer>(); childComponent.Type = SceneItemChildLayer.LayerType.Shadow; sceneItemComponent.ChildLayers.Add(childComponent); } foreach (var patch in placeHolder.patches) { var obj = CreateSpriteInstance(patch, cache); // NOTE in game mode patches attached to scene, not to scene item obj.transform.SetParent(sceneFolder); var childComponent = obj.gameObject.AddComponent <SceneItemChildLayer>(); childComponent.Type = SceneItemChildLayer.LayerType.Patch; sceneItemComponent.ChildLayers.Add(childComponent); } visibleItems.Add(sceneItemComponent); break; } if (visibleItems.Count >= buildParams.VisibleItemCount) { break; } } return(visibleItems); }
public void MergeFrom(BuilderConfig other) { if (other == null) { return; } if (other.Action.Length != 0) { Action = other.Action; } if (other.Track.Length != 0) { Track = other.Track; } if (other.RegistryMirror.Length != 0) { RegistryMirror = other.RegistryMirror; } if (other.DockerDaemonMtu.Length != 0) { DockerDaemonMtu = other.DockerDaemonMtu; } if (other.manifest_ != null) { if (manifest_ == null) { Manifest = new global::Estafette.Ci.Manifest.V1.EstafetteManifest(); } Manifest.MergeFrom(other.Manifest); } if (other.JobName.Length != 0) { JobName = other.JobName; } if (other.ReleaseName.Length != 0) { ReleaseName = other.ReleaseName; } events_.Add(other.events_); if (other.ciServer_ != null) { if (ciServer_ == null) { CiServer = new global::Estafette.Ci.Contracts.V1.CiServerConfig(); } CiServer.MergeFrom(other.CiServer); } if (other.buildParams_ != null) { if (buildParams_ == null) { BuildParams = new global::Estafette.Ci.Contracts.V1.BuildParamsConfig(); } BuildParams.MergeFrom(other.BuildParams); } if (other.releaseParams_ != null) { if (releaseParams_ == null) { ReleaseParams = new global::Estafette.Ci.Contracts.V1.ReleaseParamsConfig(); } ReleaseParams.MergeFrom(other.ReleaseParams); } if (other.git_ != null) { if (git_ == null) { Git = new global::Estafette.Ci.Contracts.V1.GitConfig(); } Git.MergeFrom(other.Git); } if (other.buildVersion_ != null) { if (buildVersion_ == null) { BuildVersion = new global::Estafette.Ci.Contracts.V1.BuildVersionConfig(); } BuildVersion.MergeFrom(other.BuildVersion); } credentials_.Add(other.credentials_); trustedImages_.Add(other.trustedImages_); _unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields); }
public override int GetHashCode() { int hash = 1; if (Action.Length != 0) { hash ^= Action.GetHashCode(); } if (Track.Length != 0) { hash ^= Track.GetHashCode(); } if (RegistryMirror.Length != 0) { hash ^= RegistryMirror.GetHashCode(); } if (DockerDaemonMtu.Length != 0) { hash ^= DockerDaemonMtu.GetHashCode(); } if (manifest_ != null) { hash ^= Manifest.GetHashCode(); } if (JobName.Length != 0) { hash ^= JobName.GetHashCode(); } if (ReleaseName.Length != 0) { hash ^= ReleaseName.GetHashCode(); } hash ^= events_.GetHashCode(); if (ciServer_ != null) { hash ^= CiServer.GetHashCode(); } if (buildParams_ != null) { hash ^= BuildParams.GetHashCode(); } if (releaseParams_ != null) { hash ^= ReleaseParams.GetHashCode(); } if (git_ != null) { hash ^= Git.GetHashCode(); } if (buildVersion_ != null) { hash ^= BuildVersion.GetHashCode(); } hash ^= credentials_.GetHashCode(); hash ^= trustedImages_.GetHashCode(); if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
public hkRootLevelContainer BuildNavmesh(BuildParams p, List <Vector3> verts, List <int> indices) { var root = new hkRootLevelContainer(); NavMeshNative.SetNavmeshBuildParams(p.Cellsize, p.Cellheight, p.SlopeAngle, p.AgentHeight, p.AgentClimb, p.AgentRadius, p.MinRegionArea); var buildSuccess = NavMeshNative.BuildNavmeshForMesh(verts.ToArray(), verts.Count, indices.ToArray(), indices.Count); if (!buildSuccess) { return(null); } var vcount = NavMeshNative.GetMeshVertCount(); var icount = NavMeshNative.GetMeshTriCount(); if (vcount == 0 || icount == 0) { return(null); } ushort[] bverts = new ushort[vcount * 3]; ushort[] bindices = new ushort[icount * 3 * 2]; Vector3[] vbverts = new Vector3[vcount]; NavMeshNative.GetMeshVerts(bverts); NavMeshNative.GetMeshTris(bindices); Vector3[] bounds = new Vector3[2]; NavMeshNative.GetBoundingBox(bounds); var nmesh = new hkaiNavMesh(); nmesh.m_aabb = new hkAabb(); nmesh.m_aabb.m_min = new Vector4(bounds[0].X, bounds[0].Y, bounds[0].Z, 1.0f); nmesh.m_aabb.m_max = new Vector4(bounds[1].X, bounds[1].Y, bounds[1].Z, 1.0f); nmesh.m_edgeData = new List <int>(); nmesh.m_edgeDataStriding = 1; nmesh.m_edges = new List <hkaiNavMeshEdge>(); nmesh.m_erosionRadius = 0.0f; nmesh.m_faceData = new List <int>(); nmesh.m_faceDataStriding = 1; nmesh.m_faces = new List <hkaiNavMeshFace>(); nmesh.m_flags = 0; nmesh.m_vertices = new List <Vector4>(); for (int i = 0; i < bverts.Length / 3; i++) { var vx = bverts[i * 3]; var vy = bverts[i * 3 + 1]; var vz = bverts[i * 3 + 2]; var vert = new Vector3(bounds[0].X + (float)vx * p.Cellsize, bounds[0].Y + (float)vy * p.Cellheight, bounds[0].Z + (float)vz * p.Cellsize); nmesh.m_vertices.Add(new Vector4(vert.X, vert.Y, vert.Z, 1.0f)); vbverts[i] = vert; } for (int t = 0; t < bindices.Length / 2; t += 3) { var f = new hkaiNavMeshFace(); f.m_clusterIndex = 0; f.m_numEdges = 3; f.m_startEdgeIndex = nmesh.m_edges.Count; f.m_startUserEdgeIndex = -1; f.m_padding = 0xCDCD; nmesh.m_faces.Add(f); nmesh.m_faceData.Add(0); for (int i = 0; i < 3; i++) { var e = new hkaiNavMeshEdge(); e.m_a = bindices[t * 2 + i]; e.m_b = bindices[t * 2 + ((i + 1) % 3)]; e.m_flags = 4; // Record adjacency if (bindices[t * 2 + 3 + i] == 0xFFFF) { // No adjacency e.m_oppositeEdge = 0xFFFFFFFF; e.m_oppositeFace = 0xFFFFFFFF; } else { e.m_oppositeFace = bindices[t * 2 + 3 + i]; // Find the edge that has this face as an adjancency for (int j = 0; j < 3; j++) { var edge = bindices[t * 2 + 3 + i] * 6 + 3 + j; if (bindices[edge] == (t / 3)) { e.m_oppositeEdge = (uint)bindices[t * 2 + 3 + i] * 3 + (uint)j; } } } nmesh.m_edges.Add(e); nmesh.m_edgeData.Add(0); } } root.m_namedVariants = new List <hkRootLevelContainerNamedVariant>(); var variant = new hkRootLevelContainerNamedVariant(); variant.m_className = "hkaiNavMesh"; variant.m_name = "hkaiNavMesh"; variant.m_variant = nmesh; root.m_namedVariants.Add(variant); // Next step: build a bvh var shortIndices = new ushort[bindices.Length / 2]; for (int i = 0; i < bindices.Length / 2; i += 3) { shortIndices[i] = bindices[i * 2]; shortIndices[i + 1] = bindices[i * 2 + 1]; shortIndices[i + 2] = bindices[i * 2 + 2]; } bool didbuild = BVHNative.BuildBVHForMesh(vbverts, vbverts.Length, shortIndices, shortIndices.Length); if (!didbuild) { return(null); } var nodecount = BVHNative.GetBVHSize(); var nsize = BVHNative.GetNodeSize(); var nodes = new NativeBVHNode[nodecount]; BVHNative.GetBVHNodes(nodes); // Rebuild in friendlier tree form List <BVNode> bnodes = new List <BVNode>((int)nodecount); foreach (var n in nodes) { var bnode = new BVNode(); bnode.Min = new Vector3(n.minX, n.minY, n.minZ); bnode.Max = new Vector3(n.maxX, n.maxY, n.maxZ); bnode.IsLeaf = n.isLeaf == 1; bnode.PrimitiveCount = n.primitiveCount; bnode.Primitive = n.firstChildOrPrimitive; bnodes.Add(bnode); } for (int i = 0; i < nodes.Length; i++) { if (nodes[i].isLeaf == 0) { bnodes[i].Left = bnodes[(int)nodes[i].firstChildOrPrimitive]; bnodes[i].Right = bnodes[(int)nodes[i].firstChildOrPrimitive + 1]; } } var bvhvariant = new hkRootLevelContainerNamedVariant(); bvhvariant.m_className = "hkcdStaticAabbTree"; bvhvariant.m_name = "hkcdStaticAabbTree"; var tree = new hkcdStaticAabbTree(); bvhvariant.m_variant = tree; root.m_namedVariants.Add(bvhvariant); tree.m_treePtr = new hkcdStaticTreeDefaultTreeStorage6(); tree.m_treePtr.m_nodes = bnodes[0].BuildAxis6Tree(); var min = bnodes[0].Min; var max = bnodes[0].Max; tree.m_treePtr.m_domain = new hkAabb(); tree.m_treePtr.m_domain.m_min = new Vector4(min.X, min.Y, min.Z, 1.0f); tree.m_treePtr.m_domain.m_max = new Vector4(max.X, max.Y, max.Z, 1.0f); // Build a dummy directed graph var gvariant = new hkRootLevelContainerNamedVariant(); gvariant.m_className = "hkaiDirectedGraphExplicitCost"; gvariant.m_name = "hkaiDirectedGraphExplicitCost"; var graph = new hkaiDirectedGraphExplicitCost(); gvariant.m_variant = graph; root.m_namedVariants.Add(gvariant); graph.m_nodes = new List <hkaiDirectedGraphExplicitCostNode>(); var node = new hkaiDirectedGraphExplicitCostNode(); node.m_numEdges = 0; node.m_startEdgeIndex = 0; graph.m_nodes.Add(node); graph.m_positions = new List <Vector4>(); var c = (max - min) / 2; graph.m_positions.Add(new Vector4(c.X, c.Y, c.Z, 1.0f)); return(root); }
/// <summary> /// Picks random SceneItems and their PlaceHolders /// until conditions in BuildParams are satisfied /// (eg. 20 visible items) /// /// For picked SceneItems removed all placeholders except one /// Other SceneItems removed from scene /// </summary> /// <returns>returns list of visible items</returns> private List <SceneItem> RefineSceneItems(List <SceneItem> itemList, Transform sceneFolder, BuildParams buildParams) { CollisionController collisionController = new CollisionController(sceneFolder.gameObject.GetComponent <SceneComponent>().SceneSize); List <SceneItem> visibleItemList = new List <SceneItem>(); foreach (SceneItem item in itemList) { if (visibleItemList.Count >= buildParams.VisibleItemCount) { Destroy(item.gameObject); continue; } // skip if item does not contains placeholders if (item.transform.childCount == 0) { continue; } // get list of all placeholders List <SpriteRenderer> placeHolders = new List <SpriteRenderer>(); foreach (Transform child in item.transform) { // filter out themeselves if (child == item.transform) { continue; } SpriteRenderer childSpriteRenderer = child.gameObject.GetComponent <SpriteRenderer>(); if (childSpriteRenderer == null || childSpriteRenderer.sprite == null) { continue; } placeHolders.Add(childSpriteRenderer); } // shuffle and select one that does not collide with items already attached to scene placeHolders = shuffle(placeHolders).ToList(); SpriteRenderer pickedPlaceHolder = null; foreach (SpriteRenderer placeHolder in placeHolders) { if (!collisionController.CheckCollision(placeHolder)) { pickedPlaceHolder = placeHolder; break; } } // if no one placeholder is suitable, remove whole item from scene if (pickedPlaceHolder == null) { Destroy(item.gameObject); continue; } // else remove other placeholders except picked one // also do some gameObjects hierarchy flattening SpriteRenderer itemSpriteRenderer = item.gameObject.AddComponent <SpriteRenderer>(); itemSpriteRenderer.sprite = pickedPlaceHolder.sprite; itemSpriteRenderer.sortingOrder = pickedPlaceHolder.sortingOrder; Transform[] childs = pickedPlaceHolder.GetComponentsInChildren <Transform>(); foreach (Transform child in childs) { if (child == pickedPlaceHolder.transform) { continue; } child.SetParent(sceneFolder, true); } item.transform.position = pickedPlaceHolder.transform.position; childs = item.GetComponentsInChildren <Transform>(); foreach (Transform child in childs) { if (child == item.transform) { continue; } Destroy(child.gameObject); } visibleItemList.Add(item); } return(visibleItemList); }
/// <summary> /// Create a build /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='branch'> /// The branch name /// </param> /// <param name='ownerName'> /// The name of the owner /// </param> /// <param name='appName'> /// The name of the application /// </param> /// <param name='paramsParameter'> /// Parameters of the build /// </param> public static Build Create(this IBuilds operations, string branch, string ownerName, string appName, BuildParams paramsParameter = default(BuildParams)) { return(operations.CreateAsync(branch, ownerName, appName, paramsParameter).GetAwaiter().GetResult()); }