Example #1
0
        public void Update(ComponentizedEntity entity, IGameContext gameContext, IUpdateContext updateContext)
        {
            if (!string.IsNullOrWhiteSpace(UserInterfaceAssetName))
            {
                if (_userInterfaceAssetRef == null ||
                    _userInterfaceControllerAsset != UserInterfaceAssetName)
                {
                    _userInterfaceAssetRef        = _assetManager.Get <UserInterfaceAsset>(UserInterfaceAssetName);
                    _userInterfaceControllerAsset = UserInterfaceAssetName;
                }

                if (_userInterfaceAssetRef.IsReady && _userInterfaceAssetRef.Asset != _userInterfaceAsset)
                {
                    if (_userInterfaceController != null)
                    {
                        _userInterfaceController.Enabled = false;
                    }

                    _userInterfaceAsset              = _userInterfaceAssetRef.Asset;
                    _userInterfaceController         = _userInterfaceFactory.CreateUserInterfaceController(_userInterfaceAsset);
                    _userInterfaceController.Enabled = true;

                    // Register behaviours.
                    foreach (var behaviour in _behaviourRegistration)
                    {
                        behaviour(_userInterfaceController);
                    }
                }
            }

            if (_userInterfaceController != null)
            {
                _userInterfaceController.Update(gameContext, updateContext);
            }
        }
Example #2
0
 public DefaultUserInterfaceController(IKernel kernel, IHierarchy hierarchy, INode node, UserInterfaceAsset userInterfaceAsset)
 {
     _kernel                          = kernel;
     _hierarchy                       = hierarchy;
     _node                            = node;
     _userInterfaceAsset              = userInterfaceAsset;
     _registeredBehaviours            = new Dictionary <string, Dictionary <UserInterfaceBehaviourEvent, UserInterfaceBehaviourHandler <object> > >();
     _containerBehaviours             = new Dictionary <object, string[]>();
     _availableFragments              = new Dictionary <string, XmlNode>();
     _firedCreatedEventsForContainers = new HashSet <IContainer>();
     _enabled                         = true;
 }