public void SetTrapState(TrapComponent comp, TrapState state) { SmartEntity smartEntity = (SmartEntity)comp.Entity; TrapViewComponent trapViewComp = smartEntity.TrapViewComp; TrapState currentState = comp.CurrentState; if (currentState != state) { comp.CurrentState = state; IState currentState2 = Service.Get <GameStateMachine>().CurrentState; if (TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState2)) { smartEntity.BuildingComp.BuildingTO.CurrentStorage = ((state == TrapState.Armed) ? 1 : 0); } Service.Get <TrapViewController>().UpdateTrapVisibility((SmartEntity)comp.Entity); switch (state) { case TrapState.Spent: Service.Get <EventManager>().SendEvent(EventId.TrapDisarmed, comp); break; case TrapState.Active: Service.Get <EventManager>().SendEvent(EventId.TrapTriggered, comp); break; case TrapState.Destroyed: comp.CurrentState = TrapState.Spent; Service.Get <EventManager>().SendEvent(EventId.TrapDestroyed, comp); break; } } Service.Get <TrapViewController>().SetTrapViewState(trapViewComp, state); }
protected override bool SetupParticlesOnShow(Entity entity) { BuildingTypeVO buildingType = entity.Get <BuildingComponent>().BuildingType; if (buildingType.Type == BuildingType.Trap && entity.Get <TrapComponent>().CurrentState != TrapState.Spent && !ContractUtils.IsBuildingUpgrading(entity) && !ContractUtils.IsBuildingConstructing(entity)) { TrapTypeVO trapType = Service.Get <IDataController>().Get <TrapTypeVO>(buildingType.TrapUid); uint trapMaxRadius = TrapUtils.GetTrapMaxRadius(trapType); uint trapAttackRadius = TrapUtils.GetTrapAttackRadius(trapType); base.SetupParticleSystemWithRange(this.triggerRadius, 5f, trapMaxRadius); base.SetupParticleSystemWithRange(this.damageRadius, 5f, trapAttackRadius); return(true); } return(false); }
public void ReadRow(Row row) { this.Uid = row.Uid; this.EventType = StringUtils.ParseEnum <TrapEventType>(row.TryGetString(TrapTypeVO.COLUMN_eventType)); this.SetEventData(TrapUtils.ParseEventData(this.EventType, row.TryGetString(TrapTypeVO.COLUMN_eventData))); this.TargetType = row.TryGetString(TrapTypeVO.COLUMN_targetType); this.TriggerConditions = row.TryGetString(TrapTypeVO.COLUMN_triggerConditions); this.RevealAudio = row.TryGetString(TrapTypeVO.COLUMN_revealAudio); this.DisarmConditions = row.TryGetString(TrapTypeVO.COLUMN_disarmConditions); this.AddOns = TrapUtils.ParseAddons(row.TryGetString(TrapTypeVO.COLUMN_addOns)); this.RearmCreditsCost = row.TryGetInt(TrapTypeVO.COLUMN_rearmCreditsCost); this.RearmMaterialsCost = row.TryGetInt(TrapTypeVO.COLUMN_rearmMaterialsCost); this.RearmContrabandCost = row.TryGetInt(TrapTypeVO.COLUMN_rearmContrabandCost); this.ParsedTrapConditions = TrapUtils.ParseConditions(this.TriggerConditions); }
private void DetermineEffectRange(SmartEntity entity, ref uint maxRange, ref uint minRange) { if (entity.BuildingComp == null) { return; } if (entity.ShooterComp != null) { maxRange = entity.ShooterComp.ShooterVO.MaxAttackRange; minRange = entity.ShooterComp.ShooterVO.MinAttackRange; return; } if (entity.TrapComp != null) { maxRange = TrapUtils.GetTrapAttackRadius(entity.TrapComp.Type); return; } }
protected virtual bool SetupParticlesOnShow(SmartEntity entity) { uint minRange; if (entity.ShooterComp != null) { minRange = entity.ShooterComp.ShooterVO.MaxAttackRange; } else { if (entity.TrapComp == null) { return(false); } minRange = TrapUtils.GetTrapAttackRadius(entity.TrapComp.Type); } this.SetupParticleSystemWithRange(this.whiteRingParticles, 5f, minRange); return(true); }
private void UpdateRadius() { int trapMaxRadius = (int)TrapUtils.GetTrapMaxRadius(this.trapVO); int trapMaxRadius2 = (int)TrapUtils.GetTrapMaxRadius(this.maxTrapVO); SliderControl sliderControl = this.sliders[1]; sliderControl.DescLabel.Text = this.lang.Get("TRAP_TRIGGER_RADIUS", new object[0]); sliderControl.CurrentLabel.Text = this.lang.ThousandsSeparated(trapMaxRadius); sliderControl.CurrentSlider.Value = ((trapMaxRadius2 == 0) ? 0f : ((float)trapMaxRadius / (float)trapMaxRadius2)); if (this.useUpgradeGroup && this.nextTrapVO != null) { int trapMaxRadius3 = (int)TrapUtils.GetTrapMaxRadius(this.maxTrapVO); sliderControl.NextLabel.Text = this.lang.Get("PLUS", new object[] { this.lang.ThousandsSeparated(trapMaxRadius3 - trapMaxRadius) }); sliderControl.NextSlider.Value = ((trapMaxRadius2 == 0) ? 0f : ((float)trapMaxRadius3 / (float)trapMaxRadius2)); } }
public void UpdateTrapVisibility(SmartEntity entity) { if (entity.TrapViewComp == null) { return; } TrapViewComponent trapViewComp = entity.TrapViewComp; IState currentState = Service.GameStateMachine.CurrentState; bool flag = currentState is BattleStartState || currentState is BattlePlayState || currentState is BattlePlaybackState || currentState is BattleEndState; bool flag2 = GameUtils.IsVisitingBase(); bool flag3 = TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState); bool flag4 = (flag && !flag3) || flag2; trapViewComp.Anim.SetLayerWeight(1, (float)((!flag4) ? 1 : 0)); trapViewComp.Anim.SetLayerWeight(0, (float)((!flag4) ? 0 : 1)); bool active = false; if (!flag2) { switch (entity.TrapComp.CurrentState) { case TrapState.Spent: active = (!flag || flag3 || entity.TrapComp.PreviousState == TrapState.Active); break; case TrapState.Armed: active = (!flag || flag3); break; case TrapState.Active: active = true; break; case TrapState.Destroyed: active = flag; break; } } trapViewComp.Contents.SetActive(active); }
public void SetTrapState(TrapComponent comp, TrapState state) { SmartEntity smartEntity = (SmartEntity)comp.Entity; TrapViewComponent trapViewComp = smartEntity.TrapViewComp; TrapState currentState = comp.CurrentState; if (currentState != state) { comp.CurrentState = state; IState currentState2 = Service.GameStateMachine.CurrentState; if (TrapUtils.IsCurrentPlayerInDefensiveBattle(currentState2)) { smartEntity.BuildingComp.BuildingTO.CurrentStorage = ((state != TrapState.Armed) ? 0 : 1); } Service.TrapViewController.UpdateTrapVisibility((SmartEntity)comp.Entity); if (state != TrapState.Active) { if (state != TrapState.Spent) { if (state == TrapState.Destroyed) { comp.CurrentState = TrapState.Spent; Service.EventManager.SendEvent(EventId.TrapDestroyed, comp); } } else { Service.EventManager.SendEvent(EventId.TrapDisarmed, comp); } } else { Service.EventManager.SendEvent(EventId.TrapTriggered, comp); } } Service.TrapViewController.SetTrapViewState(trapViewComp, state); }
private void DetermineTriggerRange(SmartEntity entity, ref uint triggerRange) { if (entity.BuildingComp == null) { return; } BuildingTypeVO buildingType = entity.BuildingComp.BuildingType; if (buildingType.Type == BuildingType.Squad || buildingType.Type == BuildingType.ChampionPlatform) { triggerRange = buildingType.ActivationRadius; return; } if (entity.ShooterComp != null) { triggerRange = entity.ShooterComp.ShooterVO.MaxAttackRange; return; } if (entity.TrapComp != null) { triggerRange = TrapUtils.GetTrapMaxRadius(entity.TrapComp.Type); return; } }