コード例 #1
0
    public void Alloc(KEY type, int capacity, CreateFunction create, ResetFunction reset = null, DestroyFunction destroy = null)
    {
        Debug.Assert(capacity > 0);
        Debug.Assert(create != null);

        SubPool subPool;

        if (m_pool.TryGetValue(type, out subPool))
        {
            if (capacity > subPool.pool.Count)
            {
                subPool.capacity = capacity;
            }
            //Debug.AssertFormat(create == null && reset == null, "create and reset function are always ignored when realloc the subpool");
            capacity -= subPool.pool.Count;
        }
        else
        {
            subPool          = new SubPool();
            subPool.pool     = new Stack <object>();
            subPool.capacity = capacity;
            subPool.create   = create;
            subPool.reset    = reset;
            subPool.destroy  = destroy;
            m_pool.Add(type, subPool);
        }

        AllocSubPool(subPool, type, capacity);
    }
コード例 #2
0
ファイル: ObjectPoolAssistant.cs プロジェクト: ezequias2d/Ez
 /// <summary>
 /// Initializes a new instance of <see cref="ObjectPoolAssistant{T, TSpecs}"/> thats wraps a create function and evaluate function.
 /// </summary>
 /// <param name="create">The create function of a T item.</param>
 /// <param name="evaluate">The evaluate function of a T item.</param>
 /// <param name="clearCount">The number of elements counted for <see cref="IsClear"/> returns <see langword="false"/>.</param>
 public ObjectPoolAssistant(CreateFunction create, EvaluateFunction evaluate, uint clearCount = 32)
 {
     _create     = create ?? throw new ArgumentNullException(nameof(create));
     _evaluate   = evaluate;
     _clearCount = clearCount;
     _count      = _clearCount;
 }
コード例 #3
0
 public void Alloc(GameObject prefab, int capacity, CreateFunction create, ResetFunction reset = null, DestroyFunction destroy = null)
 {
     BaseObjectPool <GameObject> .CreateFunction baseCreate = delegate(GameObject type) {
         return(create(type));
     };
     BaseObjectPool <GameObject> .ResetFunction baseReset;
     if (reset != null)
     {
         baseReset = delegate(object obj) {
             reset((GameObject)obj);
         };
     }
     else
     {
         baseReset = null;
     }
     BaseObjectPool <GameObject> .DestroyFunction baseDestroy;
     if (destroy != null)
     {
         baseDestroy = delegate(object obj) {
             destroy((GameObject)obj);
         };
     }
     else
     {
         baseDestroy = null;
     }
     Alloc(prefab, capacity, baseCreate, baseReset, baseDestroy);
 }
コード例 #4
0
    public void Alloc <TYPE>(int capacity, CreateFunction <TYPE> create, ResetFunction <TYPE> reset = null, DestroyFunction <TYPE> destroy = null)
        where TYPE : new()
    {
        CreateFunction baseCreate = delegate(System.Type type) {
            return(create());
        };
        ResetFunction baseReset;

        if (reset != null)
        {
            baseReset = delegate(object obj) {
                reset((TYPE)obj);
            };
        }
        else
        {
            baseReset = null;
        }
        DestroyFunction baseDestroy;

        if (destroy != null)
        {
            baseDestroy = delegate(object obj) {
                destroy((TYPE)obj);
            };
        }
        else
        {
            baseDestroy = null;
        }
        Alloc(typeof(TYPE), capacity, baseCreate, baseReset, baseDestroy);
    }
コード例 #5
0
 public void Alloc(int capacity, CreateFunction create, ResetFunction reset = null, DestroyFunction destroy = null)
 {
     BaseObjectPool <System.Type> .CreateFunction baseCreate = delegate(System.Type type) {
         return(create());
     };
     BaseObjectPool <System.Type> .ResetFunction baseReset;
     if (reset != null)
     {
         baseReset = delegate(object obj) {
             reset((TYPE)obj);
         };
     }
     else
     {
         baseReset = null;
     }
     BaseObjectPool <System.Type> .DestroyFunction baseDestroy;
     if (destroy != null)
     {
         baseDestroy = delegate(object obj) {
             destroy((TYPE)obj);
         };
     }
     else
     {
         baseDestroy = null;
     }
     Alloc(typeof(TYPE), capacity, baseCreate, baseReset, baseDestroy);
     m_subPool = m_pool[typeof(TYPE)];
 }
コード例 #6
0
        public CreateFunction GenerateCreateFunctionStatement(Function f)
        {
            CreateFunction cf = new CreateFunction();

            cf.Function = f;
            return(cf);
        }
コード例 #7
0
ファイル: MessageEvent.cs プロジェクト: IAmUser4574/ROS.NET
 public virtual void _init(IRosMessage msg, IDictionary connhead, TimeData rec, bool needcopy, CreateFunction c)
 {
     message            = msg;
     connection_header  = connhead;
     receipt_time       = rec;
     nonconst_need_copy = needcopy;
     create             = c;
 }
コード例 #8
0
ファイル: MessageEvent.cs プロジェクト: IAmUser4574/ROS.NET
 public IMessageEvent(IMessageEvent rhs)
 {
     message            = rhs.message;
     connection_header  = rhs.connection_header;
     receipt_time       = rhs.receipt_time;
     nonconst_need_copy = rhs.nonconst_need_copy;
     create             = rhs.create;
 }
コード例 #9
0
        public string GenerateCreateFunctionScript(CreateFunction CreateFunction)
        {
            string Tmp =
                "drop function dbo." + CreateFunction.Function.Name + Environment.NewLine;

            Tmp += CreateFunction.Function.Body;

            return(Tmp);
        }
コード例 #10
0
ファイル: FunctionParser.cs プロジェクト: toddcoder/Orange
        Verb createInitializer(int index, Block block)
        {
            overridePosition = index;
            var region = getRegion();

            lambda = new Lambda(region, block, parameters, false)
            {
                Initializer = true
            };
            var builder = new CodeBuilder();
            var verb    = new CreateFunction(functionName, lambda, false, Public, true, null)
            {
                Index = statementIndex
            };

            builder.Verb(verb);
            AddStaticBlock(builder.Block);
            return(new NullOp());
        }
コード例 #11
0
        /// <summary>
        /// 새 파티클 시스템을 생성합니다.
        /// </summary>
        public ParticleSystem(float startPosX, float startPosY, float velocityX, float velocityY, int lifetime,
                              int createNumber, float createRange, CreateFunction createFunction,
                              Particle.Type particleType, Color particleColor, float particleSize, int particleLifetime)
        {
            //Random r = new Random();
            this.positionX = startPosX;//(float)r.NextDouble() * (maxPosX - minPosX) + minPosX;
            this.positionY = startPosY;
            this.velocityX = velocityX;
            this.velocityY = velocityY;
            this.lifetime  = lifetime;

            this.createNumber   = createNumber;
            this.createRange    = createRange;
            this.createFunction = createFunction;

            this.particleType     = particleType;
            this.particleColor    = particleColor;
            this.particleSize     = particleSize;
            this.particleLifetime = particleLifetime;

            this.isBasicParticleSystem = false;
        }
コード例 #12
0
        /// <summary>
        /// 테마에 맞는 기본 파티클 시스템을 생성합니다.
        /// 기본 파티클 시스템은 테마가 바뀔 때까지 사라지지 않고, 키보드 입력에 따라 파티클을 생성합니다.
        /// </summary>
        public ParticleSystem(
            int createNumber, float createRange, CreateFunction createFunction,
            Particle.Type particleType, Color particleColor, float particleSize, int particleLifetime)
        {
            //Random r = new Random();
            this.positionX = 0;
            this.positionY = 0;
            this.velocityX = 0;
            this.velocityY = 0;
            this.lifetime  = -1;

            this.createNumber   = createNumber;
            this.createRange    = createRange;
            this.createFunction = createFunction;

            this.particleType     = particleType;
            this.particleColor    = particleColor;
            this.particleSize     = particleSize;
            this.particleLifetime = particleLifetime;

            this.isBasicParticleSystem = true;
        }
コード例 #13
0
        static void Main(string[] args)
        {
            string ActionType  = null;
            string MenuControl = null;
            string ChooseTable = null;

            SQLiteConnection sqlite_conn_strength;
            SQLiteConnection sqlite_conn_cardio;
            SQLiteConnection sqlite_conn_balance;

            FitnessAppFYPLAB.CreateFunction     SynthesizeTables  = new CreateFunction();
            FitnessAppFYPLAB.StrengthInsertRead StrengthFunctions = new StrengthInsertRead();
            FitnessAppFYPLAB.CardioInsertRead   CardioFunctions   = new CardioInsertRead();
            FitnessAppFYPLAB.BalanceInsertRead  BalanceFunctions  = new BalanceInsertRead();
            //SynthesizeTables.CreateTable(sqlite_conn_balance);



            while (true)
            {
                sqlite_conn_strength = new SQLiteConnection("Data Source=StrengthDB.db; Version = 3; New = True; Compress = True; ");
                sqlite_conn_strength.Open();


                sqlite_conn_cardio = new SQLiteConnection("Data Source=CardioDB.db; Version = 3; New = True; Compress = True; ");
                sqlite_conn_cardio.Open();


                sqlite_conn_balance = new SQLiteConnection("Data Source=BalanceDB.db; Version = 3; New = True; Compress = True; ");
                sqlite_conn_balance.Open();


                int Choice1 = 0;
                int Choice2 = 0;
                int Choice3 = 0;
                int Choice4 = 0;

                do //Menu to ask actions user wants to do
                {
                    Console.Write("\n\n\n\n\n\n\n\nWhat do you want to do? Insert or see data related to a workout? Please enter words: INSERT or SEE or DELETE.");
                    ActionType = Console.ReadLine();
                    ActionType = ActionType.ToLower();
                } while (ActionType != "insert" && ActionType != "see" && ActionType != "delete");


                //Menu to determine which workout user wants to choose
                Menu(ref Choice1, ref Choice2, ref Choice3, ref Choice4);



                if (ActionType == "insert")
                {
                    InsertValues(StrengthFunctions, CardioFunctions, BalanceFunctions, SynthesizeTables, sqlite_conn_strength, sqlite_conn_cardio, sqlite_conn_balance, ref ChooseTable, ref Choice1, ref Choice2, ref Choice3, ref Choice4);
                }

                if (ActionType == "see")
                {
                    SeeFunction(StrengthFunctions, CardioFunctions, BalanceFunctions, SynthesizeTables, sqlite_conn_strength, sqlite_conn_cardio, sqlite_conn_balance, ref ChooseTable, ref Choice1, ref Choice2, ref Choice3, ref Choice4);
                }



                if (ActionType == "delete")
                {
                    DeleteFunction(StrengthFunctions, CardioFunctions, BalanceFunctions, SynthesizeTables, sqlite_conn_strength, sqlite_conn_cardio, sqlite_conn_balance, ref ChooseTable, ref Choice1, ref Choice2, ref Choice3, ref Choice4);
                }//end of delete



                do //Menu to ask whether user wants to continue
                {
                    Console.Write("\n\n\n\n\n\n\n\n\n\nDo you still want to continue (Enter YES or NO)?");

                    MenuControl = Console.ReadLine();
                    MenuControl = MenuControl.ToLower();
                } while (MenuControl != "yes" && MenuControl != "no");

                if (MenuControl == "no")
                {
                    break;
                }


                sqlite_conn_strength.Close();
                sqlite_conn_cardio.Close();
                sqlite_conn_balance.Close();
            }
        }
コード例 #14
0
ファイル: MessageEvent.cs プロジェクト: IAmUser4574/ROS.NET
 public MessageEvent(MessageEvent <M> rhs, CreateFunction c)
     : base(rhs, c)
 {
     speccreate = () => (M)c();
 }
コード例 #15
0
 void Awake()
 {
     _instance     = this;
     allGameobject = new List <GameObject>();
     GameManager   = GameObject.Find("GameobjectPool").GetComponent <Transform>();
 }
コード例 #16
0
ファイル: MessageEvent.cs プロジェクト: IAmUser4574/ROS.NET
 public IMessageEvent(IRosMessage msg, IDictionary conhead, TimeData rectime, bool needcopy, CreateFunction c)
 {
     _init(msg, conhead, rectime, needcopy, c);
 }
コード例 #17
0
ファイル: MessageEvent.cs プロジェクト: IAmUser4574/ROS.NET
 public IMessageEvent(IMessageEvent rhs, CreateFunction c)
     : this(rhs.message, rhs.connection_header, rhs.receipt_time, rhs.nonconst_need_copy, c)
 {
 }