public void AddWeaponToEntity(int eid) { Core.Entity e = new Core.Entity(_entityID); Core.EntityReturner er; int weaponID = e.UID; Components.CreatureDetailsComp cdc = (Components.CreatureDetailsComp)GetSingleComponentByID(eid, Core.ComponentTypes.CreatureDetails); if (cdc.CreatureType != Types.CreatureTypes.Troll) { er = Core.EntityFactory.CreateSword(); } else { er = Core.EntityFactory.CreateTrollClub(); } Entities.Add(_entityID, er.ComponentList); EntityBitLookUp.Add(_entityID, er.LookUpBit); JustEntities.Add(_entityID, e); _entityID++; // add weapon to entity Core.InventoryAddEventArgs addEvent = new Core.InventoryAddEventArgs(Core.EventTypes.InventoryAdd, eid, weaponID); Core.EventBus.Publish(Core.EventTypes.InventoryAdd, addEvent); }
public void LoadEntities() { Systems.LoadSystem loadSys = new Systems.LoadSystem(); Entities.Clear(); Entities = loadSys.LoadEntities(); if (Entities.Count > 0) { Game.MessageLog.Add("YAY!"); EntityBitLookUp.Clear(); foreach (KeyValuePair <int, List <Components.Component> > entry in Entities) { List <Components.Component> compList = entry.Value; int eid = entry.Key; int checker = 0; foreach (Components.Component c in compList) { Core.ComponentTypes ct = c.CompType; checker = checker | (int)ct; } EntityBitLookUp.Add(eid, checker); } // reset max entityID counter List <int> idList = new List <int>(Entities.Keys); int maxID = idList.Max(); _entityID = maxID + 1; } }
public void AddMonster(int x, int y, Core.DungeonMap m) { Core.Entity e = new Core.Entity(_entityID); Core.EntityReturner er; //int ind = r.Next(CreatNames.Count); int ind = Game.Random.Next(CreatNames.Count - 1); string creatureName = CreatNames[ind]; int entType = RogueSharp.DiceNotation.Dice.Roll("1d20"); if (entType <= 2) { er = Core.EntityFactory.CreateTroll(x, y, creatureName, m); } else if (entType > 2 && entType < 6) { er = Core.EntityFactory.CreateOrc(x, y, creatureName, m); } else if (entType >= 6 && entType < 12) { er = Core.EntityFactory.CreateKobold(x, y, creatureName, m); } else if (entType >= 12 && entType < 15) { er = Core.EntityFactory.CreateZombie(x, y, creatureName, m); } else { er = Core.EntityFactory.CreateRat(x, y, creatureName, m); } //add entity to entity dict Entities.Add(_entityID, er.ComponentList); EntityBitLookUp.Add(_entityID, er.LookUpBit); JustEntities.Add(_entityID, e); //add to PositionLookUp AddEntToPosition(x, y, e.UID); //try adding to schedule Components.Component ts = GetSingleComponentByID(_entityID, Core.ComponentTypes.Schedulable); if (ts != null) { Components.SchedulableComp sc = (Components.SchedulableComp)ts; int entTime = sc.Time; Game.ShedSystem.Add(e, entTime); } // inc entityID _entityID++; //add weapon to entity AddWeaponToEntity(e.UID); if (RogueSharp.DiceNotation.Dice.Roll("1d10") > 8) { AddPotionToEntity(e.UID); } }
public void AddDoor(int x, int y, bool isOpen) { var e = new Core.Entity(_entityID); Core.EntityReturner er = Core.EntityFactory.CreateDoor(x, y, isOpen); //add entity to entity dict Entities.Add(_entityID, er.ComponentList); EntityBitLookUp.Add(_entityID, er.LookUpBit); JustEntities.Add(_entityID, e); //add to PositionLookUp AddEntToPosition(x, y, e.UID); // inc entityID _entityID++; }
public void AddTreasure(int x, int y) { var e = new Core.Entity(_entityID); // List<Components.Component> compList = new List<Components.Component>(); Core.EntityReturner er = Core.EntityFactory.CreateGold(x, y, r.Next()); //add entity to entity dic Entities.Add(_entityID, er.ComponentList); EntityBitLookUp.Add(_entityID, er.LookUpBit); JustEntities.Add(_entityID, e); AddEntToPosition(x, y, e.UID); // inc entityID _entityID++; }
public void AddStairs(int x, int y, bool isUp) { var e = new Core.Entity(_entityID); // List<Components.Component> compList = new List<Components.Component>(); Core.EntityReturner er = Core.EntityFactory.CreateStairs(x, y, isUp); //add entity to entity dict Entities.Add(_entityID, er.ComponentList); EntityBitLookUp.Add(_entityID, er.LookUpBit); JustEntities.Add(_entityID, e); //add to PositionLookUp AddEntToPosition(x, y, e.UID); // inc entityID _entityID++; }
public void AddPotionToEntity(int eid) { Core.Entity e = new Core.Entity(_entityID); Core.EntityReturner er; int potionID = e.UID; er = Core.EntityFactory.CreateHealthPotion(); Entities.Add(_entityID, er.ComponentList); EntityBitLookUp.Add(_entityID, er.LookUpBit); JustEntities.Add(_entityID, e); _entityID++; // add potion to entity Core.InventoryAddEventArgs addEvent = new Core.InventoryAddEventArgs(Core.EventTypes.InventoryAdd, eid, potionID); Core.EventBus.Publish(Core.EventTypes.InventoryAdd, addEvent); }