private void OnTurretTimer(uint id, object cookie) { TrackingComponent trackingComp = cookie as TrackingComponent; this.UpdateWithRandomAngle(trackingComp); this.CreateRandomDelay(trackingComp, id); }
protected override void Update(float dt) { for (TrackingRenderNode trackingRenderNode = this.nodeList.Head; trackingRenderNode != null; trackingRenderNode = trackingRenderNode.Next) { TrackingComponent trackingComp = trackingRenderNode.TrackingComp; TrackingGameObjectViewComponent trackingView = trackingRenderNode.TrackingView; if (trackingView.Speed != 0f) { float target = MathUtils.MinAngle(trackingView.Yaw, trackingComp.Yaw); trackingView.Yaw = Mathf.SmoothDampAngle(trackingView.Yaw, target, ref trackingView.YawVelocity, trackingComp.MaxVelocity / trackingView.Speed); if (trackingView.YawVelocity != 0f) { trackingView.Yaw = MathUtils.WrapAngle(trackingView.Yaw); } trackingView.YawRotate(trackingView.Yaw); if (trackingComp.TrackPitch) { float target2 = MathUtils.MinAngle(trackingView.Pitch, trackingComp.Pitch); trackingView.Pitch = Mathf.SmoothDampAngle(trackingView.Pitch, target2, ref trackingView.PitchVelocity, trackingComp.MaxVelocity / trackingView.Speed); if (trackingView.PitchVelocity != 0f) { trackingView.Pitch = MathUtils.WrapAngle(trackingView.Pitch); } trackingView.PitchRotate(trackingView.Pitch); } } } }
private void Start() { //Reset time scale Time.timeScale = 1f; //Set PublicScript.gudcControllerEvents = GameObject.Find("[CameraRig]").GetComponent <ControllerEvents>(); //Reset PublicScript.gblnControllersReady = false; //Set PublicScript.gtxtDebug = VRDebug; //Set BallTracking = TheBallRigidbody.GetComponent <TrackingComponent>(); }
private void UpdateWithRandomAngle(TrackingComponent trackingComp) { Rand rand = Service.Get <Rand>(); float num = rand.ViewRangeFloat(0f, 6.28318548f); trackingComp.Mode = TrackingMode.Angle; trackingComp.TargetYaw = num; if (trackingComp.TrackPitch) { num = rand.ViewRangeFloat(0f, 0.2617994f); trackingComp.TargetPitch = num; } }
public void SetTrackingMode(TrackingMode mode) { if (trackingMode != mode) { TrackingComponent trackingComponent; if (TrackingComponents.TryGetValue(mode, out trackingComponent)) { currentTrackingComp.enabled = false; currentTrackingComp = trackingComponent; currentTrackingComp.enabled = true; trackingMode = mode; } } }
void Start() { List <TrackingComponent> TrackingComps = new List <TrackingComponent>(); GetComponents(TrackingComps); foreach (TrackingComponent comp in TrackingComps) { TrackingComponents.Add(comp.GetMode(), comp); if (comp.GetMode() == trackingMode) { currentTrackingComp = comp; } } currentTrackingComp.enabled = true; }
private void CreateRandomDelay(TrackingComponent trackingComp, uint timerId) { float randomDelayTime = this.GetRandomDelayTime(timerId == 0u); uint num = Service.Get <ViewTimerManager>().CreateViewTimer(randomDelayTime, false, new TimerDelegate(this.OnTurretTimer), trackingComp); if (timerId == 0u) { this.idleTimers.Add(num); return; } for (int i = 0; i < this.idleTimers.Count; i++) { if (this.idleTimers[i] == timerId) { this.idleTimers[i] = num; return; } } }
protected override void Update(uint dt) { ShooterController shooterController = Service.ShooterController; for (TrackingNode trackingNode = this.nodeList.Head; trackingNode != null; trackingNode = trackingNode.Next) { TrackingComponent trackingComp = trackingNode.TrackingComp; Entity turretTarget = shooterController.GetTurretTarget(trackingNode.ShooterComp); if (turretTarget != null && turretTarget != trackingComp.TargetEntity) { trackingComp.TargetEntity = turretTarget; trackingComp.Mode = TrackingMode.Entity; } if (trackingComp.Mode != TrackingMode.Disabled) { if (trackingComp.Mode == TrackingMode.Entity) { float num = (float)trackingNode.TrackingComp.TargetTransform.X - trackingNode.Transform.CenterX(); float num2 = (float)trackingNode.TrackingComp.TargetTransform.Z - trackingNode.Transform.CenterZ(); trackingComp.Yaw = Mathf.Atan2(num2, num); if (trackingNode.TrackingComp.TrackPitch) { float num3 = Mathf.Sqrt(num * num + num2 * num2); float num4 = Mathf.Sqrt(trackingNode.ShooterComp.MinAttackRangeSquared); float num5 = Mathf.Sqrt(trackingNode.ShooterComp.MaxAttackRangeSquared); num3 = Mathf.Clamp(num3, num4, num5); trackingComp.Pitch = 0.2617994f * (num5 - num3) / (num5 - num4); } } else if (trackingComp.Mode == TrackingMode.Location) { float x = (float)trackingComp.TargetX - trackingNode.Transform.CenterX(); float y = (float)trackingComp.TargetZ - trackingNode.Transform.CenterZ(); trackingComp.Yaw = Mathf.Atan2(y, x); } else if (trackingComp.Mode == TrackingMode.Angle) { trackingComp.Yaw = trackingComp.TargetYaw; } } } }
private void FastForwardTracking(uint timerId, object cookie) { this.trackComps.Sort(new Comparison <TrackingComponent>(this.SortTrackingForFastForwarding)); List <TrackingComponent> list = null; for (int i = 0; i < this.trackComps.Count; i++) { TrackingComponent trackingComponent = this.trackComps[i]; this.UpdateWithRandomAngle(trackingComponent); float randomDelayTime = this.GetRandomDelayTime(false); if (randomDelayTime > trackingComponent.IdleFastForwardTimeRemaining) { trackingComponent.IdleFastForwardTimeRemaining = 0f; trackingComponent.Yaw = trackingComponent.TargetYaw; trackingComponent.Mode = TrackingMode.Disabled; if (list == null) { list = new List <TrackingComponent>(); } list.Add(trackingComponent); } else { trackingComponent.IdleFastForwardTimeRemaining -= randomDelayTime; } } if (list != null) { for (int j = 0; j < list.Count; j++) { this.trackComps.Remove(list[j]); } } if (this.trackComps.Count > 0) { this.FastForwardTracking(0u, null); } }
public EatResponse OnEvent(EventId id, object cookie) { if (id != EventId.BuildingViewReady) { return(EatResponse.NotEaten); } EntityViewParams entityViewParams = cookie as EntityViewParams; Entity entity = entityViewParams.Entity; BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); if (buildingComponent == null) { return(EatResponse.NotEaten); } GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); TurretTypeVO turretTypeVO = null; if (buildingComponent.BuildingType.Type == BuildingType.Turret) { turretTypeVO = Service.Get <IDataController>().Get <TurretTypeVO>(buildingComponent.BuildingType.TurretUid); } if (turretTypeVO == null || string.IsNullOrEmpty(turretTypeVO.TrackerName)) { Animation component = gameObjectViewComponent.MainGameObject.GetComponent <Animation>(); if (component != null) { AssetMeshDataMonoBehaviour component2 = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>(); entity.Add <BuildingAnimationComponent>(new BuildingAnimationComponent(component, component2 ? component2.ListOfParticleSystems : null)); } } else { TrackingComponent trackingComp = entity.Get <TrackingComponent>(); TrackingGameObjectViewComponent component3 = new TrackingGameObjectViewComponent(gameObjectViewComponent.MainGameObject, turretTypeVO, trackingComp); entity.Add <TrackingGameObjectViewComponent>(component3); } return(EatResponse.NotEaten); }
private void HandleCollisionLogic() { Debug.Log("A hit was made"); TrackingComponent CollidingObject = TrackingRigidbody.transform.GetComponent <TrackingComponent>(); Vector3 collidingForce = CollidingObject.GetMomentum() / Time.deltaTime; Vector3 colliderForce = BaseTrackingComponent.GetMomentum() / Time.deltaTime; Vector3 reflectedCollidingForce = -(Vector3.Dot(collidingForce, TrackingTransform.forward) * TrackingTransform.forward); Vector3 finalForce = (reflectedCollidingForce * DampeningRatio) + (colliderForce * TrackingForceMultipler); float mag = Vector3.Magnitude(finalForce); if (mag < MinForceMag) { finalForce.Normalize(); finalForce *= MinForceMag; } TrackingRigidbody.AddForce(finalForce); TimeBetweenHitsSubtract = TimeBetweenHits; }
public override object Remove(Type compCls) { if (compCls == typeof(AreaTriggerComponent)) { this.AreaTriggerComp = null; } else if (compCls == typeof(ArmoryComponent)) { this.ArmoryComp = null; } else if (compCls == typeof(AssetComponent)) { this.AssetComp = null; } else if (compCls == typeof(AttackerComponent)) { this.AttackerComp = null; } else if (compCls == typeof(BarracksComponent)) { this.BarracksComp = null; } else if (compCls == typeof(BoardItemComponent)) { this.BoardItemComp = null; } else if (compCls == typeof(BuildingAnimationComponent)) { this.BuildingAnimationComp = null; } else if (compCls == typeof(BuildingComponent)) { this.BuildingComp = null; } else if (compCls == typeof(CantinaComponent)) { this.CantinaComp = null; } else if (compCls == typeof(ChampionComponent)) { this.ChampionComp = null; } else if (compCls == typeof(CivilianComponent)) { this.CivilianComp = null; } else if (compCls == typeof(ClearableComponent)) { this.ClearableComp = null; } else if (compCls == typeof(DamageableComponent)) { this.DamageableComp = null; } else if (compCls == typeof(DefenderComponent)) { this.DefenderComp = null; } else if (compCls == typeof(DefenseLabComponent)) { this.DefenseLabComp = null; } else if (compCls == typeof(DroidComponent)) { this.DroidComp = null; } else if (compCls == typeof(DroidHutComponent)) { this.DroidHutComp = null; } else if (compCls == typeof(SquadBuildingComponent)) { this.SquadBuildingComp = null; } else if (compCls == typeof(NavigationCenterComponent)) { this.NavigationCenterComp = null; } else if (compCls == typeof(FactoryComponent)) { this.FactoryComp = null; } else if (compCls == typeof(FleetCommandComponent)) { this.FleetCommandComp = null; } else if (compCls == typeof(FollowerComponent)) { this.FollowerComp = null; } else if (compCls == typeof(GameObjectViewComponent)) { this.GameObjectViewComp = null; } else if (compCls == typeof(GeneratorComponent)) { this.GeneratorComp = null; } else if (compCls == typeof(GeneratorViewComponent)) { this.GeneratorViewComp = null; } else if (compCls == typeof(HealerComponent)) { this.HealerComp = null; } else if (compCls == typeof(HealthComponent)) { this.HealthComp = null; } else if (compCls == typeof(TroopShieldComponent)) { this.TroopShieldComp = null; } else if (compCls == typeof(TroopShieldViewComponent)) { this.TroopShieldViewComp = null; } else if (compCls == typeof(TroopShieldHealthComponent)) { this.TroopShieldHealthComp = null; } else if (compCls == typeof(HealthViewComponent)) { this.HealthViewComp = null; } else if (compCls == typeof(HQComponent)) { this.HQComp = null; } else if (compCls == typeof(KillerComponent)) { this.KillerComp = null; } else if (compCls == typeof(LootComponent)) { this.LootComp = null; } else if (compCls == typeof(MeterShaderComponent)) { this.MeterShaderComp = null; } else if (compCls == typeof(OffenseLabComponent)) { this.OffenseLabComp = null; } else if (compCls == typeof(PathingComponent)) { this.PathingComp = null; } else if (compCls == typeof(SecondaryTargetsComponent)) { this.SecondaryTargetsComp = null; } else if (compCls == typeof(ShieldBorderComponent)) { this.ShieldBorderComp = null; } else if (compCls == typeof(ShieldGeneratorComponent)) { this.ShieldGeneratorComp = null; } else if (compCls == typeof(SizeComponent)) { this.SizeComp = null; } else if (compCls == typeof(ShooterComponent)) { this.ShooterComp = null; } else if (compCls == typeof(StarportComponent)) { this.StarportComp = null; } else if (compCls == typeof(StateComponent)) { this.StateComp = null; } else if (compCls == typeof(StorageComponent)) { this.StorageComp = null; } else if (compCls == typeof(SupportComponent)) { this.SupportComp = null; } else if (compCls == typeof(SupportViewComponent)) { this.SupportViewComp = null; } else if (compCls == typeof(TacticalCommandComponent)) { this.TacticalCommandComp = null; } else if (compCls == typeof(ChampionPlatformComponent)) { this.ChampionPlatformComp = null; } else if (compCls == typeof(TeamComponent)) { this.TeamComp = null; } else if (compCls == typeof(TrackingComponent)) { this.TrackingComp = null; } else if (compCls == typeof(TrackingGameObjectViewComponent)) { this.TrackingGameObjectViewComp = null; } else if (compCls == typeof(TransformComponent)) { this.TransformComp = null; } else if (compCls == typeof(TransportComponent)) { this.TransportComp = null; } else if (compCls == typeof(TroopComponent)) { this.TroopComp = null; } else if (compCls == typeof(TurretBuildingComponent)) { this.TurretBuildingComp = null; } else if (compCls == typeof(TurretShooterComponent)) { this.TurretShooterComp = null; } else if (compCls == typeof(WalkerComponent)) { this.WalkerComp = null; } else if (compCls == typeof(WallComponent)) { this.WallComp = null; } else if (compCls == typeof(BuffComponent)) { this.BuffComp = null; } else if (compCls == typeof(TrapComponent)) { this.TrapComp = null; } else if (compCls == typeof(TrapViewComponent)) { this.TrapViewComp = null; } else if (compCls == typeof(HousingComponent)) { this.HousingComp = null; } else if (compCls == typeof(SpawnComponent)) { this.SpawnComp = null; } return(base.Remove(compCls)); }
protected override Entity AddComponentAndDispatchAddEvent(ComponentBase comp, Type compCls) { bool flag = false; if (comp is AreaTriggerComponent) { this.AreaTriggerComp = (AreaTriggerComponent)comp; flag = true; } if (comp is ArmoryComponent) { this.ArmoryComp = (ArmoryComponent)comp; flag = true; } if (comp is AssetComponent) { this.AssetComp = (AssetComponent)comp; flag = true; } if (comp is AttackerComponent) { this.AttackerComp = (AttackerComponent)comp; flag = true; } if (comp is BarracksComponent) { this.BarracksComp = (BarracksComponent)comp; flag = true; } if (comp is BoardItemComponent) { this.BoardItemComp = (BoardItemComponent)comp; flag = true; } if (comp is BuildingAnimationComponent) { this.BuildingAnimationComp = (BuildingAnimationComponent)comp; flag = true; } if (comp is BuildingComponent) { this.BuildingComp = (BuildingComponent)comp; flag = true; } if (comp is ChampionComponent) { this.ChampionComp = (ChampionComponent)comp; flag = true; } if (comp is CivilianComponent) { this.CivilianComp = (CivilianComponent)comp; flag = true; } if (comp is ClearableComponent) { this.ClearableComp = (ClearableComponent)comp; flag = true; } if (comp is DamageableComponent) { this.DamageableComp = (DamageableComponent)comp; flag = true; } if (comp is DefenderComponent) { this.DefenderComp = (DefenderComponent)comp; flag = true; } if (comp is DefenseLabComponent) { this.DefenseLabComp = (DefenseLabComponent)comp; flag = true; } if (comp is DroidComponent) { this.DroidComp = (DroidComponent)comp; flag = true; } if (comp is DroidHutComponent) { this.DroidHutComp = (DroidHutComponent)comp; flag = true; } if (comp is SquadBuildingComponent) { this.SquadBuildingComp = (SquadBuildingComponent)comp; flag = true; } if (comp is NavigationCenterComponent) { this.NavigationCenterComp = (NavigationCenterComponent)comp; flag = true; } if (comp is FactoryComponent) { this.FactoryComp = (FactoryComponent)comp; flag = true; } if (comp is CantinaComponent) { this.CantinaComp = (CantinaComponent)comp; flag = true; } if (comp is FleetCommandComponent) { this.FleetCommandComp = (FleetCommandComponent)comp; flag = true; } if (comp is FollowerComponent) { this.FollowerComp = (FollowerComponent)comp; flag = true; } if (comp is GameObjectViewComponent) { this.GameObjectViewComp = (GameObjectViewComponent)comp; flag = true; } if (comp is GeneratorComponent) { this.GeneratorComp = (GeneratorComponent)comp; flag = true; } if (comp is GeneratorViewComponent) { this.GeneratorViewComp = (GeneratorViewComponent)comp; flag = true; } if (comp is HealerComponent) { this.HealerComp = (HealerComponent)comp; flag = true; } if (comp is TroopShieldComponent) { this.TroopShieldComp = (TroopShieldComponent)comp; flag = true; } if (comp is TroopShieldViewComponent) { this.TroopShieldViewComp = (TroopShieldViewComponent)comp; flag = true; } if (comp is TroopShieldHealthComponent) { this.TroopShieldHealthComp = (TroopShieldHealthComponent)comp; flag = true; } if (comp is HealthComponent) { this.HealthComp = (HealthComponent)comp; flag = true; } if (comp is HealthViewComponent) { this.HealthViewComp = (HealthViewComponent)comp; flag = true; } if (comp is HQComponent) { this.HQComp = (HQComponent)comp; flag = true; } if (comp is KillerComponent) { this.KillerComp = (KillerComponent)comp; flag = true; } if (comp is LootComponent) { this.LootComp = (LootComponent)comp; flag = true; } if (comp is MeterShaderComponent) { this.MeterShaderComp = (MeterShaderComponent)comp; flag = true; } if (comp is OffenseLabComponent) { this.OffenseLabComp = (OffenseLabComponent)comp; flag = true; } if (comp is PathingComponent) { this.PathingComp = (PathingComponent)comp; flag = true; } if (comp is SecondaryTargetsComponent) { this.SecondaryTargetsComp = (SecondaryTargetsComponent)comp; flag = true; } if (comp is ShieldBorderComponent) { this.ShieldBorderComp = (ShieldBorderComponent)comp; flag = true; } if (comp is ShieldGeneratorComponent) { this.ShieldGeneratorComp = (ShieldGeneratorComponent)comp; flag = true; } if (comp is SizeComponent) { this.SizeComp = (SizeComponent)comp; flag = true; } if (comp is ShooterComponent) { this.ShooterComp = (ShooterComponent)comp; flag = true; } if (comp is StarportComponent) { this.StarportComp = (StarportComponent)comp; flag = true; } if (comp is StateComponent) { this.StateComp = (StateComponent)comp; flag = true; } if (comp is StorageComponent) { this.StorageComp = (StorageComponent)comp; flag = true; } if (comp is SupportComponent) { this.SupportComp = (SupportComponent)comp; flag = true; } if (comp is SupportViewComponent) { this.SupportViewComp = (SupportViewComponent)comp; flag = true; } if (comp is TacticalCommandComponent) { this.TacticalCommandComp = (TacticalCommandComponent)comp; flag = true; } if (comp is ChampionPlatformComponent) { this.ChampionPlatformComp = (ChampionPlatformComponent)comp; flag = true; } if (comp is TeamComponent) { this.TeamComp = (TeamComponent)comp; flag = true; } if (comp is TrackingComponent) { this.TrackingComp = (TrackingComponent)comp; flag = true; } if (comp is TrackingGameObjectViewComponent) { this.TrackingGameObjectViewComp = (TrackingGameObjectViewComponent)comp; flag = true; } if (comp is TransformComponent) { this.TransformComp = (TransformComponent)comp; flag = true; } if (comp is TransportComponent) { this.TransportComp = (TransportComponent)comp; flag = true; } if (comp is TroopComponent) { this.TroopComp = (TroopComponent)comp; flag = true; } if (comp is TurretBuildingComponent) { this.TurretBuildingComp = (TurretBuildingComponent)comp; flag = true; } if (comp is TurretShooterComponent) { this.TurretShooterComp = (TurretShooterComponent)comp; flag = true; } if (comp is WalkerComponent) { this.WalkerComp = (WalkerComponent)comp; flag = true; } if (comp is WallComponent) { this.WallComp = (WallComponent)comp; flag = true; } if (comp is BuffComponent) { this.BuffComp = (BuffComponent)comp; flag = true; } if (comp is TrapComponent) { this.TrapComp = (TrapComponent)comp; flag = true; } if (comp is TrapViewComponent) { this.TrapViewComp = (TrapViewComponent)comp; flag = true; } if (comp is HousingComponent) { this.HousingComp = (HousingComponent)comp; flag = true; } if (comp is ScoutTowerComponent) { this.ScoutTowerComp = (ScoutTowerComponent)comp; flag = true; } if (comp is SpawnComponent) { this.SpawnComp = (SpawnComponent)comp; flag = true; } if (!flag && compCls != null) { Service.Logger.Error("Invalid component add: " + compCls.Name); } return(base.AddComponentAndDispatchAddEvent(comp, compCls)); }
private int SortTrackingForFastForwarding(TrackingComponent a, TrackingComponent b) { return(b.IdleFastForwardTimeRemaining.CompareTo(a.IdleFastForwardTimeRemaining)); }
// Use this for initialization void Start() { BaseTrackingComponent = GetComponent <TrackingComponent>(); TrackingTransform = BaseTrackingComponent.transform; CheckForHit(); }