public void PrepareTargeting(TargetingEvent evt, TargetingNode conicTargeting) { TargetingData targetingData = evt.TargetingData; ConicTargetingComponent component = conicTargeting.conicTargeting; MuzzleLogicAccessor accessor = new MuzzleLogicAccessor(conicTargeting.muzzlePoint, conicTargeting.weaponInstance); targetingData.Origin = accessor.GetWorldPositionShiftDirectionBarrel(component.FireOriginOffsetCoeff); targetingData.Dir = accessor.GetFireDirectionWorld(); targetingData.FullDistance = component.WorkDistance; targetingData.MaxAngle = component.HalfConeAngle; base.ScheduleEvent(BattleCache.collectDirectionsEvent.GetInstance().Init(targetingData), conicTargeting); base.ScheduleEvent(BattleCache.collectTargetsEvent.GetInstance().Init(targetingData), conicTargeting); base.ScheduleEvent(BattleCache.targetEvaluateEvent.GetInstance().Init(targetingData), conicTargeting); }
public void CollectDirections(CollectDirectionsEvent evt, TargetingNode conicTargeting) { TargetingData targetingData = evt.TargetingData; ConicTargetingComponent component = conicTargeting.conicTargeting; CollectDirection(targetingData.Origin, targetingData.Dir, 0f, targetingData); float angleStep = component.HalfConeAngle / ((float)component.HalfConeNumRays); Vector3 leftDirectionWorld = new MuzzleLogicAccessor(conicTargeting.muzzlePoint, conicTargeting.weaponInstance).GetLeftDirectionWorld(); for (int i = 0; i < component.NumSteps; i++) { base.CollectSectorDirections(targetingData.Origin, targetingData.Dir, leftDirectionWorld, angleStep, component.HalfConeNumRays, targetingData); base.CollectSectorDirections(targetingData.Origin, targetingData.Dir, leftDirectionWorld, -angleStep, component.HalfConeNumRays, targetingData); leftDirectionWorld = (Vector3)(Quaternion.AngleAxis(180f / ((float)component.NumSteps), targetingData.Dir) * leftDirectionWorld); } }