private void SetStarportDecal(Entity entity) { BuildingComponent buildingComponent = entity.Get <BuildingComponent>(); if (buildingComponent.BuildingType.Type == BuildingType.Starport) { int lvl = buildingComponent.BuildingType.Lvl; int num = (lvl - 1) % 3; float x = StarportDecalManager.FX_STARPORT_DECAL_OFFSET[num]; Vector2 mainTextureOffset = new Vector2(x, 0f); GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { Transform[] componentsInChildren = gameObjectViewComponent.MainGameObject.GetComponentsInChildren <Transform>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (componentsInChildren[i].gameObject.name.Contains("numberMesh")) { GameObject gameObject = componentsInChildren[i].gameObject; Renderer component = gameObject.GetComponent <Renderer>(); Material material = UnityUtils.EnsureMaterialCopy(component); material.mainTextureOffset = mainTextureOffset; this.decalMaterials.Add(material); } } } } }
public void ShowHighlight(Entity entity) { SmartEntity smartEntity = (SmartEntity)entity; if (smartEntity.GameObjectViewComp == null) { return; } uint num = 0u; uint minRange = 0u; this.DetermineEffectRange(smartEntity, ref num, ref minRange); this.GenerateEffectRadius(num, minRange); uint num2 = 0u; this.DetermineTriggerRange(smartEntity, ref num2); this.GenerateTriggerRadius(num2); this.inverseSpeedFactor = ((num2 > 0u) ? (15f / num2) : 0f); this.UpdateDepths(num, num2); this.radiusParent.SetActive(true); this.govc = smartEntity.GameObjectViewComp; this.govc.AttachGameObject("dynamicRadius", this.radiusParent, new Vector3(0f, 0.09f, 0f), true, false); this.showing = true; Service.Get <ViewTimeEngine>().RegisterFrameTimeObserver(this); this.particleView.ShowHighlight(entity); }
private void PrepareFactorySparkWithEvent(int message, GameObjectViewComponent viewComp) { if (viewComp.EffectGameObjects.Count > message) { GameObject gameObject = viewComp.EffectGameObjects[message]; if (gameObject != null) { Transform transform = gameObject.transform; Transform transform2 = null; if (transform.childCount > 0) { transform2 = transform.GetChild(0); } if (transform2 != null) { ParticleSystem component = transform2.GetComponent <ParticleSystem>(); component.simulationSpace = ParticleSystemSimulationSpace.World; if (component != null) { this.PlayStopParticle(0u, component); } } } } }
public void DepotSpark(int message, GameObjectViewComponent gameObjViewComp) { if (gameObjViewComp != null) { this.PrepareFactorySparkWithEvent(message, gameObjViewComp); } }
public static Target CreateTargetForTurret(SmartEntity targetEntity) { if (targetEntity == null) { return(null); } TransformComponent transformComp = targetEntity.TransformComp; if (transformComp == null) { return(null); } Target target = new Target(); target.TargetEntity = targetEntity; target.TargetBoardX = transformComp.CenterGridX(); target.TargetBoardZ = transformComp.CenterGridZ(); GameObjectViewComponent gameObjectViewComp = targetEntity.GameObjectViewComp; if (gameObjectViewComp == null) { Target.SetDefaultTargetWorldLocation(target, 1.25f); return(target); } target.TargetWorldLocation = UnityUtils.GetGameObjectBounds(gameObjectViewComp.MainGameObject).center; return(target); }
public void ShowHighlight(Entity entity) { if (!this.ready) { this.pendingEntity = entity; return; } if (entity == null) { Service.Get <StaRTSLogger>().Error("RadiusView.ShowHighlight: Entity = null"); return; } this.govc = entity.Get <GameObjectViewComponent>(); if (this.govc == null) { return; } if (this.radiusGameObject == null) { Service.Get <StaRTSLogger>().Error("RadiusView.ShowHighlight: radiusGameObject = null"); return; } this.radiusGameObject.SetActive(true); if (!this.SetupParticlesOnShow(entity)) { this.radiusGameObject.SetActive(false); return; } this.govc.AttachGameObject("radius", this.radiusGameObject, new Vector3(0f, 0.06f, 0f), true, false); }
private void AddOnSuccess(object asset, object cookie) { AddOnViewParams addOnViewParams = (AddOnViewParams)cookie; if (addOnViewParams.Entity == null) { return; } GameObjectViewComponent gameObjectViewComp = addOnViewParams.Entity.GameObjectViewComp; if (gameObjectViewComp == null || gameObjectViewComp.MainGameObject == null) { return; } string parentName = addOnViewParams.ParentName; Transform transform = gameObjectViewComp.MainGameObject.transform.Find(parentName); if (transform == null) { Service.Logger.ErrorFormat("Add On Parent not found! There's a mismatch between the CMS AddOn parent name ({0}) and the loaded model ({1})", new object[] { parentName, gameObjectViewComp.MainGameObject.name }); return; } GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(asset as GameObject); gameObject.transform.parent = transform; gameObject.transform.localPosition = Vector3.zero; gameObject.transform.localScale = Vector3.one; gameObject.transform.localRotation = Quaternion.identity; }
private void HideScaffold(Entity building) { if (this.viewObjects.ContainsKey(building)) { GameObjectViewComponent gameObjectViewComponent = building.Get <GameObjectViewComponent>(); List <ScaffoldingData> list = this.viewObjects[building]; int i = 0; int count = list.Count; while (i < count) { ScaffoldingData scaffoldingData = list[i]; GameObject gameObj = scaffoldingData.GameObj; if (gameObj != null && gameObjectViewComponent != null) { gameObjectViewComponent.DetachGameObject(gameObj.name); } this.UnloadScaffold(scaffoldingData); i++; } list.Clear(); this.viewObjects.Remove(building); if (this.waitingForView.Contains(building)) { this.waitingForView.Remove(building); } } }
private void SparkFxSuccess(object asset, object cookie) { SmartEntity smartEntity = (SmartEntity)cookie; if (smartEntity == null || smartEntity.GameObjectViewComp == null) { return; } GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; int i = 0; int count = gameObjectViewComp.EffectLocators.Count; while (i < count) { GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(asset as GameObject); GameObject gameObject2 = gameObjectViewComp.EffectLocators[i]; if (gameObject2 != null) { gameObjectViewComp.EffectGameObjects.Add(gameObject); gameObject.transform.SetParent(gameObject2.transform); gameObject.transform.localPosition = new Vector3(0f, 0f, 0f); } i++; } }
public void ApplyHitEffect(Entity building, Vector3 worldPosition) { GameObjectViewComponent gameObjectViewComponent = building.Get <GameObjectViewComponent>(); if (gameObjectViewComponent == null) { return; } ShieldBuildingInfo shieldBuildingInfo = this.GetShieldBuildingInfo(building, ShieldLoadReason.ApplyHitEffect, worldPosition); if (shieldBuildingInfo == null) { return; } FactionType factionType = this.GetFactionType(building); GameObject gameObject = this.GetImpactFromPool(shieldBuildingInfo, factionType); if (gameObject == null) { return; } ParticleSystem component = gameObject.GetComponent <ParticleSystem>(); gameObject = gameObject.transform.parent.gameObject; gameObject.transform.position = worldPosition; gameObject.transform.LookAt(gameObjectViewComponent.MainTransform); gameObject.SetActive(true); component.Play(); ImpactCookie impactCookie = new ImpactCookie(); impactCookie.ImpactGameObject = component.gameObject; impactCookie.ImpactFaction = factionType; Service.ViewTimerManager.CreateViewTimer(1.2f, false, new TimerDelegate(this.CleanUpHitEffect), impactCookie); }
private Transform GetTargetTransform(Bullet bullet, Vector3 startLocation, Vector3 endLocation) { Transform transform = null; if (bullet.ProjectileType.SeeksTarget && bullet.Target != null) { GameObjectViewComponent gameObjectViewComp = bullet.Target.GameObjectViewComp; if (gameObjectViewComp != null) { if (gameObjectViewComp.HitLocators.Count > 0) { Vector3 vector = startLocation - endLocation; int num = (int)(Mathf.Atan2(vector.z, vector.x) * 57.2957764f); int num2 = 4 - num / 45; if (gameObjectViewComp.HitLocators != null && num2 < gameObjectViewComp.HitLocators.Count && gameObjectViewComp.HitLocators[num2] != null) { transform = gameObjectViewComp.HitLocators[num2].transform; } } else if (gameObjectViewComp.CenterOfMass != null) { transform = gameObjectViewComp.CenterOfMass.transform; } if (transform == null) { transform = gameObjectViewComp.MainTransform; } } } return(transform); }
private void SpawnChargeEmitter(SmartEntity owner) { ShooterComponent shooterComp = owner.ShooterComp; if (shooterComp == null) { return; } ProjectileTypeVO projectileType = shooterComp.ShooterVO.ProjectileType; if (string.IsNullOrEmpty(projectileType.ChargeAssetName)) { return; } GameObjectViewComponent gameObjectViewComp = owner.GameObjectViewComp; if (gameObjectViewComp == null || gameObjectViewComp.GunLocators.Count == 0 || gameObjectViewComp.GunLocators[0].Count == 0) { return; } GameObject gameObject = gameObjectViewComp.GunLocators[0][0]; if (gameObject == null) { return; } Vector3 position = gameObject.transform.position; this.StartDirectionalEmitter(owner, gameObject, position, Vector3.zero, projectileType.ChargeAssetName, projectileType.MuzzleFlashFadeTime); }
public void CheckHealthView(SmartEntity entity) { HealthComponent healthComp = entity.HealthComp; ShieldBorderComponent shieldBorderComp = entity.ShieldBorderComp; if (shieldBorderComp != null) { SmartEntity smartEntity = (SmartEntity)shieldBorderComp.ShieldGeneratorEntity; GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; bool showAtFullHealth = this.ShowHealthView(entity, healthComp, gameObjectViewComp, false, true, false, false); this.ShowHealthView(smartEntity, smartEntity.HealthComp, gameObjectViewComp, true, false, showAtFullHealth, true); return; } ShieldGeneratorComponent shieldGeneratorComp = entity.ShieldGeneratorComp; if (shieldGeneratorComp != null) { SmartEntity smartEntity2 = (SmartEntity)shieldGeneratorComp.ShieldBorderEntity; GameObjectViewComponent gameObjectViewComp = entity.GameObjectViewComp; bool showAtFullHealth2 = this.ShowHealthView(entity, healthComp, gameObjectViewComp, true, false, false, true); this.ShowHealthView(smartEntity2, smartEntity2.HealthComp, gameObjectViewComp, false, true, showAtFullHealth2, false); return; } TroopShieldHealthComponent troopShieldHealthComp = entity.TroopShieldHealthComp; bool hasSecondary = false; bool showAtFullHealth3 = false; if (troopShieldHealthComp != null) { showAtFullHealth3 = this.ShowHealthView(entity, troopShieldHealthComp, entity.GameObjectViewComp, true, true, true, false); hasSecondary = true; } this.ShowHealthView(entity, healthComp, entity.GameObjectViewComp, true, hasSecondary, showAtFullHealth3, true); }
public void UpdateNewEntityView(SmartEntity entity) { GameObjectViewComponent gameObjectViewComp = entity.GameObjectViewComp; TransformComponent transformComp = entity.TransformComp; if (gameObjectViewComp == null || transformComp == null) { Service.Get <StaRTSLogger>().WarnFormat("Entity is not ready for rendering. view: {0}, transform: {1}, entity: {2}", new object[] { (gameObjectViewComp == null) ? "null" : gameObjectViewComp.ToString(), (transformComp == null) ? "null" : transformComp.ToString(), entity.ID }); return; } gameObjectViewComp.MainTransform.position = new Vector3(Units.BoardToWorldX(transformComp.CenterX()), gameObjectViewComp.MainTransform.position.y, Units.BoardToWorldZ(transformComp.CenterZ())); if (entity.TroopComp != null || entity.DroidComp != null) { this.RotateGameObject(entity, 0f, 0f, 0f); float speed = Service.Get <BattlePlaybackController>().CurrentPlaybackScale; this.UpdateAnimationSpeed(gameObjectViewComp, speed); this.UpdateAnimationState(gameObjectViewComp, entity.StateComp); return; } if (entity.TrapComp != null) { gameObjectViewComp.MainGameObject.SetActive(true); Service.Get <TrapController>().SetTrapState(entity.TrapComp, entity.TrapComp.CurrentState); Service.Get <TrapViewController>().UpdateTrapVisibility(entity); gameObjectViewComp.Rotate(transformComp.Rotation); return; } gameObjectViewComp.Rotate(transformComp.Rotation); gameObjectViewComp.MainGameObject.SetActive(true); }
public void TrySetupView() { if (this.loaded) { return; } if (this.view == null) { return; } GameObjectViewComponent gameObjectViewComponent = this.Entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent == null) { return; } HeroDecal.SetupDecal(this.view, this.scale); this.view.SetActive(true); gameObjectViewComponent.AttachGameObject(this.name, this.view, Vector3.zero, true, true); this.loaded = true; Service.Get <ViewTimeEngine>().RegisterFrameTimeObserver(this); if (this.fading) { this.FadeToGray(); } }
private void CreateAndAttachFXEntityInternal(string assetName, Dictionary <string, object> cookie) { string text = (string)cookie["assetKey"]; string text2 = (string)cookie["attachmentKey"]; if (this.activeTimers.ContainsKey(text)) { Service.Get <ViewTimerManager>().TriggerKillViewTimer(this.activeTimers[text]); this.activeTimers.Remove(text); } SmartEntity smartEntity = (SmartEntity)cookie["entity"]; GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; if (gameObjectViewComp != null && !gameObjectViewComp.HasAttachment(text2)) { if (!this.EnsureUniqueFX(text, assetName, text2)) { return; } AssetManager assetManager = Service.Get <AssetManager>(); assetManager.RegisterPreloadableAsset(assetName); AssetHandle value = AssetHandle.Invalid; assetManager.Load(ref value, assetName, new AssetSuccessDelegate(this.OnAttachedFXLoaded), null, cookie); this.assetHandles.Add(text, value); } }
protected override void Update(float dt) { Vector3 zero = Vector3.zero; for (EntityRenderNode entityRenderNode = this.nodeList.Head; entityRenderNode != null; entityRenderNode = entityRenderNode.Next) { Vector3 vector = zero; SmartEntity smartEntity = (SmartEntity)entityRenderNode.Entity; GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; StateComponent stateComp = smartEntity.StateComp; EntityState rawState = stateComp.RawState; if (rawState == EntityState.Moving) { PathView pathView = smartEntity.PathingComp.PathView; if (pathView != null) { pathView.TimeOnPathSegment += dt; vector = this.entityRenderController.MoveGameObject(gameObjectViewComp, pathView, smartEntity.SizeComp.Width); } } if (rawState != EntityState.Dying) { this.entityRenderController.RotateGameObject(smartEntity, vector.x, vector.z, dt); } else if (smartEntity.TroopComp != null) { gameObjectViewComp.UpdateAllAttachments(); } if (smartEntity.TroopComp != null || smartEntity.DroidComp != null) { bool isAbilityModeActive = smartEntity.TroopComp != null && smartEntity.TroopComp.IsAbilityModeActive; this.entityRenderController.UpdateAnimationState(gameObjectViewComp, stateComp, isAbilityModeActive); } } }
public void Cleanup() { if (this.Entity == null) { return; } Service.Get <ViewTimeEngine>().UnregisterFrameTimeObserver(this); GameObjectViewComponent gameObjectViewComponent = this.Entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { gameObjectViewComponent.DetachGameObject(this.name); } if (this.material != null) { UnityUtils.DestroyMaterial(this.material); this.material = null; } if (this.view != null) { UnityEngine.Object.Destroy(this.view); this.view = null; } if (this.heroHandle != AssetHandle.Invalid) { Service.Get <AssetManager>().Unload(this.heroHandle); this.heroHandle = AssetHandle.Invalid; } this.Entity = null; this.hero = null; this.name = null; this.loaded = false; this.fading = false; }
public void RemoveAttachedRubbleFromEntity(Entity entity) { GameObjectViewComponent viewComp = entity.Get <GameObjectViewComponent>(); GameUtils.ToggleGameObjectViewVisibility(viewComp, true); this.RemoveAttachedFXFromEntity(entity, "rubble"); }
public void OnViewFrameTime(float dt) { GameObjectViewComponent gameObjectViewComponent = this.Entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { gameObjectViewComponent.UpdateAttachment(this.name); } if (this.material == null) { this.TrySetMaterial(); } if (this.fading && this.material != null) { this.fadingTime += dt; bool flag = this.fadingTime >= 1.5f; if (flag) { this.fadingTime = 1.5f; } float num = this.fadingTime / 1.5f; float materialSaturation = 1f - num; this.SetMaterialSaturation(materialSaturation); if (flag) { this.fading = false; Service.Get <ViewTimeEngine>().UnregisterFrameTimeObserver(this); } } }
private void ActivateAbilityViewEffects(DeployedTroop deployedTroop, TroopAbilityVO ability) { SmartEntity entity = deployedTroop.Entity; GameObjectViewComponent gameObjectViewComp = entity.GameObjectViewComp; if (gameObjectViewComp == null) { return; } if (ability.AltGunLocators != null && ability.AltGunLocators.Length != 0) { gameObjectViewComp.SwitchGunLocators(true); } GameObject mainGameObject = gameObjectViewComp.MainGameObject; mainGameObject.transform.localScale = Vector3.one * ability.PersistentScaling; if (!string.IsNullOrEmpty(ability.PersistentEffect)) { ITroopDeployableVO troopType = entity.TroopComp.TroopType; TransformComponent transformComp = entity.TransformComp; deployedTroop.LightSaberHitFx = new LightSaberHitEffect(ability.ProjectileType.SplashRadius, transformComp.CenterGridX(), transformComp.CenterGridZ(), mainGameObject.transform, ability.PersistentEffect, troopType.Faction); } if (deployedTroop.WeaponTrail != null && deployedTroop.WeaponTrailActivateLifetime > 0f) { deployedTroop.WeaponTrail.ChangeLifeTime(deployedTroop.WeaponTrailActivateLifetime); } }
private void MoveLiftedBuilding(Entity building, Vector3 worldGroundPosition, bool isPartOfSelection) { Entity selectedBuilding = this.buildingSelector.SelectedBuilding; TransformComponent transformComponent = building.Get <TransformComponent>(); TransformComponent transformComponent2 = selectedBuilding.Get <TransformComponent>(); float num = (float)transformComponent2.X - (float)transformComponent.BoardWidth / 2f + (float)transformComponent2.BoardWidth / 2f; float num2 = (float)transformComponent2.Z - (float)transformComponent.BoardDepth / 2f + (float)transformComponent2.BoardDepth / 2f; float num3 = (float)transformComponent.X; float num4 = (float)transformComponent.Z; float num5 = Units.BoardToWorldX(num3 - num); float num6 = Units.BoardToWorldZ(num4 - num2); Vector3 grabPoint = this.buildingSelector.GrabPoint; float num7 = worldGroundPosition.x - grabPoint.x + num5; float num8 = worldGroundPosition.z - grabPoint.z + num6; float num9; float num10; EditBaseController.BuildingBoardToWorld(building, 0, 0, out num9, out num10); float num11 = num7 - num9; float num12 = num8 - num10; Units.SnapWorldToGridX(ref num11); Units.SnapWorldToGridZ(ref num12); int num13 = Units.WorldToBoardX(num11); int num14 = Units.WorldToBoardZ(num12); transformComponent.X = num13; transformComponent.Z = num14; int num15 = -2147483648; if (this.prevBoardAnchorX.ContainsKey(building)) { num15 = this.prevBoardAnchorX[building]; } int num16 = -2147483648; if (this.prevBoardAnchorZ.ContainsKey(building)) { num16 = this.prevBoardAnchorZ[building]; } if (num13 != num15 || num14 != num16) { this.canOccupy = this.EntireSelectionIsPlaceable(); Service.UXController.MiscElementsManager.EnableConfirmGroupAcceptButton(this.canOccupy); FootprintMoveData cookie = new FootprintMoveData(building, num11, num12, this.canOccupy); Service.EventManager.SendEvent(EventId.UserMovedLiftedBuilding, cookie); } GameObjectViewComponent gameObjectViewComponent = building.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { gameObjectViewComponent.SetXYZ(num7, 3f, num8); } if (this.canOccupy && !isPartOfSelection) { this.prevValidBoardAnchorX[building] = num13; this.prevValidBoardAnchorZ[building] = num14; } }
private void TryShowEffect() { if (this.troopEntity == null) { Service.Get <StaRTSLogger>().Error("TryShowEffect with Null troopEntity"); return; } bool flag = !this.showFullEffect || (this.troopCardTexture != null && this.effectObj != null && this.effectObj.transform != null); if (!this.ShuttleReadyForShowEffect()) { this.shuttle = Service.Get <ShuttleController>().GetShuttleForStarport(this.starportEntity); } if (!flag || !this.pathReached || !this.ShuttleReadyForShowEffect()) { if (!this.ShuttleReadyForShowEffect()) { Service.Get <EventManager>().RegisterObserver(this, EventId.ShuttleAnimStateChanged, EventPriority.Default); } return; } GameObjectViewComponent gameObjectViewComponent = this.troopEntity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent == null) { Service.Get <EventManager>().RegisterObserver(this, EventId.TroopViewReady, EventPriority.Default); return; } Service.Get <EventManager>().SendEvent(EventId.TroopLoadingIntoStarport, this.troopEntity); if (this.entityFader == null || gameObjectViewComponent.MainGameObject == null) { this.Finish(); return; } Vector3 position = this.shuttle.CenterOfMass.transform.position; this.animPosition = new AnimPosition(gameObjectViewComponent.MainGameObject, 0.8f, position); Service.Get <AnimController>().Animate(this.animPosition); this.entityFader.FadeOut(this.troopEntity, 0f, 0.3f, null, new FadingDelegate(this.OnFadeOutComplete)); AssetMeshDataMonoBehaviour component = gameObjectViewComponent.MainGameObject.GetComponent <AssetMeshDataMonoBehaviour>(); if (component != null && component.ShadowGameObject != null) { component.ShadowGameObject.SetActive(false); } this.timerId = Service.Get <ViewTimerManager>().CreateViewTimer(2f, false, new TimerDelegate(this.OnEffectTimer), null); if (this.showFullEffect) { this.effectObj.SetActive(true); position.y = 1.2f; this.effectObj.transform.position = position; this.troopCardMaterial = UnityUtils.EnsureMaterialCopy(this.troopCardPS.GetComponent <Renderer>()); this.troopCardMaterial.mainTexture = this.troopCardTexture; this.troopCardPS.Play(); this.shuttleGlowPS.Play(); this.shuttle.PulseOutline(); } }
public void LoadEntityAsset(Entity e, string assetName, bool createCollider) { SmartEntity smartEntity = (SmartEntity)e; EntityViewParams entityViewParams = new EntityViewParams(smartEntity, createCollider); AssetComponent assetComp = smartEntity.AssetComp; if (assetComp == null) { Service.Get <StaRTSLogger>().Error("Entity is missing asset component: " + assetName); this.AssetFailure(entityViewParams); return; } if (assetComp.RequestedAssetName == assetName) { bool isBuilding = smartEntity.BuildingComp != null; bool flag = assetName == null; bool isDroid = smartEntity.DroidComp != null; if (!flag) { GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; if (gameObjectViewComp == null || gameObjectViewComp.MainGameObject == null) { return; } } this.SendAssetReadyEvent(isBuilding, flag, isDroid, entityViewParams); return; } if (assetComp.RequestedAssetHandle != AssetHandle.Invalid) { this.UnloadEntityAsset(smartEntity); } assetComp.RequestedAssetName = assetName; if (assetName == null) { this.AssetFailure(entityViewParams); return; } AssetManager assetManager = Service.Get <AssetManager>(); assetManager.RegisterPreloadableAsset(assetName); WorldPreloadAsset preloadedAsset = Service.Get <WorldPreloader>().GetPreloadedAsset(assetName); if (preloadedAsset == null) { AssetHandle requestedAssetHandle = AssetHandle.Invalid; assetManager.Load(ref requestedAssetHandle, assetName, new AssetSuccessDelegate(this.AssetSuccess), new AssetFailureDelegate(this.AssetFailure), entityViewParams); assetComp.RequestedAssetHandle = requestedAssetHandle; return; } assetComp.RequestedAssetHandle = preloadedAsset.Handle; if (preloadedAsset.GameObj == null) { this.AssetFailure(entityViewParams); return; } this.AssetSuccess(preloadedAsset.GameObj, entityViewParams); }
public void UpdateAnimationSpeed(GameObjectViewComponent view, float speed) { Animator component = view.MainGameObject.GetComponent <Animator>(); if (component != null) { component.speed = speed; } }
private void OnAssetSuccess(object asset, object cookie) { GameObject gameObject = (GameObject)asset; ScaffoldingData scaffoldingData = (ScaffoldingData)cookie; scaffoldingData.GameObj = gameObject; Entity building = scaffoldingData.Building; if (this.viewObjects.ContainsKey(building)) { int offset = scaffoldingData.Offset; bool flip = scaffoldingData.Flip; gameObject.name = string.Format("Scaffold_{0}_{1}{2}", new object[] { building.ID, flip ? "L" : "R", offset }); BuildingComponent buildingComponent = building.Get <BuildingComponent>(); BuildingTypeVO buildingType = buildingComponent.BuildingType; Transform transform = gameObject.transform; float num; float num2; if (flip) { num = (float)(-(float)offset); num2 = 0f; transform.localScale = new Vector3(-1f, 1f, 1f); transform.rotation = Quaternion.AngleAxis(-180f, Vector3.up); } else { num = 0f; num2 = (float)(-(float)offset); transform.rotation = Quaternion.AngleAxis(-90f, Vector3.up); } transform.localPosition = new Vector3((num + (float)buildingType.SizeX * 0.5f) * 3f, 0f, (num2 + (float)buildingType.SizeY * 0.5f) * 3f); List <ScaffoldingData> list = this.viewObjects[building]; list.Add(scaffoldingData); GameObjectViewComponent gameObjectViewComponent = building.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { this.AttachToView(gameObject, gameObjectViewComponent); return; } gameObject.SetActive(false); if (!this.waitingForView.Contains(building)) { this.waitingForView.Add(building); return; } } else { this.UnloadScaffold(scaffoldingData); } }
public void HideHighlight() { if (this.govc == null) { return; } this.govc.DetachGameObject("radius"); this.govc = null; this.radiusGameObject.SetActive(false); }
public ShaderSwappedEntity(Entity entity, string shaderName) { this.entity = entity; this.combineMeshManager = Service.CombineMeshManager; GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { base.Init(gameObjectViewComponent.MainGameObject, shaderName); } }
private bool SpawnVehicle(Contract contract, Entity contractEntity) { if (this.busyEntities.ContainsKey(contractEntity)) { return(true); } TroopTypeVO optional = this.sdc.GetOptional <TroopTypeVO>(contract.ProductUid); if (optional == null) { Service.Logger.Error("Could not find troop with uid " + contract.ProductUid); return(true); } bool flag = this.DespawnVehicle(contractEntity); string troopID = optional.TroopID; string assetName; if (troopID == "ATAT") { assetName = "atatfactory_emp-mod"; } else if (troopID == "MHC") { assetName = "umhcfactory_emp-mod"; } else { assetName = optional.AssetName; } GameObjectViewComponent gameObjectViewComponent = contractEntity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent == null) { return(true); } GameObject mainGameObject = gameObjectViewComponent.MainGameObject; if (mainGameObject == null) { return(true); } Transform transform = mainGameObject.transform.Find("locator_vehicle"); if (transform == null) { return(true); } Vector3 offset = Vector3.zero; offset = transform.position + new Vector3(0f, 0.2f, 0f) - mainGameObject.transform.position; this.fxManager.CreateAndAttachFXToEntity(contractEntity, assetName, "FactoryProduct", new FXManager.AttachedFXLoadedCallback(this.OnVehicleAssetLoadSuccess), false, offset, true); this.busyEntities.Add(contractEntity, optional); return(!flag); }
public FadingEntity(Entity entity, float delay, float fadeTime, FadingDelegate onStart, FadingDelegate onComplete) : base(entity, delay, fadeTime, onStart, onComplete) { this.entity = entity; GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent != null) { MeterShaderComponent meter = entity.Get <MeterShaderComponent>(); base.InitData(gameObjectViewComponent.MainGameObject, meter); } }