/// <summary> /// Instantiates clickable number objects in the scene. Number of objects /// depends on the difficulty level. Number of objects = game level. /// <param name="gameLevel"> The game level. </param> /// </summary> private void InstantiateNumberObjects(int gameLevel) { // initialization Vector2 randomPosition = Vector2.zero; for (int i = 0; i < gameLevel; i++) { // set number value, color & instantiate number object NumberObjectPrefab.GetComponent <Text>().text = _orderedNumbers[i].ToString(); NumberObjectPrefab.GetComponent <Text>().color = _levelManager.GetRandomColor(); // generate position for the number game object while (true) { float x = Random.Range(-ScreenWidth / 2, ScreenWidth / 2); float y = Random.Range(-ScreenHeight / 2, (ScreenHeight - 100) / 2); randomPosition.x = x; randomPosition.y = y; bool canSpawnHere = PhysicsUtil.CheckBounds2D(randomPosition, ScreenDimens); // is the position valid? if (canSpawnHere) { break; } } GameObject newObject = Instantiate(NumberObjectPrefab, randomPosition, UIController.Identity()); _instantiatedObjects.Add(newObject); // make the number object a child of the canvas _instantiatedObjects[i].transform.SetParent(GameObject.Find("Container").transform, false); } }
public PhysicsUtil() { if (INSTANCE == null || INSTANCE != this) { INSTANCE = this; } }
protected override bool TestVisibility(VisualAspect aspect) { if (this.RequiresLineOfSight) { var v = aspect.transform.position - this.transform.position; //RaycastHit[] hits = Physics.RaycastAll(this.transform.position, v, v.magnitude, this.LineOfSightMask); //foreach (var hit in hits) //{ // //we ignore ourself // var r = hit.collider.FindRoot(); // if (r != aspect.entityRoot && r != this.entityRoot) return false; //} using (var lst = com.spacepuppy.Collections.TempCollection.GetList <RaycastHit>()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, this.LineOfSightMask); for (int i = 0; i < cnt; i++) { //we ignore ourself var r = lst[i].collider.FindRoot(); if (r != aspect.entityRoot && r != this.entityRoot) { return(false); } } } } return(true); }
protected bool IsLineOfSight(Collider coll) { var v = coll.GetCenter() - this.transform.position; //RaycastHit hit; //if(Physics.Raycast(this.transform.position, v, out hit, v.magnitude, _lineOfSightMask)) //{ // return (hit.collider == coll); //} using (var lst = com.spacepuppy.Collections.TempCollection.GetList <RaycastHit>()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, _lineOfSightMask); if (cnt > 0) { var otherRoot = coll.FindRoot(); for (int i = 0; i < cnt; i++) { //we ignore ourself var r = lst[i].collider.FindRoot(); if (r != otherRoot && r != this.entityRoot) { return(false); } } } } return(true); }
private IEnumerator Detonate() { for (int i = 0; i < Flashes; i++) { spriteRenderer.color = FlashColor; yield return(new WaitForSeconds(FlashTime)); spriteRenderer.color = Color.white; yield return(new WaitForSeconds(FlashTime)); } Instantiate(ExplosionPrefab, transform.position, Quaternion.identity); var caughtInExplosion = Physics2D.OverlapCircleAll(transform.position, ExplosionRadius); foreach (var item in caughtInExplosion) { if (item != this.GetComponent <Collider2D>()) { if (!item.CompareTag("Enemy")) { item.SendMessage("TakeDamage", ExplosionDamage, SendMessageOptions.DontRequireReceiver); } var itemRigidbody = item.GetComponent <Rigidbody2D>(); if (itemRigidbody) { itemRigidbody.AddForce(Vector2.up * 1, ForceMode2D.Impulse); PhysicsUtil.AddExplosionForce2D(itemRigidbody, ExplosionForce, transform.position, ExplosionRadius); } } } this.SendMessage("InstaDie"); }
public static bool Prefix(KillOnTrigger __instance, Collider collider) { if (SRCheatMenu.infiniteHealth && PhysicsUtil.IsPlayerMainCollider(collider)) { //SRCheatMenu.Log("DEBUG: KillOnTrigger Player");//DEBUG return(false); } return(true); }
protected override bool TestVisibility(VisualAspect aspect) { //if not in cylinder, can not see it var halfHeight = _height / 2.0f; var rod = this.Rod; var center = this.GetCenterInWorldSpace(); var otherPos = aspect.transform.position; if (!Cylinder.ContainsPoint(center - (rod * halfHeight), center + (rod * halfHeight), _radius, _innerRadius, otherPos)) { return(false); } if (this._angle < 360.0f) { var v = VectorUtil.SetLengthOnAxis(otherPos - center, rod, 0f); var a = Vector3.Angle(this.transform.forward, v); if (a > this._angle / 2.0f) { return(false); } } if (this.RequiresLineOfSight) { var v = otherPos - center; //RaycastHit[] hits = Physics.RaycastAll(this.transform.position, v, v.magnitude, this.LineOfSightMask); //foreach (var hit in hits) //{ // //we ignore ourself // var r = hit.collider.FindRoot(); // if (r != aspect.entityRoot && r != this.entityRoot) return false; //} using (var lst = com.spacepuppy.Collections.TempCollection.GetList <RaycastHit>()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, this.LineOfSightMask); for (int i = 0; i < cnt; i++) { //we ignore ourself var r = lst[i].collider.FindRoot(); if (r != aspect.entityRoot && r != this.entityRoot) { return(false); } } } } return(true); }
public void Shoot(Vector3 target) { _collider.enabled = true; _targetAcquired = true; _isObjectHit = false; _rBody.isKinematic = false; Vector3 vel = PhysicsUtil.GetParabolaInitVelocity(transform.position, target, Physics.gravity.y, heightOff: Mathf.Abs(transform.position.y - target.y) < 1 ? 1 : 0); _rBody.velocity = vel; Invoke("DisableSelf", _disableTime); }
private static T SetupDoorBase <T>(CPBlock block, SecurityDoor door) where T : CPContext, new() { Vector3 position = door.m_bioScanAlign.position; if (!PhysicsUtil.SlamPos(ref position, Vector3.down, 4.0f, LayerManager.MASK_LEVELGEN, false, 0f, 1.0f)) { return(null); } return(SetupBase <T>(block, door.Gate.ProgressionSourceArea, position, door.transform)); }
public override void update(float dt) { if ((base.Character.TargetCharacter == null) || (PhysicsUtil.DistBetween(base.Character, base.Character.TargetCharacter) < 3f)) { this.m_meleeAttackBehaviour.update(dt); } else { this.m_rangedAttackBehaviour.update(dt); } }
public override void update(float dt) { ActiveDungeon activeDungeon = GameLogic.Binder.GameState.ActiveDungeon; CharacterInstance primaryPlayerCharacter = activeDungeon.PrimaryPlayerCharacter; if (!base.Character.isExecutingSkill()) { if ((base.Character.ManualTargetPos != Vector3.zero) && (PhysicsUtil.DistBetween(base.Character, base.Character.ManualTargetPos) > 1f)) { this.m_movementBehaviour.update(dt); } else if ((!primaryPlayerCharacter.IsDead && (primaryPlayerCharacter.CurrentHpNormalized <= 0.5f)) && (Time.fixedTime >= this.m_nextPossibleSkillExecutionTime)) { if (base.Character.TargetCharacter != primaryPlayerCharacter) { CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter, Vector3.zero); } if (base.Character.PhysicsBody.rotatedEnoughForMovement()) { GameLogic.Binder.SkillSystem.activateSkill(base.Character, SkillType.Heal, -1f, null); this.m_nextPossibleSkillExecutionTime = Time.fixedTime + ConfigSkills.SHARED_DATA[SkillType.Heal].Cooldown; } } else if (((primaryPlayerCharacter.TargetCharacter != null) && (PhysicsUtil.DistBetween(primaryPlayerCharacter, primaryPlayerCharacter.TargetCharacter) > ConfigGameplay.PASSIVE_HP_REGEN_PROXIMITY_THRESHOLD)) || (primaryPlayerCharacter.ManualTargetPos != Vector3.zero)) { if ((base.Character.TargetCharacter != primaryPlayerCharacter.TargetCharacter) || (base.Character.ManualTargetPos != primaryPlayerCharacter.ManualTargetPos)) { CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter.TargetCharacter, primaryPlayerCharacter.ManualTargetPos); } this.m_movementBehaviour.update(dt); this.m_seekTacticalPosition = true; } else if (this.m_seekTacticalPosition) { this.m_targetingAiBehaviour.update(dt); if (base.Character.TargetCharacter != null) { Vector3 worldPt = base.Character.TargetCharacter.PhysicsBody.Transform.position - ((Vector3)(base.Character.TargetCharacter.PhysicsBody.Transform.forward * 1.5f)); worldPt = activeDungeon.ActiveRoom.calculateNearestEmptySpot(worldPt, worldPt - base.Character.TargetCharacter.PhysicsBody.Transform.position, 1f, 1f, 6f, null); CmdSetCharacterTarget.ExecuteStatic(base.Character, null, worldPt); this.m_seekTacticalPosition = false; } } else { this.m_targetingAiBehaviour.update(dt); this.m_movementBehaviour.update(dt); if (((base.Character.TargetCharacter != null) && this.m_movementBehaviour.WithinAttackDistance) && base.Character.PhysicsBody.rotatedEnoughForMovement()) { base.Character.AttackRoutine = GameLogic.Binder.CommandProcessor.executeCharacterSpecific(base.Character, new CmdAttackMelee(base.Character, base.Character.TargetCharacter), 0f); } } } }
public void Init() { this.rigidbody = base.GetComponent <Rigidbody>(); this.effectInstance = Instantiate <GameObject>(this.brokenEffect); PhysicsUtil.SetGameObjectLayer(this.effectInstance, Layers.MINOR_VISUAL); this.partRigidbodies = this.effectInstance.GetComponentsInChildren <Rigidbody>(); this.renderers = this.effectInstance.GetComponentsInChildren <Renderer>(); this.nameToMaterial = new Dictionary <string, Material>(); this.SaveTransforms(); this.Disable(); this.inited = true; }
public void Spray(SprayEvent e, SingleNode <GraffitiInstanceComponent> graffitiInstanceNode, [JoinByUser] WeaponNode weaponNode) { RaycastHit hit; MuzzleLogicAccessor accessor = new MuzzleLogicAccessor(weaponNode.muzzlePoint, weaponNode.weaponInstance); Vector3 worldPosition = accessor.GetWorldPosition(); Vector3 barrelOriginWorld = accessor.GetBarrelOriginWorld(); Vector3 dir = worldPosition - barrelOriginWorld; if (PhysicsUtil.RaycastWithExclusion(barrelOriginWorld, dir, out hit, (worldPosition - barrelOriginWorld).magnitude + 10f, LayerMasks.VISUAL_STATIC, null)) { base.ScheduleEvent(new CreateGraffitiEvent(barrelOriginWorld, dir, weaponNode.weaponInstance.WeaponInstance.transform.up), graffitiInstanceNode); } }
private void MeasurementUpdateCorrection(Vector3 data) { float val = (FACTOR_MEASURED_VALUE_TO_PREVIOUS_VALUE * this.predictedCovariance) / (((FACTOR_MEASURED_VALUE_TO_PREVIOUS_VALUE * this.predictedCovariance) * FACTOR_MEASURED_VALUE_TO_PREVIOUS_VALUE) + ENVIRONMENT_NOISE); if (!PhysicsUtil.IsValidFloat(val)) { this.Reset(this.State); } else { this.State = this.predictedState + (val * (data - (FACTOR_MEASURED_VALUE_TO_PREVIOUS_VALUE * this.predictedState))); this.covariance = (1f - (val * FACTOR_MEASURED_VALUE_TO_PREVIOUS_VALUE)) * this.predictedCovariance; } }
protected override bool TestVisibility(VisualAspect aspect) { //if not in cylinder, can not see it float aspRad = aspect.Radius; if (aspRad > MathUtil.EPSILON) { if (!Cone.ContainsSphere(this.transform.position, this.transform.position + this.Direction * _range, _startRadius, _endRadius, aspect.transform.position, aspRad)) { return(false); } } else { if (!Cone.ContainsPoint(this.transform.position, this.transform.position + this.Direction * _range, _startRadius, _endRadius, aspect.transform.position)) { return(false); } } if (this.LineOfSightMask.value != 0) { var v = aspect.transform.position - this.transform.position; using (var lst = com.spacepuppy.Collections.TempCollection.GetList <RaycastHit>()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, this.LineOfSightMask); for (int i = 0; i < cnt; i++) { //we ignore ourself var r = lst[i].collider.FindRoot(); if (r != aspect.entityRoot && r != this.entityRoot) { return(false); } } } } return(true); }
private void OnDrawGizmosSelected() { Vector3?vector = PhysicsUtil.IntersectionPointWithLayer(base.gameObject, LayerConstants.GetPlayerLayerCollisionMask(), 20f, Vector3.down); if (vector.HasValue) { Gizmos.color = GeyserColor; Gizmos.DrawLine(base.gameObject.transform.position, vector.Value); Gizmos.DrawSphere(vector.Value, 0.05f); Gizmos.DrawWireSphere(vector.Value, GeyserDiameter / 2f); Gizmos.color = MagnetColor; Gizmos.DrawSphere(vector.Value + new Vector3(0f, GeyserHeight, 0f), 0.05f); Gizmos.DrawWireSphere(vector.Value + new Vector3(0f, GeyserHeight, 0f), MagnetDiameter / 2f); } }
public static List <int> abilityAoeDamage(int characterId, ETeam characterTeamId, Vector2 position, Vector2 attackPoint, Vector2 direction, float radius, float range, int damage) { Vector2 point = position + attackPoint + direction * range; List <CharacterObject> objectsHit = PhysicsUtil.findCharactersInRadius(characterId, point, radius); List <int> returnList = new List <int>(); foreach (CharacterObject objectHit in objectsHit) { if (objectHit.teamId != characterTeamId) { returnList.Add(objectHit.id); } } return(returnList); }
private void BuildContainer(Transform containerPosition, Object containerPrefab, Transform hangarCamera) { containerPosition.DestroyChildren(); GameObject hull = (GameObject)Object.Instantiate(containerPrefab); hull.transform.SetParent(containerPosition.transform); hull.transform.localPosition = Vector3.zero; hull.transform.localRotation = Quaternion.identity; PhysicsUtil.SetGameObjectLayer(containerPosition.gameObject, Layers.HANGAR); Renderer containerRenderer = TankBuilderUtil.GetContainerRenderer(hull); BurningTargetBloom componentInChildren = hangarCamera.GetComponentInChildren <BurningTargetBloom>(); componentInChildren.targets.Clear(); componentInChildren.targets.Add(containerRenderer); }
private void initialize() { isEventFogActive = false; isAdjustmentOverride = false; geyserPhase = GeyserPhase.None; int num = CollectibleObjects.Length; spawnPoint = new Vector3?[num]; for (int i = 0; i < num; i++) { GameObject gameObject = CollectibleObjects[i]; ref Vector3?reference = ref spawnPoint[i]; reference = PhysicsUtil.IntersectionPointWithLayer(gameObject, LayerConstants.GetPlayerLayerCollisionMask(), 20f, Vector3.down); gameObject.SetActive(value: false); }
public void BuildTank(NodeAddedEvent e, HangarTankBaseSystem.HangarNode hangar, HangarTankBaseSystem.WeaponSkinItemPreviewLoadedNode weaponSkin, [Context, JoinByParentGroup] HangarTankBaseSystem.WeaponItemPreviewNode weaponItem, HangarTankBaseSystem.HullSkinItemPreviewLoadedNode tankSkin, [Context, JoinByParentGroup] HangarTankBaseSystem.TankItemPreviewNode tankItem, TankPaintItemPreviewLoadedNode tankPaint, WeaponPaintItemPreviewLoadedNode weaponPaint, HangarTankBaseSystem.HangarCameraNode hangarCamera, SingleNode <SupplyEffectSettingsComponent> settings) { Transform root = hangar.hangarTankPosition.transform; root.DestroyChildren(); GameObject tankInstance = (GameObject)Object.Instantiate(tankSkin.resourceData.Data); tankInstance.transform.SetParent(root); tankInstance.transform.localPosition = Vector3.zero; tankInstance.transform.localRotation = Quaternion.identity; tankSkin.hangarItemPreview.Instance = tankInstance; tankInstance.GetComponentInChildren <NitroEffectComponent>().InitEffect(settings.component); Transform mountPoint = tankInstance.GetComponent <MountPointComponent>().MountPoint; GameObject weaponInstance = (GameObject)Object.Instantiate(weaponSkin.resourceData.Data); weaponInstance.transform.SetParent(tankInstance.transform); weaponInstance.transform.localPosition = mountPoint.localPosition; weaponInstance.transform.localRotation = mountPoint.localRotation; weaponSkin.hangarItemPreview.Instance = weaponInstance; GameObject tankPaintInstance = (GameObject)Object.Instantiate(tankPaint.resourceData.Data); tankPaintInstance.transform.SetParent(tankInstance.transform); tankPaintInstance.transform.localPosition = Vector3.zero; GameObject weaponPaintInstance = (GameObject)Object.Instantiate(weaponPaint.resourceData.Data); weaponPaintInstance.transform.SetParent(tankInstance.transform); weaponPaintInstance.transform.localPosition = Vector3.zero; PhysicsUtil.SetGameObjectLayer(root.gameObject, Layers.STATIC); this.ApplyPaint(tankInstance, weaponInstance, tankPaintInstance, weaponPaintInstance); weaponInstance.GetComponentInChildren <DoubleDamageEffectComponent>().InitEffect(settings.component); weaponInstance.GetComponentInChildren <DoubleDamageSoundEffectComponent>().RecalculatePlayingParameters(); Renderer weaponRenderer = TankBuilderUtil.GetWeaponRenderer(weaponInstance); weaponRenderer.tag = "TankWeapon"; Renderer hullRenderer = TankBuilderUtil.GetHullRenderer(tankInstance); hullRenderer.tag = "TankHull"; weaponRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; weaponRenderer.lightProbeUsage = LightProbeUsage.Off; hullRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; hullRenderer.lightProbeUsage = LightProbeUsage.Off; BurningTargetBloom componentInChildren = hangarCamera.cameraRootTransform.Root.GetComponentInChildren <BurningTargetBloom>(); componentInChildren.targets.Clear(); componentInChildren.targets.Add(weaponRenderer); componentInChildren.targets.Add(hullRenderer); base.ScheduleEvent <HangarTankBuildedEvent>(hangar); }
public override bool Execute(string[] args) { if (args.Length < 1 || args.Length > 2) { Console.LogError("Incorrect number of arguments!"); return(false); } Identifiable.Id id; GameObject prefab; try { id = (Identifiable.Id)Enum.Parse(typeof(Identifiable.Id), args[0], true); prefab = GameContext.Instance.LookupDirector.GetPrefab(id); } catch { Console.LogError("Invalid ID!"); return(false); } int count = 0; if (args.Length != 2 || !Int32.TryParse(args[1], out count)) { count = 1; } for (int i = 0; i < count; i++) { if (Physics.Raycast(new Ray(Camera.main.transform.position, Camera.main.transform.forward), out var hit)) { var spawned = SRBehaviour.InstantiateActor(prefab, SceneContext.Instance.Player.GetComponent <RegionMember>().setId, true); spawned.transform.position = hit.point + hit.normal * PhysicsUtil.CalcRad(spawned.GetComponent <Collider>()); var delta = -(hit.point - Camera.main.transform.position).normalized; var newForward = (delta - Vector3.Project(delta, hit.normal)).normalized; spawned.transform.rotation = Quaternion.LookRotation(delta, hit.normal); } } return(true); }
public void OnUpdate(TimeUpdateEvent e, RemoteSmoothTankNode node) { float deltaTime = e.DeltaTime; KalmanFilterComponent kalmanFilter = node.kalmanFilter; RemoteTankSmootherComponent remoteTankSmoother = node.remoteTankSmoother; Rigidbody rigidbody = node.rigidbody.Rigidbody; Transform transform = node.tankVisualRoot.transform; Transform rigidbodyTransform = node.rigidbody.RigidbodyTransform; this.KalmanFPSIndependentCorrect(kalmanFilter, rigidbodyTransform.position, deltaTime); float smoothingCoeff = deltaTime * remoteTankSmoother.smoothingCoeff; remoteTankSmoother.prevVisualPosition = this.SmoothPositionValue(remoteTankSmoother.prevVisualPosition, rigidbody.velocity, deltaTime, kalmanFilter.kalmanFilterPosition.State, smoothingCoeff); remoteTankSmoother.prevVisualRotation = this.SmoothRotationValue(remoteTankSmoother.prevVisualRotation, rigidbody.angularVelocity, deltaTime, rigidbodyTransform.rotation, smoothingCoeff); if (PhysicsUtil.IsValidVector3(remoteTankSmoother.prevVisualPosition) && PhysicsUtil.IsValidQuaternion(remoteTankSmoother.prevVisualRotation)) { transform.position = remoteTankSmoother.prevVisualPosition; transform.rotation = remoteTankSmoother.prevVisualRotation; } }
// Token: 0x06005583 RID: 21891 RVA: 0x001D81E8 File Offset: 0x001D65E8 private void Update() { if (this.Source == null || this.Target == null || this._renderer == null) { return; } Vector3 vector = this.Target.position; Collider component = this.Target.GetComponent <Collider>(); if (component != null) { vector = PhysicsUtil.ClosestPointOnCollider(component, this.Source.position); } base.transform.LookAt(vector); float magnitude = (vector - this.Source.position).magnitude; this.Source.localScale = new Vector3(magnitude, 1f, 1f); this._renderer.material.mainTextureScale = new Vector2(magnitude * this.TextureScale, 1f); this._renderer.material.mainTextureOffset += new Vector2(Time.deltaTime * this.ScrollSpeed, 0f); }
IEnumerator coinEff(int effnum, Vector2 tartgetpos) { var re = GetComponent <RectTransform>(); float maxx = re.rect.size.x; maxx = Camera.main.ScreenToWorldPoint(new Vector3(maxx, 0, 0)).x; for (int i = 0; i < effnum; i++) { yield return(new WaitForSeconds(0.1f)); Vector2 inipos = new Vector2(Random.Range(0, maxx), 0); //inipos = Camera.main.ScreenToWorldPoint(inipos); var ef = Instantiate(eff, transform); ef.GetComponent <RectTransform>().position = inipos; float centery = tartgetpos.y + Random.Range(50, 100); var li = PhysicsUtil.GetParabolaInitVelocity(inipos, tartgetpos, -9.8f, centery, 0) * buc; StartCoroutine(moveeff(ef, tartgetpos, li)); } yield return(new WaitForSeconds(effnum * 0.1f)); Shownext(); }
// Token: 0x06005390 RID: 21392 RVA: 0x001CD23C File Offset: 0x001CB63C public static Vector3 ClosestPointOnCollider(Collider col, Vector3 pt, ref bool isPointInside) { if (col == null) { return(Vector3.zero); } SphereCollider sphereCollider = col as SphereCollider; if (sphereCollider != null) { return(PhysicsUtil.ClosestPointOnCollider(sphereCollider, pt, ref isPointInside)); } BoxCollider boxCollider = col as BoxCollider; if (boxCollider != null) { return(PhysicsUtil.ClosestPointOnCollider(boxCollider, pt, ref isPointInside)); } CapsuleCollider capsuleCollider = col as CapsuleCollider; if (capsuleCollider != null) { return(PhysicsUtil.ClosestPointOnCollider(capsuleCollider, pt, ref isPointInside)); } Bounds bounds = col.bounds; bool flag = pt.x >= bounds.min.x && pt.x <= bounds.max.x && pt.y >= bounds.min.y && pt.y <= bounds.max.y && pt.z >= bounds.min.z && pt.z <= bounds.max.z; Vector3 vector = (!flag) ? col.ClosestPointOnBounds(pt) : pt; Vector3 direction = bounds.center - vector; Ray ray = new Ray(vector, direction); RaycastHit raycastHit; if (col.Raycast(ray, out raycastHit, direction.magnitude)) { isPointInside = false; return(raycastHit.point); } isPointInside = flag; return(col.ClosestPointOnBounds(pt)); }
public override void update(float dt) { ActiveDungeon activeDungeon = GameLogic.Binder.GameState.ActiveDungeon; CharacterInstance primaryPlayerCharacter = activeDungeon.PrimaryPlayerCharacter; if ((base.Character.ManualTargetPos != Vector3.zero) && (PhysicsUtil.DistBetween(base.Character, base.Character.ManualTargetPos) > 1f)) { this.m_movementBehaviour.update(dt); } else if (((primaryPlayerCharacter.TargetCharacter != null) && (PhysicsUtil.DistBetween(primaryPlayerCharacter, primaryPlayerCharacter.TargetCharacter) > ConfigGameplay.PASSIVE_HP_REGEN_PROXIMITY_THRESHOLD)) || (primaryPlayerCharacter.ManualTargetPos != Vector3.zero)) { if ((base.Character.TargetCharacter != primaryPlayerCharacter.TargetCharacter) || (base.Character.ManualTargetPos != primaryPlayerCharacter.ManualTargetPos)) { CmdSetCharacterTarget.ExecuteStatic(base.Character, primaryPlayerCharacter.TargetCharacter, primaryPlayerCharacter.ManualTargetPos); } this.m_movementBehaviour.update(dt); this.m_seekTacticalPosition = true; } else if (this.m_seekTacticalPosition) { this.m_targetingAiBehaviour.update(dt); if (base.Character.TargetCharacter != null) { Vector3 worldPt = base.Character.TargetCharacter.PhysicsBody.Transform.position - ((Vector3)(base.Character.TargetCharacter.PhysicsBody.Transform.forward * 1.5f)); worldPt = activeDungeon.ActiveRoom.calculateNearestEmptySpot(worldPt, worldPt - base.Character.TargetCharacter.PhysicsBody.Transform.position, 1f, 1f, 6f, null); CmdSetCharacterTarget.ExecuteStatic(base.Character, null, worldPt); this.m_seekTacticalPosition = false; } } else { this.m_targetingAiBehaviour.update(dt); this.m_movementBehaviour.update(dt); if (((base.Character.TargetCharacter != null) && this.m_movementBehaviour.WithinAttackDistance) && base.Character.PhysicsBody.rotatedEnoughForMovement()) { base.Character.AttackRoutine = GameLogic.Binder.CommandProcessor.executeCharacterSpecific(base.Character, new CmdAttackMelee(base.Character, base.Character.TargetCharacter), 0f); } } }
public static IEnumerator ThrowDrop(DropAnimation target, Vector3 endPosition, float time) { Collider2D collider = target.GetComponent <Collider2D>(); if (collider != null) { collider.enabled = false; } IEnumerator other = PhysicsUtil.MoveInLine(target.transform, endPosition, time); IEnumerator height = PhysicsUtil.MoveInArc(target.dropTransform, new Vector3(0.0f, 0.0f, 0.0f), time, true); while (other.MoveNext() && height.MoveNext()) { yield return(null); } if (collider != null) { collider.enabled = true; } }
IEnumerator moveeff(Transform eff, Vector3 t1, Vector3 ver) { yield return(null); float t = 0; Vector3 inipos = eff.position; while (Vector3.Distance(eff.position, t1) > 25) { t += Time.deltaTime * 8; var next = PhysicsUtil.GetParabolaNextPosition(inipos, ver, -9.8f, t); eff.right = next - eff.position; eff.position = next; yield return(new WaitForEndOfFrame()); if (t > 20f) { break; } } t = Vector3.Distance(eff.position, efftarget.position); while (t > 10) { var dir = efftarget.position - eff.position; eff.position += dir * Time.deltaTime * 3; if (t < 100) { var t2 = t * 0.01f; eff.localScale = new Vector3(t2, t2, t2); } yield return(new WaitForEndOfFrame()); t = Vector3.Distance(eff.position, efftarget.position); } Destroy(eff.gameObject); }
// Token: 0x06005790 RID: 22416 RVA: 0x001E32FC File Offset: 0x001E16FC private void CheckSafetyBubble() { if (this.currentAvatar == null || this.currentAvatarDescriptor == null) { return; } if (this._avatarPedestal != null) { return; } if (this._vrcPlayer == null) { return; } if (!VRCInputManager.personalSpace) { this.SetIsInsidePersonalSpace(false); return; } if (APIUser.IsFriendsWith(this._vrcPlayer.player.userId)) { this.SetIsInsidePersonalSpace(false); return; } float y = this.currentAvatarDescriptor.ViewPosition.y; float num = Mathf.Lerp(this.MinBubbleRadius, this.MaxBubbleRadius, Mathf.InverseLerp(2f, 4f, y)); float capsuleHeight = y + num * 2f; Vector3 capsuleCenter = new Vector3(0f, y / 2f, 0f); Vector3 worldCameraPos = VRCVrCamera.GetInstance().GetWorldCameraPos(); bool flag = false; PhysicsUtil.ClosestPointOnCapsule(base.transform.localToWorldMatrix, capsuleCenter, capsuleHeight, num, 1, worldCameraPos, ref flag); bool flag2 = false; if (flag) { this.SetIsInsidePersonalSpace(true); flag2 = true; } else { Animator component = this.currentAvatar.GetComponent <Animator>(); if (component != null && component.isHuman) { Transform boneTransform = component.GetBoneTransform(HumanBodyBones.LeftHand); if (boneTransform != null && Vector3.SqrMagnitude(boneTransform.position - worldCameraPos) <= this.HandBubbleRadius * this.HandBubbleRadius) { this.SetIsInsidePersonalSpace(true); flag2 = true; } if (!flag2) { Transform boneTransform2 = component.GetBoneTransform(HumanBodyBones.RightHand); if (boneTransform2 != null && Vector3.SqrMagnitude(boneTransform2.position - worldCameraPos) <= this.HandBubbleRadius * this.HandBubbleRadius) { this.SetIsInsidePersonalSpace(true); flag2 = true; } } } } if (!flag2) { this.SetIsInsidePersonalSpace(false); } }
protected override bool TestVisibility(VisualAspect aspect) { //if not in cylinder, can not see it var halfHeight = _height / 2.0f; var rod = this.Rod; var center = this.GetCenterInWorldSpace(); var otherPos = aspect.transform.position; float aspRad = aspect.Radius; if (aspRad > MathUtil.EPSILON) { if (!Cylinder.ContainsSphere(center - (rod * halfHeight), center + (rod * halfHeight), _radius, _innerRadius, otherPos, aspRad)) { return(false); } if (this._angle < 360.0f) { var v = VectorUtil.SetLengthOnAxis(otherPos - center, rod, 0f); var a = Vector3.Angle(this.transform.forward, v); float k = 2f * Mathf.Asin(aspRad / (Mathf.Sqrt(v.sqrMagnitude + (aspRad * aspRad) / 4f))) * Mathf.Rad2Deg; if (a > (_angle / 2.0f) - k) { return(false); } } } else { if (!Cylinder.ContainsPoint(center - (rod * halfHeight), center + (rod * halfHeight), _radius, _innerRadius, otherPos)) { return(false); } if (this._angle < 360.0f) { var v = VectorUtil.SetLengthOnAxis(otherPos - center, rod, 0f); var a = Vector3.Angle(this.transform.forward, v); if (a > this._angle / 2.0f) { return(false); } } } if (this.LineOfSightMask.value != 0) { var v = otherPos - center; using (var lst = com.spacepuppy.Collections.TempCollection.GetList <RaycastHit>()) { int cnt = PhysicsUtil.RaycastAll(this.transform.position, v, lst, v.magnitude, this.LineOfSightMask); for (int i = 0; i < cnt; i++) { //we ignore ourself var r = lst[i].collider.FindRoot(); if (r != aspect.entityRoot && r != this.entityRoot) { return(false); } } } } return(true); }