public static GameObject InitHitBoxComponent(EntityKey entityKey, IHitBox playerEntity, GameObject hitboxGo) { hitboxGo.name = "hitbox_" + entityKey; GameObject bsGo = HitBoxConstants.FindBoundingSphereModel(hitboxGo); SphereCollider sc = bsGo.GetComponent <SphereCollider>(); sc.enabled = false; hitboxGo.transform.Recursively(t => { var go = t.gameObject; HitBoxOwnerComponent pc = go.GetComponent <HitBoxOwnerComponent>(); if (pc == null) { pc = go.AddComponent <HitBoxOwnerComponent>(); } pc.OwnerEntityKey = entityKey; pc.gameObject.layer = UnityLayers.HitBoxLayer; }); playerEntity.AddHitBox(new BoundingSphere(sc.center, sc.radius), hitboxGo); hitboxGo.SetActive(false); return(hitboxGo); }
protected override bool Filter(HitBoxOwnerComponent boxOwnerComponent, int cmdSeq) { if (boxOwnerComponent && boxOwnerComponent.OwnerEntityKey.EntityType == (short)EEntityType.Vehicle) { hitTargetVehicle = contexts.vehicle.GetEntityWithEntityKey(boxOwnerComponent.OwnerEntityKey) ?? null; if (hitTargetVehicle == null) { return(false); } this.cmdSeq = cmdSeq; return(true); } return(false); }
protected override bool Filter(HitBoxOwnerComponent boxOwnerComponent, int cmdSeq) { if (boxOwnerComponent && boxOwnerComponent.OwnerEntityKey.EntityType == (short)EEntityType.Player) { hitTargetPlayer = contexts.player.GetEntityWithEntityKey(boxOwnerComponent.OwnerEntityKey) ?? null; if (hitTargetPlayer == null) { BulletHitHandler._logger.ErrorFormat("[Hit{1}]cant get player entity with key {0}", boxOwnerComponent.OwnerEntityKey, cmdSeq); return(false); } this.cmdSeq = cmdSeq; return(true); } return(false); }
public bool ProcessHitTarget(HitBoxOwnerComponent boxOwnerComponent, int cmdSeq, CompensationWorld compensationWorld, IBulletEntityAgent bulletEntityAgent, RaycastHit hit, PlayerEntity srcPlayer) { if (Filter(boxOwnerComponent, cmdSeq)) { try { profilerInfo.BeginProfileOnlyEnableProfile(); Handle(compensationWorld, bulletEntityAgent, hit, srcPlayer); } finally { profilerInfo.EndProfileOnlyEnableProfile(); } return(true); } return(false); }
protected abstract bool Filter(HitBoxOwnerComponent boxOwnerComponent, int cmdSeq);
protected override bool Filter(HitBoxOwnerComponent boxOwnerComponent, int cmdSeq) { return(true); }