public static EntityReturner CreateStairs(int xp, int yp, bool isUp) { List <Components.Component> compList = new List <Components.Component>(); // set bitwise to 0 int checker = 0; Components.PositionComp positionComp = new Components.PositionComp(xp, yp); compList.Add(positionComp); checker = checker | (int)Core.ComponentTypes.Position; char c = isUp ? '<' : '>'; Components.RenderComp rendComp = new Components.RenderComp(c, RLNET.RLColor.White); compList.Add(rendComp); checker = checker | (int)Core.ComponentTypes.Render; Components.StairComp stairComp = new Components.StairComp(isUp); compList.Add(stairComp); checker = checker | (int)Core.ComponentTypes.Stairs; Components.UseableComp useComp = new Components.UseableComp(); compList.Add(useComp); checker = checker | (int)Core.ComponentTypes.Useable; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public void OnMessage(Core.MessageEventArgs e) { switch (e.MessageType) { case Core.EventTypes.Use: Core.UseEventArgs args = (Core.UseEventArgs)e; // position based? if (args.PositionBased) { Core.Entity entityUsing = args.EntityUsing; Components.PositionComp posComp = (Components.PositionComp)_entManager.GetSingleComponentByID(entityUsing.UID, Core.ComponentTypes.Position); int xPos = posComp.X; int yPos = posComp.Y; string posLU = xPos.ToString() + "-" + yPos.ToString(); if (_entManager.EntityPostionLookUp.TryGetValue(posLU, out List <Core.Entity> entry)) { foreach (Core.Entity li in entry) { int useableLU = (int)Core.ComponentTypes.Useable; int stairsLU = (int)Core.ComponentTypes.Stairs; int entBit = _entManager.EntityBitLookUp[li.UID]; if ((useableLU & entBit) > 0) { // is it a stair? if ((entBit & stairsLU) > 0) { // yay! it's a stair.... Components.StairComp stairComp = (Components.StairComp)_entManager.GetSingleComponentByID(li.UID, Core.ComponentTypes.Stairs); if (stairComp.isUp) { // go up } else { //go down } } } } } } else { // non position based, use inventory } break; } }