public void removeObject(GameObject obj) { GridData data = objectToGridData[obj.GetHashCode()]; this.updateGrid(data.fromX, data.fromY, data.toX, data.toY, -data.cost); objectToGridData.Remove(obj.GetHashCode()); //Debug.Log(string.Format("{0} at ({1},{2}) ({3}, {4})", obj.GetHashCode(), data.fromX, data.fromY, data.toX, data.toY)); }
private UnitBase findTarget(GameObject target) { foreach (UnitBase unit in UnitHandler.units) { if (unit.unit.GetHashCode() == target.GetHashCode()) return unit; } return null; }
void OnMouseDown() { if (!connectedLine) { // instantiate Line after clicking circle line = Instantiate(Resources.Load("LinePrefab")) as GameObject; line.name = "Line_(" + line.GetHashCode() + ")"; line.GetComponent <Bezier_Spline>().originObject = this.gameObject; } }
public static string GetID(GameObject g) { foreach(KeyValuePair<string,GameObject> entry in objects) { if (entry.Value.GetHashCode().Equals(g.GetHashCode())) { return entry.Key; break; } } return "UnregisteredObject"; }
public void player_onExitWave(GameObject go) { if (gameObject.GetHashCode() == go.GetHashCode()) { if (statustext != null) { statustext.text = "Status: out of range"; } } }
private void HandleInfectedMove() { float possibleTargetDistance = 0; GameObject possibleTarget = null; foreach (GameObject npc in _npcs) { if (!npc.activeSelf) { continue; } float distance = Vector3.Distance(transform.position, npc.transform.position); if (distance <= AWARANESS_RADIUS_INFECTED) { if (possibleTarget == null || distance < possibleTargetDistance) { PlayerController pc = npc.GetComponent <PlayerController>(); if (pc == null || pc != null && pc._moving) // don't follow the player if not moving { possibleTarget = npc; possibleTargetDistance = distance; } } } } if (possibleTarget == null) // no target available in this frame, let's just cruise { Wondering(); } else { if (possibleTarget.GetHashCode() != _currentTarget) { _currentTarget = possibleTarget.GetHashCode(); StopAndResetAgent(); } MoveViaAgent(possibleTarget); } }
public override int GetHashCode() { unchecked { int hash = 17; hash = hash * 29 + Type.GetHashCode(); hash = hash * 29 + Listener.GetHashCode(); hash = hash * 29 + Callback.GetHashCode(); return(hash); } }
public override int GetHashCode() { unchecked { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ (Rows != null ? Rows.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TilePrefab != null ? TilePrefab.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (TilesParent != null ? TilesParent.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (SlotRows != null ? SlotRows.GetHashCode() : 0); return(hashCode); } }
public static GameObject Clone(GameObject prefab, Transform parent, string objName = null) { GameObject clone = (GameObject)prefab.InstantiateEx(); clone.SetActive(true); clone.name = string.IsNullOrEmpty(objName) ? (prefab.name + clone.GetHashCode()) : objName; clone.transform.SetParent(parent); clone.transform.localPosition = prefab.transform.localPosition; clone.transform.localScale = prefab.transform.localScale; return(clone); }
public static Unit getUnit(GameObject gameObject) { int hashCode = gameObject.GetHashCode(); if (unitMap.ContainsKey(hashCode)){ return unitMap[hashCode]; } else { return null; } }
internal void AddOnOutsideClickHandler(GameObject gameObject, Action action) { int hashCode = gameObject.GetHashCode(); if (!_onOutsideClickHandlers.ContainsKey(hashCode)) { _onOutsideClickHandlers.Add(hashCode, new ActionTracker(gameObject)); } _onOutsideClickHandlers[hashCode].Add(action); }
public static WebView New(Rect frame) { var go = new GameObject(); go.name = "WebView_" + go.GetHashCode().ToString(); GameObject.DontDestroyOnLoad(go); var webView = go.AddComponent <WebView>(); webView.Initialize(frame); return(webView); }
public override int GetHashCode() { int hash = SceneCullingMask.GetHashCode(); if (!ReferenceEquals(PickableObject, null)) { hash ^= PickableObject.GetHashCode(); } return(hash); }
public static Pool Get(GameObject prefab) { var hasPool = _pools.TryGetValue(prefab.GetHashCode(), out var pool); if (!hasPool) { pool = new Pool(prefab, 0); } return(pool); }
public static void AddBindIcon(GameObject parent) { var tex = GetBindIconTex(parent); var icon = panel.AddImage($"{parent.name}_{parent.GetHashCode()}", tex, new Vector2(offset, 0), new Vector2(tex.width / 3, tex.height / 3), new Rect(0, 0, tex.width, tex.height)); icon.SetColor(Color.yellow); offset += tex.width / 3; parent.AddComponent <Attach>(); Logger.LogDebug("Added Hud Icon"); }
void InitializeAsteroids() { for (int i = 0; i < maxAsteroids; i++) { GameObject f = Instantiate(asteroid, new Vector3(0, 0, 500), Quaternion.identity); asteroids.Add(f.GetHashCode(), f); // Group asteroids under Arena f.transform.parent = transform.parent.Find("Asteroids"); f.SetActive(false); } }
/// <summary> /// Returns all CollisionObjects where the CollidingBlock is the passed GameObject /// </summary> /// <param name="gameObject">The searched GameObject</param> /// <returns>List of CollisionObjects containing the passed GameObject</returns> public List <CollisionObject> GetCollisionObjectsForGameObject(GameObject gameObject) { List <CollisionObject> collisionList = new List <CollisionObject>(colliderDictionary.Values); //Remove all empty CollisionObjects collisionList.RemoveAll(block => block.CollidedBlock == null); //Remove all CollisionObjects which don't contain the right collidedBlock collisionList.RemoveAll(block => block.CollidedBlock.GetHashCode() != gameObject.GetHashCode()); return(collisionList); }
public void player_onEnterWave(GameObject go) { //Filter by Hash if (gameObject.GetHashCode() == go.GetHashCode()) { if (statustext != null) { statustext.text = "Status: HIT"; } } }
//thanks again, stack overflow public override int GetHashCode() { unchecked // Overflow is fine, just wrap { int hash = 17; // Suitable nullity checks etc, of course :) hash = hash * 23 + spawn.GetHashCode(); hash = hash * 23 + spawnChance.GetHashCode(); hash = hash * 23 + location.GetHashCode(); return(hash); } }
/// <summary> /// 添加单击事件 /// </summary> public void AddClick(GameObject go, LuaFunction luafunc) { if (go == null || luafunc == null) { return; } //此处会有go.GetHashCode()相同的可能,九千多个对象会有1%的重复可能,7万多个会有50%的重复可能 buttons.Add(go.name + go.GetHashCode(), luafunc); UIEventListener.Get(go).onClick = delegate(GameObject o) { luafunc.Call(go); }; }
public static void AddTag(this GameObject instance, Tag tag) { #if UNITY_EDITOR var taggable = GetComponent(instance); if (!taggable.Contains(tag)) { taggable.Add(tag); } #endif tag.Add(instance, instance.GetHashCode()); }
// Use this for initialization void Start() { prefabs = new GameObject[amount]; for (int i = 0; i < amount; i++) { Vector2 randPos = Random.insideUnitCircle * range; Vector3 randPos3 = new Vector3(randPos.x, 0.05f, randPos.y); GameObject destination = (GameObject)Instantiate(prefab, randPos3, Quaternion.Euler(270, 0, 0)); destination.name = "Dest " + destination.GetHashCode(); prefabs[i] = destination; } }
public void registerObject(GameObject obj, float x, float y, float width, float height, int cost) { GridData d = new GridData(); d.cost = cost; d.xOffset = obj.transform.position.x - x; d.yOffset = obj.transform.position.y - y; getGridCoords(x - width/2, y - height/2, out d.fromX, out d.fromY); getGridCoords(x + width/2, y + height/2, out d.toX, out d.toY); objectToGridData[obj.GetHashCode()] = d; this.updateGrid(d.fromX, d.fromY, d.toX, d.toY, cost); //Debug.Log(string.Format("Registered object: {0} at ({1},{2}) ({3}, {4})", obj.GetHashCode(), d.fromX, d.fromY, d.toX, d.toY)); }
private static int GetPrefabId(GameObject gameObject) { int objectId = gameObject.GetHashCode(); GameObjectPoolReference poolReferenceComp = gameObject.GetComponent <GameObjectPoolReference>(); if (poolReferenceComp != null) { objectId = poolReferenceComp.PrefabID; } return(objectId); }
// Start is called before the first frame update void Start() { _rnd = new Random((uint)UnityEngine.Random.Range(1, 100000)); _hero = GetComponent <Rigidbody2D>(); _heroZone = GetComponent <CapsuleCollider2D>(); _heroImages = GetComponentsInChildren <SpriteRenderer>(); Debug.Log($"Init projectile {projectile.GetHashCode()}"); _direction = new Vector3(1, 0); _gun = _marker.GetComponent <GunScript>(); _direction = new Vector3(1, 0).normalized; _currentDirection = new Vector3(1, 0); }
public override int GetHashCode() { unchecked { int hashCode = (gameObject != null ? gameObject.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (mesh != null ? mesh.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (vertexes != null ? vertexes.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (edges != null ? edges.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (faces != null ? faces.GetHashCode() : 0); return(hashCode); } }
void Start() { if (prefab) { if (ToolsUIManager.Instance != null) { ToolsUIManager.Instance.RegisterUI3DObject(prefab); uid = prefab.GetHashCode(); transform.localRotation = AssetBankUtils.thumbnailRotation; } } }
public override void OnUpdate(double deltaTime) { IScene scene = GameObject.Scene; IObject[] objects = scene.GetObjects().Value; Vec3 obj1 = GameObject.Position; Vec3 bound1 = GameObject.Bounds; for (int i = 0; i < objects.Length; i++) { if (objects[i].GetHashCode() != GameObject.GetHashCode() && objects[i] is IGameObject gameObject) { Vec3 obj2 = gameObject.Position; Vec3 bound2 = gameObject.Bounds; if (bound1.X <= 0 && bound1.Y <= 0 && bound1.Z <= 0 || bound2.X <= 0 && bound2.Y <= 0 && bound2.Z <= 0) { continue; } if (obj1.X < obj2.X + bound2.X && obj1.X + bound1.X > obj2.X && obj1.Y < obj2.Y + bound2.Y && obj1.Y + bound1.Y > obj2.Y && obj1.Z < obj2.Z + bound2.Z && obj1.Z + bound1.Z > obj2.Z) { if (Entered && HitGameObject.GetHashCode() == gameObject.GetHashCode()) { OnCollisionStay(gameObject); } else if (!Entered && HitGameObject == null) { Entered = true; HitGameObject = gameObject; OnCollisionEnter(gameObject); } break; } if (Entered && HitGameObject.GetHashCode() == gameObject.GetHashCode()) { Entered = false; HitGameObject = null; OnCollisionLeave(gameObject); break; } } } }
public static GameObject Alloc(string prefabPath, Vector3 pos, Quaternion rot, System.Action <GameObject> func = null) { int pathHash = prefabPath.GetHashCode(); Object prefabObj = null; Instance._prefabMap.TryGetValue(pathHash, out prefabObj); if (prefabObj == null) { prefabObj = Resources.Load(prefabPath); if (prefabObj == null) { //Debug.LogErrorFormat("Can't found Prefab : {0}", prefabPath); return(null); } Instance._prefabMap[pathHash] = prefabObj; } GameObject gameObj = null; int hash = prefabObj.GetHashCode(); Pool pool = null; Instance._pool.TryGetValue(hash, out pool); if (pool == null) { pool = new Pool(prefabObj, prefabPath, Instance.gameObject); Instance._pool[hash] = pool; } gameObj = pool.Alloc(pos, rot, func); if (gameObj == null) { return(null); } int objHash = gameObj.GetHashCode(); if (Instance._hashMap.ContainsKey(objHash) == false) { Instance._hashMap.Add(objHash, hash); } #if UNITY_EDITOR //Instance.SetDebugName(); #endif return(gameObj); }
public static void SetPeer(GameObject gameObject, Component component) { var hashCode = gameObject.GetHashCode(); if (!peers.ContainsKey(hashCode)) { peers.Add(hashCode, new Dictionary <Type, WeakReference <Component> >()); } var compDic = peers[hashCode]; compDic[component.GetType()] = new WeakReference <Component>(component); }
/// <summary> /// Trigger Exit function of the Box Collider, is triggered when a Collider of a Block exits /// Box. Block is removed from List if last refernce of Block is removed from List /// </summary> /// <param name="other">Collider of the Block</param> private void OnTriggerExit(Collider other) { GameObject block = other.transform.root.gameObject; //Remove the first found Block from the List markedBlocks.Remove(block); //Marking ends if no Block is in the List anymore if (!markedBlocks.Exists(tempBlock => tempBlock.GetHashCode() == block.GetHashCode())) { block.SendMessageUpwards("OnMarkedEnd", SendMessageOptions.DontRequireReceiver); } }
public override bool Equals(object rhs) { if (rhs == null) { return(this.gameObject == null ? true : false); } else if (this.gameObject == null) { return(false); } if (rhs is z_EditableObject) { return(rhs.Equals(this)); } else if (rhs is GameObject) { return(((GameObject)rhs).GetHashCode() == gameObject.GetHashCode()); } return(false); }
private void SelectGameObject(GameObject go, string id) { if (go.GetHashCode().ToString() == id) { Selection.activeObject = go; return; } for (int i = 0; i < go.transform.childCount; ++i) { SelectGameObject(go.transform.GetChild(i).gameObject, id); } }
private static bool IsValidObjectToBePicked() { for (int i = 0; i < Selection.gameObjects.Length; i++) { // Do not pick itself if (Selection.gameObjects[i].GetHashCode() == destGameObject.GetHashCode()) { return(false); } } return(true); }
/// <summary> /// 添加对象 /// </summary> /// <param name="gameObject">Game object.</param> public void PushObject(GameObject gameObject) { int hashKey = gameObject.GetHashCode(); if (!this.objectHash.ContainsKey(hashKey)) { this.objectHash.Add(hashKey, new PoolItemTime(gameObject)); } else { this.objectHash[hashKey].Active(); } }
/// <summary> /// 添加对象,往同一对象池里添加对象 /// </summary> public void PushObject(GameObject _gameObject) { int hashKey = _gameObject.GetHashCode(); if (!this.objectList.ContainsKey(hashKey)) { this.objectList.Add(hashKey, new Object(_gameObject)); } else { this.objectList[hashKey].Active(); } }
public static IEnumerator moveToPoint(GameObject subject, Vector3 targetPoint) { MotionAgent motionAgent; if (Instance.map.ContainsKey(subject.GetHashCode())) { motionAgent = Instance.map[subject.GetHashCode()]; if (motionAgent.navMeshObstacle.enabled) { motionAgent.navMeshObstacle.enabled = false; yield return null; yield return null; } if (!motionAgent.navMeshAgent.enabled) { motionAgent.navMeshAgent.enabled = true; } } else { motionAgent = new MotionAgent(subject, targetPoint); motionAgent.navMeshObstacle.enabled = false; yield return null; yield return null; motionAgent.navMeshAgent.enabled = true; Instance.map.Add(subject.GetHashCode(), motionAgent); } //Instance.agentList.Add(motionAgent); motionAgent.isStop = false; motionAgent.navMeshAgent.SetDestination(targetPoint); yield return null; Debug.Log(motionAgent.navMeshAgent.remainingDistance); yield return motionAgent; }
/// <summary> /// Creates this cache entry /// Automatically gets reference to the EntityTag of the Entity /// </summary> /// <param name="Entity">GameEntity to cache</param> public GameEntityCacheEntry(GameObject Entity) { if(Entity.tag != "GameEntity") { Debug.LogError("Attempted to cache a non GameEntity GameObject. Blocked"); Entity = null; Tag = null; } this.Entity = Entity; Tag = Entity.GetComponent<EntityTag>(); EntityHash = Entity.GetHashCode(); }
public void updateObjectPosition(GameObject obj) { GridData data = objectToGridData[obj.GetHashCode()]; // Remove old weight from old positions this.updateGrid(data.fromX, data.fromY, data.toX, data.toY, -data.cost); // calculate new positions var width = data.toX - data.fromX; var height = data.toY - data.fromY; getGridCoords(obj.transform.position.x + data.xOffset - width/2, obj.transform.position.y + data.yOffset - height/2, out data.fromX, out data.fromY); getGridCoords(obj.transform.position.x + data.xOffset + width/2, obj.transform.position.y + data.yOffset + height/2, out data.toX, out data.toY); // update map objectToGridData[obj.GetHashCode()] = data; // Add weight to new positions this.updateGrid(data.fromX, data.fromY, data.toX, data.toY, -data.cost); //Debug.Log(string.Format("{0} at ({1},{2}) ({3}, {4})", obj.GetHashCode(), data.fromX, data.fromY, data.toX, data.toY)); }
private bool HasGameObjectInHeirarchy(GameObject gameObject, int hashCodeToSearchFor) { if (gameObject.GetHashCode() == hashCodeToSearchFor) return true; foreach (Transform child in gameObject.transform) { if (HasGameObjectInHeirarchy(child.gameObject, hashCodeToSearchFor)) return true; } return false; }
private void EvalutateOnOutsideClick(GameObject gameObjectBeingClicked) { int hashOfClickedItem = gameObjectBeingClicked.GetHashCode(); foreach (var kvp in _onOutsideClickHandlers) { // Create a strong reference to this variable so that it can't be collected after "HasExpired" evalutes var gameObject = kvp.Value.GameObject; if (!kvp.Value.HasExpired && !HasGameObjectInHeirarchy(gameObject, hashOfClickedItem)) { kvp.Value.Execute(); } } }
/// <summary> /// Adds a GameObject as a subject of this /// panel's transitions. /// </summary> /// <param name="go">GameObject to be added as a subject.</param> public void AddSubject(GameObject go) { int hash = go.GetHashCode(); if (subjects.ContainsKey(hash)) return; subjects.Add(hash, go); for (int i = 0; i < Transitions.list.Length; ++i) Transitions.list[i].AddSubSubject(go); // Add the subject to any parent container as well: if (container != null) container.AddSubject(go); }
/// <summary> /// Removes a GameObject as a subjects of /// this panel's transitions. /// </summary> /// <param name="go">GameObject to be removed as a subject.</param> public void RemoveSubject(GameObject go) { int hash = go.GetHashCode(); if (!subjects.ContainsKey(hash)) return; subjects.Remove(hash); for (int i = 0; i < Transitions.list.Length; ++i) Transitions.list[i].RemoveSubSubject(go); // Remove the subject from any parent container as well: if (container != null) container.RemoveSubject(go); }
/// <summary> /// Removes a GameObject as a subjects of /// this panel's transitions. /// </summary> /// <param name="go">GameObject to be removed as a subject.</param> public void RemoveSubject(GameObject go) { int hash = go.GetHashCode(); if (!subjects.ContainsKey(hash)) return; subjects.Remove(hash); for (int i = 0; i < Transitions.list.Length; ++i) Transitions.list[i].RemoveSubSubject(go); }
public static void add(GameObject gameObject,Unit unit) { unitMap.Add(gameObject.GetHashCode(), unit); }