public void CreateAndAttachFXToEntity(Entity entity, string assetName, string attachmentKey, FXManager.AttachedFXLoadedCallback callback, bool pinToCenterOfMass, Vector3 offset, bool applyRotation) { Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["assetName"] = assetName; dictionary["entity"] = entity; dictionary["attachmentKey"] = attachmentKey; dictionary["assetKey"] = FXUtils.MakeAssetKey(attachmentKey, entity); dictionary["callback"] = callback; dictionary["centerOfMass"] = pinToCenterOfMass; dictionary["coords"] = offset; dictionary["rotation"] = applyRotation; this.CreateAndAttachFXEntityInternal(assetName, dictionary); }
public void StopParticlesAndRemoveAttachedFXFromEntity(Entity entity, string attachmentKey) { if (entity == null) { return; } GameObjectViewComponent gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); if (gameObjectViewComponent == null) { return; } string text = FXUtils.MakeAssetKey(attachmentKey, entity); GameObject attachedGameObject = gameObjectViewComponent.GetAttachedGameObject(attachmentKey); if (attachedGameObject != null) { float delay = 0f; ParticleSystem[] componentsInChildren = attachedGameObject.GetComponentsInChildren <ParticleSystem>(true); if (componentsInChildren != null && componentsInChildren.Length > 0) { delay = 5f; int i = 0; int num = componentsInChildren.Length; while (i < num) { componentsInChildren[i].Stop(false); i++; } } Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["entity"] = entity; dictionary["attachmentKey"] = attachmentKey; dictionary["assetKey"] = text; dictionary["gameObject"] = attachedGameObject; if (this.activeTimers.ContainsKey(text)) { Service.ViewTimerManager.KillViewTimer(this.activeTimers[text]); this.activeTimers.Remove(text); } uint value = Service.ViewTimerManager.CreateViewTimer(delay, false, new TimerDelegate(this.RemoveAttachedFXFromEntityAfterDelay), dictionary); this.activeTimers.Add(text, value); } else { this.UnloadByAssetKey(text); } }
public void CreateFXAtPosition(string assetName, Vector3 worldPos, Quaternion rotation) { string text = FXUtils.MakeAssetKey(assetName, worldPos); if (!this.EnsureUniqueFX(text, assetName, worldPos)) { return; } Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["assetName"] = assetName; dictionary["coords"] = worldPos; dictionary["rotation"] = rotation; AssetHandle value = AssetHandle.Invalid; Service.Get <AssetManager>().Load(ref value, assetName, new AssetSuccessDelegate(this.OnFXWithPositionLoaded), null, dictionary); this.assetHandles.Add(text, value); }
public void RemoveAttachedFXFromEntity(Entity entity, string attachmentKey) { GameObjectViewComponent gameObjectViewComponent = null; if (entity != null) { gameObjectViewComponent = entity.Get <GameObjectViewComponent>(); } if (gameObjectViewComponent != null) { GameObject attachedGameObject = gameObjectViewComponent.GetAttachedGameObject(attachmentKey); if (attachedGameObject != null) { gameObjectViewComponent.DetachGameObject(attachmentKey); this.fxInstances.Remove(attachedGameObject); UnityEngine.Object.Destroy(attachedGameObject); } } string assetKey = FXUtils.MakeAssetKey(attachmentKey, entity); this.UnloadByAssetKey(assetKey); }
public void CreateDestructionFX(SmartEntity entity, bool isBuilding) { string debrisAssetNameForEntity = FXUtils.GetDebrisAssetNameForEntity(entity, isBuilding); if (debrisAssetNameForEntity != null) { GameObjectViewComponent gameObjectViewComp = entity.GameObjectViewComp; if (gameObjectViewComp == null) { return; } Vector3 position = gameObjectViewComp.MainTransform.position; Vector3 vector = new Vector3(position.x, 0f, position.z); if (!isBuilding) { GameObject centerOfMass = gameObjectViewComp.CenterOfMass; if (centerOfMass != null) { Vector3 position2 = centerOfMass.transform.position; vector = new Vector3(position2.x, position2.y, position2.z); } } string text = FXUtils.MakeAssetKey(debrisAssetNameForEntity, vector); if (!this.EnsureUniqueFX(text, debrisAssetNameForEntity, vector)) { return; } Dictionary <string, object> dictionary = new Dictionary <string, object>(); dictionary["assetName"] = debrisAssetNameForEntity; dictionary["coords"] = vector; dictionary["assetKey"] = text; AssetHandle value = AssetHandle.Invalid; Service.Get <AssetManager>().Load(ref value, debrisAssetNameForEntity, new AssetSuccessDelegate(this.OnDestructionFXLoaded), null, dictionary); this.assetHandles.Add(text, value); } }