private bool OnBulletRefected(EvtAfterBulletReflected evt) { AbilityTriggerBullet bullet = Singleton <EventManager> .Instance.GetActor <AbilityTriggerBullet>(evt.bulletID); MonoTriggerBullet triggerBullet = bullet.triggerBullet; bullet.Setup(base.actor, triggerBullet.speed, MixinTargetting.All, triggerBullet.IgnoreTimeScale, triggerBullet.AliveDuration); evt.attackData.attackerAttackValue *= base.instancedAbility.Evaluate(this.config.DamageRatio); Vector3 position = Singleton <EventManager> .Instance.GetEntity(evt.launcherID).GetAttachPoint("RootNode").position; BaseAbilityActor actor = Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(evt.launcherID); if (Vector3.Angle(base.instancedAbility.caster.entity.transform.forward, actor.entity.transform.position - base.instancedAbility.caster.entity.transform.position) < this.config.Angle) { if (this.config.IsReflectToLauncher) { triggerBullet.SetupTracing(position, triggerBullet._traceLerpCoef, triggerBullet._traceLerpCoefAcc, false); triggerBullet.transform.forward = -triggerBullet.transform.forward; } else { position.y += UnityEngine.Random.Range((float)1f, (float)3f); Vector3 rhs = position - base.entity.XZPosition; float sqrMagnitude = rhs.sqrMagnitude; rhs.y = 0f; Vector3 onUnitSphere = UnityEngine.Random.onUnitSphere; if (Vector3.Dot(onUnitSphere, rhs) < 0f) { onUnitSphere = -onUnitSphere; } onUnitSphere.y = Mathf.Abs(onUnitSphere.y); triggerBullet.transform.forward = onUnitSphere; triggerBullet.SetupTracing((Vector3)((onUnitSphere.normalized * sqrMagnitude) * 0.8f), triggerBullet._traceLerpCoef, triggerBullet._traceLerpCoefAcc, false); } if (this.config.ResetAliveDuration) { triggerBullet.AliveDuration = this.config.NewAliveDuration; } base.actor.abilityPlugin.HandleActionTargetDispatch(this.config.ReflectSuccessActions, base.instancedAbility, base.instancedModifier, Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(evt.launcherID), evt); } else { EvtBulletHit hit = new EvtBulletHit(triggerBullet.GetRuntimeID(), base.actor.runtimeID) { ownerID = base.actor.runtimeID, cannotBeReflected = true }; Vector3 vector4 = triggerBullet.transform.position - ((Vector3)((Time.deltaTime * triggerBullet.BulletTimeScale) * triggerBullet.transform.GetComponent <Rigidbody>().velocity)); AttackResult.HitCollsion collsion = new AttackResult.HitCollsion { hitPoint = vector4, hitDir = triggerBullet.transform.forward }; hit.hitCollision = collsion; Singleton <EventManager> .Instance.FireEvent(hit, MPEventDispatchMode.Normal); } return(false); }
protected override bool ListenBulletHit(EvtBulletHit evt) { if (base.selfIdentity.isAuthority) { Singleton <MPEventManager> .Instance.MarkEventReplicate(evt); return(base.ListenBulletHit(evt)); } return(false); }
private void OnTriggerEnter(Collider other) { if (((this._collisionMask.value & (((int)1) << other.gameObject.layer)) != 0) && this._collisionEnabled) { BaseMonoEntity componentInParent = other.GetComponentInParent <BaseMonoEntity>(); if (Singleton <RuntimeIDManager> .Instance.ParseCategory(componentInParent.GetRuntimeID()) == 4) { if (this._enteredIDs.Contains(componentInParent.GetRuntimeID())) { return; } } else if (!componentInParent.IsActive() || this._enteredIDs.Contains(componentInParent.GetRuntimeID())) { return; } BaseMonoEntity owner = componentInParent; if (componentInParent is BaseMonoDynamicObject) { BaseMonoDynamicObject obj2 = (BaseMonoDynamicObject)componentInParent; if ((obj2.dynamicType == BaseMonoDynamicObject.DynamicType.EvadeDummy) && (obj2.owner != null)) { this._enteredIDs.Add(obj2.owner.GetRuntimeID()); } } else if (componentInParent is MonoBodyPartEntity) { owner = ((MonoBodyPartEntity)componentInParent).owner; } if (!(owner is BaseMonoAbilityEntity) || !((BaseMonoAbilityEntity)owner).isGhost) { this._enteredIDs.Add(owner.GetRuntimeID()); EvtBulletHit evt = new EvtBulletHit(base._runtimeID, owner.GetRuntimeID()) { ownerID = base.ownerID }; Vector3 position = base.transform.position - ((Vector3)((Time.deltaTime * this.BulletTimeScale) * this._rigidbody.velocity)); AttackResult.HitCollsion collsion = new AttackResult.HitCollsion { hitPoint = other.ClosestPointOnBounds(position), hitDir = this.CreateHitForward() }; evt.hitCollision = collsion; Singleton <EventManager> .Instance.FireEvent(evt, MPEventDispatchMode.Normal); } } }
public static EvtBulletHit Deserialize(Packet_Event_EvtBulletHit table, EvtBulletHit obj) { if (obj == null) { obj = new EvtBulletHit(); } obj.targetID = table.TargetID; obj.otherID = table.OtherID; if (table.GetHitCollision(GetCachedTable <MPHitCollision>()) != null) { obj.hitCollision = Deserialize(GetCachedTable <MPHitCollision>(), new AttackResult.HitCollsion()); } obj.hitEnvironment = table.HitEnvironment; obj.hitGround = table.HitGround; obj.cannotBeReflected = table.CannotBeReflected; return(obj); }
protected override void Update() { AttackResult.HitCollsion collsion; base.Update(); if (this._resetTimer != null) { this._resetTimer.Core(1f); if (this._resetTimer.isTimeUp) { this._enteredIDs.Clear(); this._resetTimer.Reset(false); } } if (this._aliveTimer.isActive) { this._aliveTimer.Core(this.BulletTimeScale); if (this._aliveTimer.isTimeUp) { EvtBulletHit evt = new EvtBulletHit(base._runtimeID) { ownerID = base.ownerID }; collsion = new AttackResult.HitCollsion { hitDir = this.CreateHitForward(), hitPoint = base.transform.position }; evt.hitCollision = collsion; evt.hitGround = true; evt.selfExplode = true; Singleton <EventManager> .Instance.FireEvent(evt, MPEventDispatchMode.Normal); this._aliveTimer.Reset(false); } } if (InLevelData.IsOutOfStage(this.XZPosition)) { EvtBulletHit hit2 = new EvtBulletHit(base._runtimeID) { ownerID = base.ownerID }; collsion = new AttackResult.HitCollsion { hitDir = this.CreateHitForward(), hitPoint = base.transform.position }; hit2.hitCollision = collsion; Singleton <EventManager> .Instance.FireEvent(hit2, MPEventDispatchMode.Normal); } else if ((base.transform.position.y < 0.05f) && this._collisionEnabled) { EvtBulletHit hit3 = new EvtBulletHit(base._runtimeID) { ownerID = base.ownerID }; collsion = new AttackResult.HitCollsion { hitDir = this.CreateHitForward(), hitPoint = base.transform.position }; hit3.hitCollision = collsion; hit3.hitGround = true; Singleton <EventManager> .Instance.FireEvent(hit3, MPEventDispatchMode.Normal); } else if (this._state == BulletState.Linear) { this.speed += (this.acceleration * Time.deltaTime) * this.BulletTimeScale; this._rigidbody.velocity = (Vector3)((this.speed * base.transform.forward) * this.BulletTimeScale); } else if (this._state == BulletState.TracePosition) { this._traceLerpCoef += (this._traceLerpCoefAcc * Time.deltaTime) * this.BulletTimeScale; Vector3 forward = base.transform.forward; Vector3 vector3 = this._targetPosition - this._rigidbody.position; if (vector3.magnitude >= this.targetReachThreshold) { forward = Vector3.Normalize(this._targetPosition - this._rigidbody.position); float num = Vector3.Angle(forward, base.transform.forward); if (!this._passBy || (num < 90.0)) { base.transform.forward = Vector3.Slerp(base.transform.forward, forward, (Time.deltaTime * this.BulletTimeScale) * this._traceLerpCoef); } this.speed += (this.acceleration * Time.deltaTime) * this.BulletTimeScale; this._rigidbody.velocity = (Vector3)(((this.speed * base.transform.forward) + this.speedAdd) * this.BulletTimeScale); } else { this._rigidbody.velocity = (Vector3)(base.transform.forward * 0f); if (this._collisionEnabled) { EvtBulletHit hit4 = new EvtBulletHit(base._runtimeID) { ownerID = base.ownerID }; collsion = new AttackResult.HitCollsion { hitDir = this.CreateHitForward(), hitPoint = base.transform.position }; hit4.hitCollision = collsion; hit4.hitGround = true; Singleton <EventManager> .Instance.FireEvent(hit4, MPEventDispatchMode.Normal); } } } else if (((this._state == BulletState.Placing) && (this._placingTimer != null)) && this._placingTimer.isActive) { this._placingTimer.Core(this.BulletTimeScale); if (!this._placingTimer.isTimeUp) { base.transform.position = Vector3.Slerp(this._originalPosition, this._placingPosition, this._placingTimer.timer / this._placingTimer.timespan); this._collisionEnabled = false; this._collisionMask = -1; this._rigidbody.velocity = (Vector3)((this.speed * base.transform.forward) * this.BulletTimeScale); } else { this._state = BulletState.TracePosition; this._placingTimer.Reset(false); this.speed = this._resumeSpeed; this._collisionEnabled = true; } } }
protected override bool ListenBulletHit(EvtBulletHit evt) { if (!base._bulletAttackDatas.ContainsKey(evt.targetID)) { return(false); } BaseMPIdentity identity = Singleton <MPManager> .Instance.TryGetIdentity(evt.otherID); if (((identity != null) && !identity.isAuthority) && !identity.remoteMode.IsRemoteReceive()) { return(false); } AttackData attackData = base._bulletAttackDatas[evt.targetID]; attackData.isFromBullet = true; bool flag = base.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage; bool flag2 = (base.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage) || (base.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDamageHitTarget); bool flag3 = true; bool flag4 = base.baseConfig.BulletHitType == BulletHitBehavior.NoDestroyAndRefresh; BaseMonoEntity entity = Singleton <EventManager> .Instance.GetEntity(evt.otherID); BaseAbilityActor actor = Singleton <EventManager> .Instance.GetActor(evt.otherID) as BaseAbilityActor; if ((entity is MonoDummyDynamicObject) || ((identity != null) && !identity.remoteMode.IsRemoteReceive())) { flag2 = false; flag = false; flag3 = false; flag4 = false; } else if (evt.hitEnvironment) { flag2 = true; flag4 = false; } else if ((!evt.cannotBeReflected && (actor != null)) && actor.abilityState.ContainsState(AbilityState.ReflectBullet)) { Singleton <EventManager> .Instance.FireEvent(new EvtAfterBulletReflected(evt.otherID, evt.targetID, base.actor.runtimeID, base._bulletAttackDatas[evt.targetID]), MPEventDispatchMode.Normal); return(false); } AbilityTriggerBullet bulletActor = Singleton <EventManager> .Instance.GetActor <AbilityTriggerBullet>(evt.targetID); if (flag2) { bulletActor.Kill(); base._bulletAttackDatas.Remove(evt.targetID); } else { attackData = attackData.Clone(); } if (flag4) { bulletActor.triggerBullet.ResetInside(base.baseConfig.ResetTime); } base._evtsLs.Clear(); if (evt.hitEnvironment) { if (!evt.hitGround) { return(true); } EvtHittingOther item = new EvtHittingOther(base.actor.runtimeID, evt.otherID, attackData) { hitCollision = evt.hitCollision }; base._evtsLs.Add(item); } else { attackData.hitCollision = evt.hitCollision; base._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, evt.otherID, base.baseConfig.HitAnimEventID, attackData)); } if (flag) { List <CollisionResult> list = CollisionDetectPattern.CylinderCollisionDetectBySphere(evt.hitCollision.hitPoint, evt.hitCollision.hitPoint, base.instancedAbility.Evaluate(base.baseConfig.HitExplodeRadius), 1f, Singleton <EventManager> .Instance.GetAbilityHitboxTargettingMask(base.actor.runtimeID, base.baseConfig.Targetting)); float y = evt.hitCollision.hitPoint.y; for (int j = 0; j < list.Count; j++) { CollisionResult result = list[j]; BaseMonoEntity collisionResultEntity = AttackPattern.GetCollisionResultEntity(result.entity); if ((collisionResultEntity != null) && (collisionResultEntity.GetRuntimeID() != evt.otherID)) { result.hitPoint.y = y; AttackData data2 = attackData.Clone(); AttackResult.HitCollsion collsion = new AttackResult.HitCollsion { hitDir = result.hitForward, hitPoint = result.hitPoint }; data2.hitCollision = collsion; base._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, collisionResultEntity.GetRuntimeID(), base.baseConfig.HitAnimEventID, data2)); } } } if (flag3) { Vector3 hitPoint = evt.hitCollision.hitPoint; if (base.baseConfig.ExplodeEffectGround) { hitPoint.y = 0f; } Vector3 hitDir = evt.hitCollision.hitDir; hitDir.y = 0f; base.FireTriggerBulletHitExplodeEffect(bulletActor, hitPoint, hitDir, false); } if (base.baseConfig.HitExplodeActions.Length > 0) { for (int k = 0; k < base._evtsLs.Count; k++) { base.actor.abilityPlugin.HandleActionTargetDispatch(base.baseConfig.HitExplodeActions, base.instancedAbility, base.instancedModifier, Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(base._evtsLs[k].toID), evt); } } for (int i = 0; i < base._evtsLs.Count; i++) { EvtHittingOther other2 = base._evtsLs[i]; AttackPattern.SendHitEvent(base.actor.runtimeID, other2.toID, other2.animEventID, other2.hitCollision, other2.attackData, false, MPEventDispatchMode.CheckRemoteMode); } return(true); }
protected virtual bool ListenBulletHit(EvtBulletHit evt) { if (!this._bulletAttackDatas.ContainsKey(evt.targetID)) { return(false); } AttackData attackData = this._bulletAttackDatas[evt.targetID]; attackData.isFromBullet = true; bool flag = this.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage; bool flag2 = (this.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDoExplodeDamage) || (this.baseConfig.BulletHitType == BulletHitBehavior.DestroyAndDamageHitTarget); bool flag3 = true; bool flag4 = this.baseConfig.BulletHitType == BulletHitBehavior.NoDestroyAndRefresh; BaseMonoEntity entity = Singleton <EventManager> .Instance.GetEntity(evt.otherID); BaseAbilityActor actor = Singleton <EventManager> .Instance.GetActor(evt.otherID) as BaseAbilityActor; if (entity is MonoDummyDynamicObject) { flag2 = false; flag = false; flag3 = false; flag4 = false; } else if (evt.hitEnvironment) { flag2 = true; flag4 = false; } else if ((!evt.cannotBeReflected && (actor != null)) && actor.abilityState.ContainsState(AbilityState.ReflectBullet)) { Singleton <EventManager> .Instance.FireEvent(new EvtAfterBulletReflected(evt.otherID, evt.targetID, base.actor.runtimeID, this._bulletAttackDatas[evt.targetID]), MPEventDispatchMode.Normal); return(false); } AbilityTriggerBullet bulletActor = Singleton <EventManager> .Instance.GetActor <AbilityTriggerBullet>(evt.targetID); if (flag2) { if (bulletActor != null) { bulletActor.Kill(); } this._bulletAttackDatas.Remove(evt.targetID); } else { attackData = attackData.Clone(); } if (flag4 && (bulletActor != null)) { bulletActor.triggerBullet.ResetInside(this.baseConfig.ResetTime); } this._evtsLs.Clear(); if (evt.hitEnvironment) { if (!evt.hitGround) { return(true); } EvtHittingOther item = new EvtHittingOther(base.actor.runtimeID, evt.otherID, attackData) { hitCollision = evt.hitCollision }; this._evtsLs.Add(item); } else { attackData.hitCollision = evt.hitCollision; this._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, evt.otherID, this.baseConfig.HitAnimEventID, attackData)); } if (flag) { List <CollisionResult> list = CollisionDetectPattern.CylinderCollisionDetectBySphere(evt.hitCollision.hitPoint, evt.hitCollision.hitPoint, base.instancedAbility.Evaluate(this.baseConfig.HitExplodeRadius), 1f, Singleton <EventManager> .Instance.GetAbilityHitboxTargettingMask(base.actor.runtimeID, this.baseConfig.Targetting)); float y = evt.hitCollision.hitPoint.y; for (int j = 0; j < list.Count; j++) { CollisionResult result = list[j]; BaseMonoEntity collisionResultEntity = AttackPattern.GetCollisionResultEntity(result.entity); if ((collisionResultEntity != null) && (collisionResultEntity.GetRuntimeID() != evt.otherID)) { result.hitPoint.y = y; AttackData data2 = attackData.Clone(); AttackResult.HitCollsion collsion = new AttackResult.HitCollsion { hitDir = result.hitForward, hitPoint = result.hitPoint }; data2.hitCollision = collsion; this._evtsLs.Add(new EvtHittingOther(base.actor.runtimeID, collisionResultEntity.GetRuntimeID(), this.baseConfig.HitAnimEventID, data2)); } } } if (flag3) { Vector3 hitPoint = evt.hitCollision.hitPoint; if (this.baseConfig.ExplodeEffectGround) { hitPoint.y = 0f; } Vector3 hitDir = evt.hitCollision.hitDir; hitDir.y = 0f; bool selfExplode = evt.selfExplode; if (bulletActor != null) { this.FireTriggerBulletHitExplodeEffect(bulletActor, hitPoint, hitDir, selfExplode); } } if ((this.baseConfig.HitExplodeActions.Length > 0) && (!evt.selfExplode || !this.baseConfig.MuteSelfHitExplodeActions)) { for (int k = 0; k < this._evtsLs.Count; k++) { if (base.actor.abilityPlugin != null) { base.actor.abilityPlugin.HandleActionTargetDispatch(this.baseConfig.HitExplodeActions, base.instancedAbility, base.instancedModifier, Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(this._evtsLs[k].toID), evt); } } } for (int i = 0; i < this._evtsLs.Count; i++) { EvtHittingOther other2 = this._evtsLs[i]; if (this.baseConfig.IsHitChangeTargetDirection && (other2.attackData.hitEffect >= AttackResult.AnimatorHitEffect.ThrowUp)) { BaseAbilityActor actor2 = Singleton <EventManager> .Instance.GetActor <BaseAbilityActor>(other2.toID); if (actor2 != null) { actor2.entity.transform.forward = -other2.attackData.hitCollision.hitDir; } } Singleton <EventManager> .Instance.FireEvent(other2, MPEventDispatchMode.Normal); } return(true); }
public static Offset <Packet_Event_EvtBulletHit> Serialize(FlatBufferBuilder builder, EvtBulletHit obj) { Offset <MPHitCollision> hitCollisionOffset = new Offset <MPHitCollision>(); if (obj.hitCollision != null) { hitCollisionOffset = Serialize(builder, obj.hitCollision); } Packet_Event_EvtBulletHit.StartPacket_Event_EvtBulletHit(builder); Packet_Event_EvtBulletHit.AddTargetID(builder, obj.targetID); Packet_Event_EvtBulletHit.AddOtherID(builder, obj.otherID); Packet_Event_EvtBulletHit.AddHitCollision(builder, hitCollisionOffset); Packet_Event_EvtBulletHit.AddHitEnvironment(builder, obj.hitEnvironment); Packet_Event_EvtBulletHit.AddHitGround(builder, obj.hitGround); Packet_Event_EvtBulletHit.AddCannotBeReflected(builder, obj.cannotBeReflected); return(Packet_Event_EvtBulletHit.EndPacket_Event_EvtBulletHit(builder)); }
public static object DeserializeToObject(Table table, object obj) { if (table.GetType() == typeof(MoleMole.MPProtocol.MPStageData)) { if (obj == null) { obj = new MoleMole.MPStageData(); } return(Deserialize((MoleMole.MPProtocol.MPStageData)table, (MoleMole.MPStageData)obj)); } if (table.GetType() == typeof(MoleMole.MPProtocol.MPAvatarDataItem)) { if (obj == null) { obj = new MoleMole.MPAvatarDataItem(); } return(Deserialize((MoleMole.MPProtocol.MPAvatarDataItem)table, (MoleMole.MPAvatarDataItem)obj)); } if (table.GetType() == typeof(Packet_Event_EvtHittingOther)) { if (obj == null) { obj = new EvtHittingOther(); } return(Deserialize((Packet_Event_EvtHittingOther)table, (EvtHittingOther)obj)); } if (table.GetType() == typeof(Packet_Event_EvtBeingHit)) { if (obj == null) { obj = new EvtBeingHit(); } return(Deserialize((Packet_Event_EvtBeingHit)table, (EvtBeingHit)obj)); } if (table.GetType() == typeof(Packet_Event_EvtAttackLanded)) { if (obj == null) { obj = new EvtAttackLanded(); } return(Deserialize((Packet_Event_EvtAttackLanded)table, (EvtAttackLanded)obj)); } if (table.GetType() == typeof(Packet_Event_EvtEvadeSuccess)) { if (obj == null) { obj = new EvtEvadeSuccess(); } return(Deserialize((Packet_Event_EvtEvadeSuccess)table, (EvtEvadeSuccess)obj)); } if (table.GetType() == typeof(Packet_Event_EvtBulletHit)) { if (obj == null) { obj = new EvtBulletHit(); } return(Deserialize((Packet_Event_EvtBulletHit)table, (EvtBulletHit)obj)); } if (table.GetType() == typeof(MPAttackData)) { if (obj == null) { obj = new AttackData(); } return(Deserialize((MPAttackData)table, (AttackData)obj)); } if (table.GetType() == typeof(MPAttackResult)) { if (obj == null) { obj = new AttackResult(); } return(Deserialize((MPAttackResult)table, (AttackResult)obj)); } if (table.GetType() != typeof(MPHitCollision)) { return(obj); } if (obj == null) { obj = new AttackResult.HitCollsion(); } return(Deserialize((MPHitCollision)table, (AttackResult.HitCollsion)obj)); }