Example #1
0
    // I AM THE FACTORY!  Hate non-abstract factories.  *whine whine whine*.  This will actually just buffer requests and then create
    public Entity Create(ENT_TYPE type)
    {
        Entity created = null;

        if (allTehEntities[(int)type] == null)
        {
            allTehEntities[(int)type] = new List <Entity>();
        }
        if (activeMark[(int)type] < allTehEntities[(int)type].Count)  //There is an inactive... YAY!
        {
            created = allTehEntities[(int)type][activeMark[(int)type]];
            activeMark[(int)type]++;
            return(created);
        }
        created = Creators[(int)type]();

        if (created == null)
        {
            return(null);
        }
        if (cm != null)
        {
            created.Init(cm);
        }
        allTehEntities[(int)type].Add(created);
        activeMark[(int)type]++;
        return(created);
    }
Example #2
0
        public void BindToEntity(Base_Entity ent)
        {
            if (ent == null)
                return;

            mBoundEnt = ent;
            mBoundToEnt = true;

            if (ent.GetType() == typeof(player))
                mBoundType = ENT_TYPE.ENT_PLAYER;
            else
                mBoundType = ENT_TYPE.ENT_GENERIC;
        }
Example #3
0
    // I AM THE FACTORY!  Hate non-abstract factories.  *whine whine whine*.  This will actually just buffer requests and then create
    public Entity Create(ENT_TYPE type)
    {
        Entity created = null;
        if (allTehEntities[(int)type] == null)
            allTehEntities[(int)type] = new List<Entity>();
        if(activeMark[(int) type] < allTehEntities[(int) type].Count) //There is an inactive... YAY!
        {
            created = allTehEntities[(int)type][activeMark[(int)type]];
            activeMark[(int)type]++;
            return created;
        }
        created = Creators[(int)type]();

        if (created == null)
            return null;
        if(cm != null)
           created.Init(cm);
        allTehEntities[(int)type].Add(created);
        activeMark[(int)type]++;
        return created;
    }
Example #4
0
    public object Cast(Vector2 startPos, Vector2 dir, ENT_TYPE collisionType)
    {
        mStartPosition = startPos;
        mDirection = dir;
        mEndPosition = startPos + (dir * mFarZ); //Give us our farZ coord (startpoint + (direction * scalar))

        float lerpMult = 0;
        while (lerpMult < 1)
        {
            lerpMult += 0.01f;

            Vector2 lerpPos = (mEndPosition - mStartPosition) * lerpMult;

            switch (collisionType)
            {
                case ENT_TYPE.ENT_GEOM:
                    mCollided = TestGeom(lerpPos);
                    break;

                default:
                    mCollided = TestEntGeneric();
                    break;
            }
        }

        return null;
    }