public static EntityReturner CreateTrollClub() { List <Components.Component> compList = new List <Components.Component>(); // set bitwise to 0 int checker = 0; Components.WeaponComp weapComp = new Components.WeaponComp("2d6", Types.WeaponDmgTypes.Crushing, false, "Club", 12); compList.Add(weapComp); checker = checker | (int)ComponentTypes.Weapon; Components.UseableComp useComp = new Components.UseableComp(); compList.Add(useComp); checker = checker | (int)ComponentTypes.Useable; Components.CollectableComp colComp = new Components.CollectableComp(1, false, false, Types.ItemTypes.Weapon, true); compList.Add(colComp); checker = checker | (int)ComponentTypes.Collectable; Components.ItemValueComp valComp = new Components.ItemValueComp(RogueSharp.DiceNotation.Dice.Roll("1d3")); compList.Add(valComp); checker = checker | (int)ComponentTypes.ItemValue; Components.RenderComp rendComp = new Components.RenderComp('|', Swatch.DbMetal); compList.Add(rendComp); checker = checker | (int)ComponentTypes.Render; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public static EntityReturner CreateGold(int x, int y, int rndNum) { // set bitwise to 0 int checker = 0; List <Components.Component> compList = new List <Components.Component>(); Components.PositionComp positionComp = new Components.PositionComp(x, y); compList.Add(positionComp); checker = checker | (int)Core.ComponentTypes.Position; Components.RenderComp rendComp = new Components.RenderComp('$', RLNET.RLColor.Yellow); compList.Add(rendComp); checker = checker | (int)Core.ComponentTypes.Render; Components.ItemValueComp valComp = new Components.ItemValueComp(RogueSharp.DiceNotation.Dice.Roll("1d6")); compList.Add(valComp); checker = checker | (int)Core.ComponentTypes.ItemValue; Components.CollectableComp collComp = new Components.CollectableComp(1, true, true, Types.ItemTypes.Treasure, true); compList.Add(collComp); checker = checker | (int)Core.ComponentTypes.Collectable; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public static EntityReturner CreateHealthPotion() { List <Components.Component> compList = new List <Components.Component>(); // set bitwise to 0 int checker = 0; Components.PotionComp potComp = new Components.PotionComp(Types.PotionTypes.Health); compList.Add(potComp); checker = checker | (int)ComponentTypes.Potion; Components.UseableComp useComp = new Components.UseableComp(); compList.Add(useComp); checker = checker | (int)ComponentTypes.Useable; Components.RenderComp rendComp = new Components.RenderComp('!', RLNET.RLColor.Yellow); compList.Add(rendComp); checker = checker | (int)Core.ComponentTypes.Render; Components.ItemValueComp valComp = new Components.ItemValueComp(RogueSharp.DiceNotation.Dice.Roll("1d6")); compList.Add(valComp); checker = checker | (int)Core.ComponentTypes.ItemValue; Components.CollectableComp collComp = new Components.CollectableComp(1, false, false, Types.ItemTypes.Potion, true); compList.Add(collComp); checker = checker | (int)Core.ComponentTypes.Collectable; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public void OnMessage(Core.MessageEventArgs e) { switch (e.MessageType) { case Core.EventTypes.InventoryAdd: Core.InventoryAddEventArgs msg = (Core.InventoryAddEventArgs)e; int entPickingUp = msg.EntPickingUp; int pickedUpObj = msg.PickedUpObject; List <Components.Component> pickedUpObjComps = _entityManager.GetCompsByID(pickedUpObj); List <Components.Component> entComps = _entityManager.GetCompsByID(entPickingUp); Components.InventoryComp invComp = (Components.InventoryComp)_entityManager.GetSingleComponentByID(entPickingUp, Core.ComponentTypes.Inventory); if (invComp != null) { Components.PositionComp posComp = (Components.PositionComp)pickedUpObjComps.Find(x => x.CompType == Core.ComponentTypes.Position); Components.CollectableComp collectComp = (Components.CollectableComp)pickedUpObjComps.Find(x => x.CompType == Core.ComponentTypes.Collectable); Components.ItemValueComp vC = (Components.ItemValueComp)pickedUpObjComps.Find(x => x.CompType == Core.ComponentTypes.ItemValue); //Components.Component c = _entityManager.GetSingleComponentByID(collectComp.) bool hasValue = (vC != null); if (collectComp.Active) { //is it treasure? if (collectComp.Treasure) { //TODO stackable treasure if (vC != null) { invComp.ValueCarried += vC.ItemValue; } // remove position comps from picked up object _entityManager.RemoveCompFromEnt(pickedUpObj, Core.ComponentTypes.Position); collectComp.Active = false; _entityManager.RemoveEntFromPosition(posComp.X, posComp.Y, pickedUpObj); invComp.Treasure.Add(pickedUpObj); } else { // is it stackable? - not currently used //TODO stackable collectables if (collectComp.Stackable) { } else { Game.MessageLog.Add("picking up item"); // System.Threading.Thread.Sleep(1000); if (posComp != null) { _entityManager.RemoveEntFromPosition(posComp.X, posComp.Y, pickedUpObj); _entityManager.RemoveCompFromEnt(pickedUpObj, Core.ComponentTypes.Position); pickedUpObjComps.Remove(posComp); } invComp.Inventory.Add(pickedUpObj); } } } } break; } }
public void OnMessage(Core.MessageEventArgs e) { switch (e.MessageType) { case Core.EventTypes.DeleteEntity: Core.DeleteEntEventArgs msg = (Core.DeleteEntEventArgs)e; //_entsToDelete.Add(msg.entID); // set cell walkable List <Components.Component> compList = _entityManager.GetCompsByID(msg.entID); Components.PositionComp pc = (Components.PositionComp)compList.FirstOrDefault(x => x.CompType == Core.ComponentTypes.Position); _dungeonMap.SetIsWalkable(pc.X, pc.Y, true); _shedSystem.Remove(_entityManager.JustEntities[msg.entID]); _entityManager.RemoveEntity(msg.entID); break; case Core.EventTypes.DeadEntity: // leave corpse of entity Core.DeleteEntEventArgs dM = (Core.DeleteEntEventArgs)e; int entID = dM.entID; Components.PositionComp posC = (Components.PositionComp)_entityManager.GetSingleComponentByID(entID, Core.ComponentTypes.Position); _dungeonMap.SetIsWalkable(posC.X, posC.Y, true); Components.RenderComp rendC = (Components.RenderComp)_entityManager.GetSingleComponentByID(entID, Core.ComponentTypes.Render); rendC.Glyph = '%'; rendC.Colour = RLNET.RLColor.LightRed; Components.AttributesComp attC = (Components.AttributesComp)_entityManager.GetSingleComponentByID(entID, Core.ComponentTypes.Attributes); attC.Dead = true; Game.MessageLog.Add($"ENT IS DEAD YEAH: {attC.Dead} ----------------------------------------------------------------------------"); _shedSystem.Remove(_entityManager.JustEntities[entID]); _entityManager.RemoveCompFromEnt(entID, Core.ComponentTypes.Health); _entityManager.RemoveCompFromEnt(entID, Core.ComponentTypes.Actor); _entityManager.RemoveCompFromEnt(entID, Core.ComponentTypes.Schedulable); _entityManager.AddFurnitureToEnt(entID); _entityManager.AddDeadComp(entID); // drop inventory Components.InventoryComp invC = (Components.InventoryComp)_entityManager.GetSingleComponentByID(entID, Core.ComponentTypes.Inventory); if (invC != null) { foreach (int droppedID in invC.Inventory) { Components.CollectableComp cc = (Components.CollectableComp)_entityManager.GetSingleComponentByID(droppedID, Core.ComponentTypes.Collectable); // only drop treasure for the moment //TODO - drop other items apart from treasure if (cc.Treasure) { _entityManager.AddPositionToEnt(droppedID, posC.X, posC.Y); cc.Active = true; } } } break; } }