public void SetUp() { _ef = new EntityFactory(); _em = new EntityManager(); _ef.Add("base", new Identifier("Item"), new Sprite("base", 1)); _ef.Add("item", new Identifier("Item"), new Sprite("item", 1)); _ef.Inherits("inherited", "base", new Sprite("inherited", 2)); _ef.Compile(); }
public static void Init(EntityFactory ef) { ef.Add("person", new Sprite("npc", Sprite.ActorLayer), new Identifier("npc"), new ControllerComponent(new DoNothing(), new AP(World.OneSecondInSpeed / 2)), new Creature(), BodyComponent.CreateHuman(50), new VisibleComponent(10), new ItemContainerComponent(), new ConditionHolder(new HumanNeedsEffect(), new CreatureEncumbranceEffect()), new EquipmentComponent(new List <string> { "Head", "Torso", "Arms", "Main Hand", "Off Hand", "Hands", "Legs", "Feet" }), new SightComponent(), new MeleeComponent(new MeleeComponent.Template { ActionDescription = "punch", ActionDescriptionPlural = "punches", Skill = "skill_unarmed", HitBonus = 0, Damage = Rand.Constant(-5), DamageType = Combat.DamageTypes["crush"], Penetration = 1, AttackSpeed = World.OneSecondInSpeed, APToReady = 1, Reach = 0, Strength = 1, Parry = 0, })); ef.Inherits("npc", "person", new ControllerComponent(new NPC(), new AP(World.OneSecondInSpeed / 2))); ef.Inherits("player", "person", new Sprite("player", Sprite.PlayerLayer), new Identifier("Player"), new ControllerComponent(new Player(), new AP(World.OneSecondInSpeed / 2))); }
public static void Init(EntityFactory ef) { ef.Add("base_item", new VisibleComponent(10), new Sprite("ITEM", Sprite.ItemsLayer), new Identifier("Junk", "A piece of junk."), new Item(0, 0, 0, 0, StackType.None)); InitMelees(ef); InitPistols(ef); InitAmmos(ef); InitArmors(ef); ef.Inherits("paperclip", "base_item", new Identifier("Paperclip", "A single paperclip."), new Lockpick(-World.StandardDeviation * 3 / 2)); ef.Inherits("lockpick", "base_item", new Identifier("Lockpick", "A basic lockpick."), new Lockpick(0)); }
public static void Init(EntityFactory ef) { Contract.Requires <ArgumentNullException>(ef != null, "ef"); ef.Add("feature", new VisibleComponent(10), new UseBroadcaster(), new Sprite("FEATURE", Sprite.FeaturesLayer), new Identifier("Feature"), new Scenery(false, false)); ef.Inherits("nonblockingfeature", "feature", new Scenery()); DoorsAndWindows(ef); #region House Features ef.Inherits("COUNTER_WOOD_RED", "feature", new Scenery(true, false, 1), new Sprite("COUNTER_WOOD_RED", Sprite.FeaturesLayer)); ef.Inherits("SINK", "feature", new Sprite("SINK", Sprite.FeaturesLayer), new Scenery(true, false, 1), new Identifier("Sink", "A sink.") ); ef.Inherits("TOILET", "nonblockingfeature", new Sprite("TOILET", Sprite.FeaturesLayer), new ApplianceComponent(new List <ApplianceComponent.Use> { ApplianceComponent.Use.UseAppliance("Use", "stat_bladder", new TimeSpan(0, 0, 1, 0), new TimeSpan(0, 0, 0, 1, 150), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} finishes using the {1}.", Identifier.GetNameOrId(e), Identifier.GetNameOrId(app.Entity)), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} is unable to use the {1}.", Identifier.GetNameOrId(e), Identifier.GetNameOrId(app.Entity))) })); ef.Inherits("BATHROOMSINK", "SINK", new Sprite("BATHROOMSINK", Sprite.FeaturesLayer), new ApplianceComponent(new List <ApplianceComponent.Use> { ApplianceComponent.Use.UseAppliance("Wash hands", "stat_cleanliness", new TimeSpan(0, 0, 0, 30), new TimeSpan(0, 0, 0, 3), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} finishes washing his hands.", Identifier.GetNameOrId(e)), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} is unable to use the {1}.", Identifier.GetNameOrId(e), Identifier.GetNameOrId(app.Entity))) })); ef.Inherits("BATH", "nonblockingfeature", new Sprite("BATH", Sprite.FeaturesLayer), new Scenery(true, false, -1), new ApplianceComponent(new List <ApplianceComponent.Use> { ApplianceComponent.Use.UseAppliance("Take a bath", "stat_cleanliness", new TimeSpan(0, 0, 30, 0), new TimeSpan(0, 0, 0, 30), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} finishes taking a bath.", Identifier.GetNameOrId(e)), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} is unable to use the {1}.", Identifier.GetNameOrId(e), Identifier.GetNameOrId(app.Entity))) }), new PassiveFeature(delegate(Entity entityNear, Entity featureEntity) { // if (Math.Abs(entityNear.Get<Location>().DistanceTo(featureEntity.Get<Location>()) - 0) < Double.Epsilon) // World.Instance.Log.Normal(String.Format("{0} steps into the bathtub.", Identifier.GetNameOrId(entityNear))); })); ef.Inherits("SHOWER", "nonblockingfeature", new Sprite("SHOWER", Sprite.FeaturesLayer)); ef.Inherits("CHAIR_WOODEN", "nonblockingfeature", new Scenery(true, false, 1), new Sprite("CHAIR_WOODEN", Sprite.FeaturesLayer)); ef.Inherits("TREE_SMALL", "nonblockingfeature", new Sprite("TREE_SMALL", Sprite.FeaturesLayer)); ef.Inherits("BED_WOODEN", "nonblockingfeature", new Sprite("BED_WOODEN", Sprite.FeaturesLayer), new ApplianceComponent(new List <ApplianceComponent.Use> { ApplianceComponent.Use.UseAppliance("Sleep", "stat_energy", new TimeSpan(0, 8, 0, 0), new TimeSpan(0, 0, 5, 0), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} finishes sleeping.", Identifier.GetNameOrId(e)), (e, app) => e.Get <GameObject>().Level.World.Log.NormalFormat("{0} is unable to use the {1}.", Identifier.GetNameOrId(e), Identifier.GetNameOrId(app.Entity))) }), new PassiveFeature(delegate(Entity entityNear, Entity featureEntity) { // if (Math.Abs(entityNear.Get<Location>().DistanceTo(featureEntity.Get<Location>()) - 0) < Double.Epsilon) // World.Instance.Log.Normal(String.Format("{0} jumps on the bed.", Identifier.GetNameOrId(entityNear))); })); ef.Inherits("SHELF_WOOD", "feature", new Scenery(true, false, 2), new Sprite("SHELF_WOOD", Sprite.FeaturesLayer)); ef.Inherits("SHELF_METAL", "feature", new Sprite("SHELF_METAL", Sprite.FeaturesLayer)); ef.Inherits("TELEVISION", "feature", new Sprite("TELEVISION", Sprite.FeaturesLayer), new PassiveFeature(delegate(Entity entityNear, Entity featureEntity) { // if (entityNear.Get<Location>().DistanceTo(featureEntity.Get<Location>()) < 5) // World.Instance.Log.Normal(String.Format("{0} hears the sound of television.", // Identifier.GetNameOrId(entityNear))); })); ef.Inherits("FRIDGE", "feature", new Sprite("FRIDGE", Sprite.FeaturesLayer)); ef.Inherits("DESK_WOODEN", "feature", new Scenery(true, false, 1), new Sprite("DESK_WOODEN", Sprite.FeaturesLayer)); ef.Inherits("CASH_REGISTER", "feature", new Sprite("CASH_REGISTER", Sprite.FeaturesLayer)); ef.Inherits("SOFA", "nonblockingfeature", new Sprite("SOFA", Sprite.FeaturesLayer), new PassiveFeature(delegate(Entity entityNear, Entity featureEntity) { // if (Math.Abs(entityNear.Get<Location>().DistanceTo(featureEntity.Get<Location>()) - 0) < Double.Epsilon) // World.Instance.Log.Normal(String.Format("{0} jumps on the sofa. Whee!!", Identifier.GetNameOrId(entityNear))); })); ef.Inherits("OVEN", "feature", new Sprite("OVEN", Sprite.FeaturesLayer)); ef.Inherits("DOOR_GARAGE", "feature", new Sprite("DOOR_GARAGE", Sprite.FeaturesLayer)); ef.Inherits("FENCE_WOODEN", "feature", new Sprite("FENCE_WOODEN", Sprite.FeaturesLayer), new Scenery(true, false, 1), new OnBump(delegate(Entity user, Entity entity) { Direction d = entity.Get <GameObject>().Location - user.Get <GameObject>().Location; user.Get <ControllerComponent>().Enqueue(new JumpOverAction(user, d)); return(OnBump.BumpResult.BlockMovement); })); ef.Inherits("LAMP_STANDARD", "nonblockingfeature", new Sprite("LAMP_STANDARD", Sprite.FeaturesLayer)); ef.Inherits("TABLE_WOODEN", "nonblockingfeature", new Sprite("TABLE_WOODEN", Sprite.FeaturesLayer)); ef.Inherits("SAFE_SIMPLE", "nonblockingfeature", new Sprite("SAFE_SIMPLE", Sprite.FeaturesLayer)); #endregion Walls(ef); #region Stairs ef.Inherits("STAIR_WOODEN_UP", "feature", new Sprite("STAIR_WOODEN_UP", Sprite.FeaturesLayer), new Scenery(true, true)); ef.Inherits("STAIR_WOODEN_DOWN", "feature", new Sprite("STAIR_WOODEN_DOWN", Sprite.FeaturesLayer), new Scenery(true, true)); #endregion #region Misc Decorations ef.Inherits("PLANTPOT_FIXED", "feature", new Sprite("PLANTPOT_FIXED", Sprite.FeaturesLayer), new Scenery(true, true)); #endregion }
protected virtual void RegisterEntityTypes() { EntityFactory. Add(EntityTypeEnum.Player, "PlayerCamera"). RegisterDefaultProperty(EntityPropertyEnum.NameplateColour, new Color4(1.0f, 0.2f, 0.9f, 0.1f)). RegisterDefaultProperty(EntityPropertyEnum.Static, false). RegisterDefaultProperty(EntityPropertyEnum.Solid, false). RegisterDefaultProperty(EntityPropertyEnum.MovementVector, new Vector3(0, 0, 0)). RegisterDefaultProperty(EntityPropertyEnum.ViewRange, (float)20). RegisterDefaultProperty(GameEntityPropertyEnum.WalkSpeed, 0.05f). RegisterDefaultProperty(GameEntityPropertyEnum.RunSpeed, 0.1f). RegisterDefaultProperty(GameEntityPropertyEnum.KeyboardMovementDir, (byte)Direction.None). RegisterDefaultProperty(GameEntityPropertyEnum.IsRunning, true). Add(EntityTypeEnum.InventoryItem, "InventoryItem"). RegisterDefaultProperty(EntityPropertyEnum.Static, true). RegisterDefaultProperty(EntityPropertyEnum.Solid, false). RegisterDefaultProperty(GameEntityPropertyEnum.DestroyOnCollected, true). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.HealthPack01). Add(EntityTypeEnum.Zombie, "Zombie"). RegisterDefaultProperty(EntityPropertyEnum.MaxHealth, Consts.ZombieHealth). RegisterDefaultProperty(EntityPropertyEnum.Health, Consts.ZombieHealth). RegisterDefaultProperty(EntityPropertyEnum.Static, false). RegisterDefaultProperty(EntityPropertyEnum.Solid, true). RegisterDefaultProperty(EntityPropertyEnum.MovementVector, new Vector3(0, 0, 0)). RegisterDefaultProperty(EntityPropertyEnum.ViewRange, (float)20). RegisterDefaultProperty(EntityPropertyEnum.ViewAngleRange, (float)Math.PI / 2). RegisterDefaultProperty(GameEntityPropertyEnum.IsZombie, true). RegisterDefaultProperty(GameEntityPropertyEnum.ChaseMinTime, (long)1500). RegisterDefaultProperty(GameEntityPropertyEnum.IsRunning, false). RegisterDefaultProperty(GameEntityPropertyEnum.WalkSpeed, 0.005f). RegisterDefaultProperty(GameEntityPropertyEnum.RunSpeed, 0.02f). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.Zombie01). RegisterDefaultServerProperty(GameEntityPropertyEnum.ChaseThinkCount, 0). RegisterDefaultProperty(GameEntityPropertyEnum.EquippedItem, (byte)InventorySpecialSlotEnum.PrimaryWeapon). Add(EntityTypeEnum.BasicWall, "BasicWall"). RegisterDefaultProperty(EntityPropertyEnum.Static, true). RegisterDefaultProperty(EntityPropertyEnum.Solid, true). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.Wall01). Add(EntityTypeEnum.BasicDoor, "BasicDoor"). RegisterDefaultProperty(EntityPropertyEnum.Static, true). RegisterDefaultProperty(EntityPropertyEnum.Solid, true). RegisterDefaultProperty(EntityPropertyEnum.MaxHealth, Consts.DoorHealth). RegisterDefaultProperty(EntityPropertyEnum.Health, Consts.DoorHealth). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.Door01). Add(EntityTypeEnum.SmallStash, "SmallStash"). RegisterDefaultProperty(EntityPropertyEnum.Static, true). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.AmmoCrate01). RegisterDefaultProperty(EntityPropertyEnum.Nameplate, "Small Stash"). RegisterDefaultProperty(EntityPropertyEnum.NameplateColour, Colours.LightBlue). Add(EntityTypeEnum.ZombieCorpse, "ZombieCorpse"). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.AmmoCrate01). RegisterDefaultProperty(EntityPropertyEnum.Static, true). Add(EntityTypeEnum.Chair, "Chair"). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.Chair01). RegisterDefaultProperty(EntityPropertyEnum.MaxHealth, Consts.ChairHealth). RegisterDefaultProperty(EntityPropertyEnum.Health, Consts.ChairHealth). RegisterDefaultProperty(EntityPropertyEnum.Static, true). RegisterDefaultProperty(EntityPropertyEnum.Solid, true). Add(EntityTypeEnum.ShopShelf, "ShopShelf"). RegisterDefaultProperty(EntityPropertyEnum.Model, Models.EmptyShelf01). RegisterDefaultProperty(EntityPropertyEnum.Static, true). RegisterDefaultProperty(EntityPropertyEnum.Solid, true); }