Esempio n. 1
0
 /// <summary>
 /// Gets the node for the given object ID or creates a new node for actors (with automatic linkage to the parent).
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <returns>The result node.</returns>
 public static SceneGraphNode GetNode(Guid id)
 {
     Nodes.TryGetValue(id, out SceneGraphNode result);
     if (result == null)
     {
         var actor = Object.TryFind <Actor>(ref id);
         if (actor != null)
         {
             result = BuildActorNode(actor);
             if (result != null && actor.HasParent)
             {
                 result.ParentNode = FindNode(actor.Parent.ID);
             }
         }
     }
     return(result);
 }
        /// <inheritdoc />
        public override void Update(float deltaTime)
        {
            base.Update(deltaTime);

            // Check if temporary asset need to be updated
            if (_tmpSceneAnimationIsDirty)
            {
                // Clear flag
                _tmpSceneAnimationIsDirty = false;

                // Update
                RefreshTempAsset();
            }

            // Check if need to load timeline
            if (_isWaitingForTimelineLoad && _asset.IsLoaded)
            {
                // Clear flag
                _isWaitingForTimelineLoad = false;

                // Load timeline data from the asset
                _timeline.Load(_asset);

                // Setup
                _timeline.Enabled = true;
                ClearEditedFlag();
            }

            // Try to reassign the player
            if (_timeline.Player == null && _cachedPlayerId != Guid.Empty)
            {
                var obj = Object.TryFind <SceneAnimationPlayer>(ref _cachedPlayerId);
                if (obj)
                {
                    _cachedPlayerId = Guid.Empty;
                    if (obj.Animation == OriginalAsset)
                    {
                        _timeline.Player = obj;
                    }
                }
            }
        }