Beispiel #1
0
            public static void SetHidden(CreatureBoardAsset creatureBoardAsset, bool hidden)
            {
                //Log.Debug($"SetHidden - hidden: {hidden}");
                IOldPersistentEffect persistentEffect = creatureBoardAsset.GetPersistentEffect();

                if (persistentEffect == null)
                {
                    Log.Error($"persistentEffect == null");
                    return;
                }

                persistentEffect.Hidden = hidden;
                CreatureManager.SetCreatureExplicitHideState(creatureBoardAsset.Creature.CreatureId, hidden);

                // Hide or show adornments:
                GameObject effectOrb = GetEffectOrb(creatureBoardAsset);

                foreach (string key in persistentEffect.Indicators.Keys)
                {
                    bool indicatorVisible = persistentEffect.Indicators[key];
                    bool shouldBeVisible  = !hidden && indicatorVisible;
                    SetOrbIndicatorVisible(effectOrb, shouldBeVisible, key);
                }

                if (persistentEffect is SuperPersistentEffect superPersistentEffect && superPersistentEffect.VisibilityMatchesBase)
                {
                    GameObject attachedParentGameObject = creatureBoardAsset.GetAttachedParentGameObject();
                    if (attachedParentGameObject != null)
                    {
                        attachedParentGameObject.SetActive(!hidden);
                    }
                    else
                    {
                        Log.Error($"Unable to find attached parent game object! Cannot hide this control!");
                    }
                }

                creatureBoardAsset.SavePersistentEffect(persistentEffect);
            }
Beispiel #2
0
            // TODO: Refactor this. Hard to read.
            internal static bool InitializeMiniFromPersistentEffect(CreatureBoardAsset creatureAsset, IOldPersistentEffect persistentEffect, string newCreatureName)
            {
                //Log.Indent();
                try
                {
                    GameObject assetLoader = creatureAsset.GetAssetLoader();
                    //Log.Warning($"creatureAsset.Creature.Name = \"{creatureAsset.Creature.Name}\"");
                    if (assetLoader != null)
                    {
                        GameObject goatClone = assetLoader.FindChild(STR_UninitializedMiniMeshName);
                        if (goatClone != null)
                        {
                            MeshFilter   meshFilter   = goatClone.GetComponent <MeshFilter>();
                            MeshRenderer meshRenderer = goatClone.GetComponent <MeshRenderer>();
                            if (meshFilter != null && meshRenderer != null)
                            {
                                PositionOrb(goatClone);

                                ReplaceMaterial(meshFilter, meshRenderer);

                                if (persistentEffect == null)
                                {
                                    persistentEffect = creatureAsset.GetPersistentEffect();
                                    if (persistentEffect == null)
                                    {
                                        Log.Error($"persistentEffect is null! Creating Waterfall!");
                                        persistentEffect = new OldPersistentEffect()
                                        {
                                            EffectName = "R1.WaterWallSegment1"
                                        };
                                    }
                                }

                                InitializeNewlyCreatedPersistentEffect(creatureAsset, persistentEffect, newCreatureName);

                                updatedCreatures.Add(creatureAsset.CreatureId.ToString());

                                Log.Debug($"returning true");
                                return(true);
                            }
                            else
                            {
                                Log.Debug($"Mesh Filter or Mesh Renderer not found in this update cycle...");
                            }
                        }
                        else
                        {
                            if (assetLoader.FindChild(STR_EffectOrb) != null)
                            {
                                //if (effectsToInitialize.Count > 0)
                                //	Log.Warning($"effectsToInitialize.Count = {effectsToInitialize.Count}");
                                //if (updatedCreatures.Count > 0)
                                //	Log.Warning($"updatedCreatures.Count = {updatedCreatures.Count}");

                                //Log.Warning($"Already initialized. Adding {creatureAsset.CreatureId.ToString()} to updatedCreatures");

                                persistentEffect = creatureAsset.GetPersistentEffect();
                                GameObject effectOrb    = GetEffectOrb(creatureAsset);
                                GameObject attachedNode = creatureAsset.GetAttachedParentGameObject();
                                if (attachedNode != null)
                                {
                                    persistentEffectEventArgs.Set(creatureAsset, assetLoader, effectOrb, attachedNode, persistentEffect);
                                    OnPersistentEffectInitialized(creatureAsset, persistentEffectEventArgs);
                                }
                                else
                                {
                                    Log.Error($"attachedNode is null!!!");
                                }

                                updatedCreatures.Add(creatureAsset.CreatureId.ToString());
                            }
                            else
                            {
                                Log.Debug($"goatClone not found in this update cycle...");
                            }
                        }
                    }
                    else
                    {
                        Log.Debug($"Asset Loader not found in this update cycle...");
                    }
                    //Log.Debug($"returning false");
                    return(false);
                }
                finally
                {
                    //Log.Unindent();
                }
            }