Esempio n. 1
0
        public void SetResolver <InterfaceT>(string resolverName, ResolveDelegate <InterfaceT> resolveDelgate, out int statu, bool onlyOnce = false, bool isMakeResolver = false)
        {
            statu = 0;
            ResolverHandler <InterfaceT> handler;
            bool hasRef = mResolverIDMapper.ContainsKey(ref resolverName, out int id);

            if (hasRef)
            {
                statu = 1;
                if (isMakeResolver)
                {
                    handler = mResolvers[id] as ResolverHandler <InterfaceT>;
                    handler.AddDelegate(resolveDelgate);
                }
            }
            else
            {
                if (isMakeResolver)
                {
                    statu = 2;
                    return;
                }
                id      = mResolverIDMapper.Add(resolverName, out _);
                handler = new ResolverHandler <InterfaceT>();
                handler.SetDelegate(resolveDelgate);
                handler.OnlyOnce = onlyOnce;
                handler.SetID(id);
                mResolvers[id] = handler;
            }
        }
Esempio n. 2
0
        public virtual int SetEntitas(IShipDockEntitas target)
        {
            int id = mEntitas.Add(target, out int statu);

            if (statu == 0)
            {
                mEntitasIDs.Add(id);
            }
            return(id);
        }
Esempio n. 3
0
 public void CheckAndCacheType(ref Type target, out int id)
 {
     if (mTypeMapper == default)
     {
         id = -1;
     }
     else
     {
         id = mTypeMapper.Add(target, out _);
     }
 }
Esempio n. 4
0
        public virtual int SetEntitas(IShipDockEntitas target)
        {
            int aid = mEntitas.Add(target, out int statu);

            if (statu == 0)
            {
                mEntitasIDs.Add(aid);
                OnEntitasStretch?.Invoke(target, false);
            }
            return(aid);
        }
Esempio n. 5
0
        private void AddComponentToMapper <T>(int name, ref T target, out int autoID) where T : IShipDockComponent, new()
        {
            autoID = mMapper.Add(target, out int statu);
            if (statu == 0)
            {
                mNameAutoIDMapper[name] = autoID;

                target.SetComponentID(autoID);
                target.Init(this);
                RelateComponentsReFiller?.Invoke(name, target, this);

                "log: Add ECS component {0}".Log(name.ToString());
            }
            else
            {
                autoID = -1;
            }
        }
Esempio n. 6
0
        public void AddResolvableConfig(params IResolvableConfig[] args)
        {
            IResolvableConfig confItem;
            int id, statu;
            int max = args.Length;

            for (int i = 0; i < max; i++)
            {
                confItem = args[i];
                id       = mResolvableNameMapper.Add(confItem.Alias, out statu);
                if (statu == 0)
                {
                    if ((confItem != default) && !mResolvableConfigs.IsContainsKey(id))
                    {
                        confItem.Create(this);
                        mResolvableConfigs[id] = confItem;
                    }
                    else
                    {
                        statu = 1;
                    }
                }
        public int Create <T>(int name, bool isUpdateByScene = false, params int[] willRelateComponents) where T : IShipDockComponent, new()
        {
            T target = new T
            {
                RelateComponents = willRelateComponents
            };

            target.SetSceneUpdate(isUpdateByScene);
            target.OnFinalUpdateForTime    = OnFinalUpdateForTime;
            target.OnFinalUpdateForEntitas = OnFinalUpdateForEntitas;
            target.OnFinalUpdateForExecute = OnFinalUpdateForExecute;

            int aid = mMapper.Add(target, out int statu);

            if (isUpdateByScene)
            {
                mUpdateByScene.Add(target);
            }
            else
            {
                mUpdateByTicks.Add(target);
            }

            if (statu == 0)
            {
                mIDMapper[name] = aid;

                target.SetComponentID(aid);
                target.FillRelateComponents(this);
                target.Init();
                RelateComponentsReFiller?.Invoke(name, target, this);
            }
            else
            {
                aid = -1;
            }
            return(aid);
        }