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); }
private void OnAttachedFXLoaded(object asset, object cookie) { Dictionary <string, object> dictionary = (Dictionary <string, object>)cookie; string assetName = (string)dictionary["assetName"]; SmartEntity smartEntity = (SmartEntity)dictionary["entity"]; if (smartEntity == null || smartEntity.GameObjectViewComp == null) { if (Service.Get <AssetManager>().IsAssetCloned(assetName)) { UnityEngine.Object.Destroy(asset as GameObject); } string assetKey = (string)dictionary["assetKey"]; this.UnloadByAssetKey(assetKey); return; } string key = (string)dictionary["attachmentKey"]; bool pinToCenterOfMass = (bool)dictionary["centerOfMass"]; bool flag = (bool)dictionary["rotation"]; Vector3 offset = (Vector3)dictionary["coords"]; GameObject gameObject = this.InitFXInstanceOnLoad(asset, assetName); if (gameObject != null) { GameObjectViewComponent gameObjectViewComp = smartEntity.GameObjectViewComp; gameObjectViewComp.AttachGameObject(key, gameObject, offset, false, pinToCenterOfMass); if (flag) { gameObject.transform.rotation = gameObjectViewComp.MainTransform.rotation; } } FXManager.AttachedFXLoadedCallback attachedFXLoadedCallback = (FXManager.AttachedFXLoadedCallback)dictionary["callback"]; if (attachedFXLoadedCallback != null) { float value = 0f; if (dictionary.ContainsKey("value")) { value = (float)dictionary["value"]; } attachedFXLoadedCallback(gameObject, smartEntity, value); } }