示例#1
0
 public override void Process(Entity e)
 {
     Moving moving = e.GetComponent<Moving>();
     Transform spatial = e.GetComponent<Transform>();
     spatial.Position += moving.Velocity * EntityWorld.Delta / 10000000;
     moving.Velocity += moving.Acceleration * EntityWorld.Delta / 10000000;
 }
 public void Attach(Entity newMaster)
 {
     master = newMaster;
     master.OnShutdown += master_OnShutdown;
     master.GetComponent<TransformComponent>(ComponentFamily.Transform).OnMove += HandleOnMasterMove;
     Translate(master.GetComponent<TransformComponent>(ComponentFamily.Transform).Position);
 }
 public void Attach(int uid)
 {
     master = Owner.EntityManager.GetEntity(uid);
     master.OnShutdown += master_OnShutdown;
     master.GetComponent<TransformComponent>(ComponentFamily.Transform).OnMove += HandleOnMasterMove;
     Translate(master.GetComponent<TransformComponent>(ComponentFamily.Transform).Position);
 }
示例#4
0
        public override void Process(Entity entity, float dt)
        {
            var physics = entity.GetComponent<PhysicsComponent>();
            var render = entity.GetComponent<RenderComponent>();

            render.RenderPosition = physics.Position;
        }
示例#5
0
        private void UpdateThrusters(Entity ship)
        {
            var shipComponent = ship.GetComponent<ShipComponent>();
            var thrusters = shipComponent.Thrusters.Select(e => e.GetComponent<ThrusterComponent>());
            var xform = ship.GetComponent<Transform>();

            bool isShipTurning = Math.Abs(shipComponent.AngularTorque) > 0;
            var isShipThrusting = shipComponent.LinearThrustVector.LengthSquared() > 0;

            foreach (var thruster in thrusters)
            {
                if (thruster == null) continue;
                bool isThrusting = false;
                if (isShipThrusting)
                {
                    var offset = Math.Abs(GetLesserAngleDifference(shipComponent.LinearThrustVector.GetAngleRadians() - MathHelper.Pi / 2f, thruster.Part.Transform.Rotation));
                    isThrusting = offset < 1;
                }
                if (isShipTurning)
                {
                    var rotateDir = (AngularDirection)Math.Sign(shipComponent.AngularTorque);
                    //isThrusting = rotateDir == thruster.RotateDir;
                    isThrusting |= thruster.GetAngularThrustMult(rotateDir, Vector2.Zero) > 0;
                }

                thruster.IsThrusting = isThrusting;
                if (isThrusting)
                    thruster.ThrustPercentage = MathHelper.Clamp(thruster.ThrustPercentage + 0.05f, 0, 1);
                else
                    thruster.ThrustPercentage = MathHelper.Clamp(thruster.ThrustPercentage - 0.05f, 0, 1);
            }
        }
示例#6
0
		protected override void ProcessEntity(Engine engine, Entity entity)
		{
			// 2 per 1000 milliseconds
			var amountPerSecond = 2;
			var people = entity.GetComponent<PeopleComponent>().Value;
			entity.GetComponent<GoldComponent>().Value += (engine.DeltaMs * amountPerSecond / 1000.0) * people;
		}
	protected void Awake()
	{
		animator = GetComponent<Animator>();
		entity = GetComponentInParent<Entity>();
		agent = entity.GetComponent<NavMeshAgent>();
		movement = entity.GetComponent<EntityMovement>();
	}
示例#8
0
 public Body ClosestTarget(Entity e)
 {
     AI a = e.GetComponent<AI>();
     PhysicsBody pb = world.GetClosestBody(e.GetComponent<ITransform>().Position, a.HostileGroup);
     Body b = new Body(world, pb.UserData as Entity);
     return b;
 }
 public override void Process(Entity e)
 {
     Acting acting = e.GetComponent<Acting>();
     if (acting.State != ActingState.SkillSelection)
         return;
     InputControlled inputControlled = e.GetComponent<InputControlled>();
     if (String.IsNullOrEmpty(acting.SkillSelected.Name))
     {
         inputControlled.SkillMenu.Draw();
     }
     else
     {
         int count = acting.PossibleTargets.Count;
         if (count > 0)
         {
             if (inputControlled.IsTargetingGroup)
             {
                 foreach (Entity entity in acting.PossibleTargets)
                 {
                     if (entity.GetComponent<Transform>() != null)
                     {
                         Vector2 position = new Vector2(entity.GetComponent<Transform>().Center.X, entity.GetComponent<Transform>().Y - 10);
                         _spriteBatch.Draw(arrowTargeted, position, Color.White);
                     }
                 }
             }
             else
             {
                 Entity TargetedEntity = acting.PossibleTargets[inputControlled.TargetIndex];
                 foreach (Entity entity in acting.PossibleTargets)
                 {
                     if (entity.GetComponent<Transform>() != null)
                     {
                         Vector2 position = new Vector2(entity.GetComponent<Transform>().Center.X, entity.GetComponent<Transform>().Y - 10);
                         if (entity == TargetedEntity)
                         {
                             _spriteBatch.Draw(arrowTargeted, position, Color.White);
                         }
                         else
                         {
                             _spriteBatch.Draw(arrowCanBeTargeted, position, Color.White);
                         }
                     }
                 }
             }
         }
         else
         {
             foreach (Entity entity in acting.Targets)
             {
                 if (entity.GetComponent<Transform>() != null)
                 {
                     Vector2 position = new Vector2(entity.GetComponent<Transform>().Center.X, entity.GetComponent<Transform>().Y - 10);
                     _spriteBatch.Draw(arrowTargeted, position, Color.White);
                 }
             }
         }
     }
 }
        public override void Process(Entity e)
        {
            if(e.GetComponent<Health>()!=null)
                e.GetComponent<Health>().AddDamage(10);

            if (e.GetComponent<Power2>() != null)
                e.GetComponent<Power2>().POWER -=10;
        }
示例#11
0
 private void PlaceItem(Entity actor, Entity item)
 {
     var rnd = new Random();
     actor.SendMessage(this, ComponentMessageType.DropItemInCurrentHand);
     item.GetComponent<SpriteComponent>(ComponentFamily.Renderable).drawDepth = DrawDepth.ItemsOnTables;
     //TODO Unsafe, fix.
     item.GetComponent<TransformComponent>(ComponentFamily.Transform).TranslateByOffset(
         new Vector2(rnd.Next(-28, 28), rnd.Next(-28, 15)));
 }
 public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
 {
     e.Group = "EFFECTS";
     e.AddComponentFromPool<Transform>();
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Expires());
     e.GetComponent<SpatialForm>().SpatialFormFile = "ShipExplosion";
     e.GetComponent<Expires>().LifeTime = 1000;
     return e;
 }
示例#13
0
        public override void Process (Entity entity)
        {
            var transform = entity.GetComponent<Transform>();
            var renderer = entity.GetComponent<Texture2DRenderer>();
            var spriteBatch = BlackBoard.GetEntry<SpriteBatch>("SpriteBatch");
            var texture = BlackBoard.GetEntry<ContentManager>("ContentManager").Load<Texture2D>(renderer.TextureName);


            spriteBatch.Draw(texture, transform.renderPosition, null, null, transform.globalOrigin, transform.renderRotation, transform.renderScale);
        }
 public Entity BuildEntity(Entity e)
 {
     e.Group = "EFFECTS";
     e.AddComponent(new Transform());
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Expires());
     e.GetComponent<SpatialForm>().SpatialFormFile = "BulletExplosion";
     e.GetComponent<Expires>().LifeTime = 1000;
     return e;
 }
示例#15
0
 public static void DamageTarget(Entity user, Entity target, int damage, double hitSuccess = 1)
 {
     EntityCreator.CreateDamageInfo(target, damage, hitSuccess);
     BattleStats stats = target.GetComponent<BattleStats>();
     stats.Health.Decrease(damage);
     if (stats.IsDead && !target.GetComponent<Group>().IsHero)
     {
         target.Delete();
     }
 }
示例#16
0
        public Entity BuildEntity(Entity e)
        {
            e.Group = "BULLETS";

            e.AddComponent(new Transform());
            e.AddComponent(new SpatialForm());
            e.AddComponent(new Velocity());
            e.AddComponent(new Expires());
            e.GetComponent<SpatialForm>().SpatialFormFile = "Missile";
            e.GetComponent<Expires>().LifeTime = 2000;
            return e;
        }
        public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
        {
            e.Group = "BULLETS";

            e.AddComponentFromPool<Transform>();
            e.AddComponent(new SpatialForm());
            e.AddComponent(new Velocity());
            e.AddComponent(new Expires());
            e.GetComponent<SpatialForm>().SpatialFormFile = "Missile";
            e.GetComponent<Expires>().LifeTime = 2000;
            return e;
        }
        public override void Process(Entity e)
        {
            Sprite sprite = e.GetComponent<Sprite>();
            Animation anim = e.GetComponent<Animation>();

            if (anim.Type != AnimationType.None)
            {
                anim._Tick++;
                anim._Tick %= anim.FrameRate;
                if (anim._Tick == 0) //If time to animate.
                {
                    switch (anim.Type)
                    {
                        case AnimationType.Loop:
                            sprite.FrameIndex++;
                            break;

                        case AnimationType.ReverseLoop:
                            sprite.FrameIndex--;
                            break;

                        case AnimationType.Increment:
                            sprite.FrameIndex++;
                            anim.Type = AnimationType.None;
                            break;

                        case AnimationType.Decrement:
                            sprite.FrameIndex--;
                            anim.Type = AnimationType.None;
                            break;

                        case AnimationType.Bounce:
                            sprite.FrameIndex += anim.FrameInc;
                            if (sprite.FrameIndex == sprite.Source.Count() - 1)
                                anim.FrameInc = -1;

                            if (sprite.FrameIndex == 0)
                                anim.FrameInc = 1;
                            break;

                        case AnimationType.Once:
                            if (sprite.FrameIndex < sprite.Source.Count() - 1)
                                sprite.FrameIndex++;
                            else
                                anim.Type = AnimationType.None;
                            break;
                    }
                    e.RemoveComponent<Sprite>(e.GetComponent<Sprite>());
                    e.AddComponent<Sprite>(sprite);
                }
            }
        }
 public Entity BuildEntity(Entity e)
 {
     e.Group = "SHIPS";
     e.AddComponent(new Transform());
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Health());
     e.AddComponent(new Weapon());
     e.AddComponent(new Enemy());
     e.AddComponent(new Velocity());
     e.GetComponent<SpatialForm>().SpatialFormFile = "EnemyShip";
     e.GetComponent<Health>().HP = 10;
     return e;
 }
 public Entity BuildEntity(Entity e, EntityWorld world, params object[] args)
 {
     e.Group = "SHIPS";
     e.AddComponentFromPool<Transform>();
     e.AddComponent(new SpatialForm());
     e.AddComponent(new Health());
     e.AddComponent(new Weapon());
     e.AddComponent(new Enemy());
     e.AddComponent(new Velocity());
     e.GetComponent<SpatialForm>().SpatialFormFile = "EnemyShip";
     e.GetComponent<Health>().HP = 10;
     return e;
 }
示例#21
0
        public HealthBar(Entity entity, HealthBarsSettings settings)
        {
            if (entity == null)
            {
                return;
            }

            Entity    = entity;
            _distance = new TimeCache <float>(() => entity.DistancePlayer, 200);

            // If ignored entity found, skip
            foreach (var _entity in IgnoreEntitiesList)
            {
                if (entity.Path.Contains(_entity))
                {
                    return;
                }
            }

            if (Entity.Path.StartsWith("Metadata/Monsters/AtlasExiles/BasiliskInfluenceMonsters/BasiliskBurrowingViper") &&
                (Entity.Rarity != MonsterRarity.Unique))
            {
                return;
            }

            Update(entity, settings);

            var _canNotDie = entity?.GetComponent <Stats>()?.StatDictionary?.ContainsKey(GameStat.CannotDie);

            if (_canNotDie == null)
            {
                CanNotDie = entity.Path.StartsWith("Metadata/Monsters/Totems/Labyrinth");
            }
            else
            {
                CanNotDie = (bool)_canNotDie;
            }

            var mods = entity?.GetComponent <ObjectMagicProperties>()?.Mods;

            if (mods != null && mods.Contains("MonsterConvertsOnDeath_"))
            {
                OnHostileChange = () =>
                {
                    if (_init)
                    {
                        Update(Entity, settings);
                    }
                };
            }
        }
示例#22
0
        public virtual Entity Install(EntityWorld world, Entity shipEntity, Entity hardpointEntity)
        {
            var slot = hardpointEntity.GetComponent<HardpointComponent>();
            if (!hardpointEntity.IsChildOf(shipEntity)) throw new InvalidOperationException("Cannot install, ship entity does not own hardpoint entity.");
            if (slot == null) throw new InvalidOperationException("Cannot install on non-hardpoint entity.");
            var shipComponent = shipEntity.GetComponent<ShipComponent>();
            var moduleEntity = world.CreateEntity();

            var hardpointTransform = hardpointEntity.GetComponent<Transform>();
            var moduleTransform = moduleEntity.AddComponentFromPool<Transform>();
            moduleTransform.Position = Vector2.Zero;
            moduleTransform.Rotation = 0;
            moduleTransform.Scale = Vector2.One;
            moduleTransform.Origin = -hardpointTransform.Origin;            

            var scale = hardpointTransform.Scale;
            var origin = -hardpointTransform.Origin;
            if (scale.X < 0)
            {
                scale.X = Math.Abs(scale.X);
                origin.X *= -1;
            }
            if (scale.Y < 0)
            {
                scale.Y *= Math.Abs(scale.Y);
                origin.Y *= -1;
            }
            moduleTransform.Scale = scale;
            moduleTransform.Origin = origin;

            hardpointEntity.AddChild(moduleEntity);
            var previousInstalled = slot.InstalledEntity;
            if (previousInstalled != null)
            {
                previousInstalled.GetComponent<ModuleComponent>().Module.Uninstall(shipEntity, previousInstalled);
            }

            if (!string.IsNullOrWhiteSpace(PartGroupId))
            {
                ShipEntityFactory.GetShipModel(PartGroupId).CreateChildEntities(world, moduleEntity);
            }

            var moduleComponent = new ModuleComponent
            {
                HardpointEntity = hardpointEntity,
                Module = this
            };
            slot.InstalledEntity = moduleEntity;
            moduleEntity.AddComponent(moduleComponent);
            return moduleEntity;
        }
示例#23
0
        public override void Process(Entity entity, float dt)
        {
            var render = entity.GetComponent<RenderComponent>();
            var animation = entity.GetComponent<AnimationComponent>();
            var input = entity.GetComponent<InputComponent>();

            string animationId = _animationMapper.GetAnimationId(input);
            SetRunningAnimation(animation, animationId);

            if (!string.IsNullOrEmpty(animation.CurrentAnimationId)){
                UpdateAnimation(dt, animation);
                render.SourceRectangle = animation.Animations[animation.CurrentAnimationId].SourceRectangle;
            }
        }
示例#24
0
 private void GasEffect(Entity entity, float frameTime)
 {
     var transform = entity.GetComponent<TransformComponent>(ComponentFamily.Transform);
     var physics = entity.GetComponent<PhysicsComponent>(ComponentFamily.Physics);
     ITile t =
         IoCManager.Resolve<IMapManager>().GetFloorAt(transform.Position);
     if (t == null)
         return;
     var gasVel = t.GasCell.GasVelocity;
     if (gasVel.Abs() > physics.Mass) // Stop tiny wobbles
     {
         transform.Position = new Vector2(transform.X + (gasVel.X * frameTime), transform.Y + (gasVel.Y * frameTime));
     }
 }
示例#25
0
 public override void DestroyEntity(Entity entity)
 {
     var debugComponent = (DebugComponent)entity.GetComponent(_debugIndex);
     debugComponent.debugBehaviour.DestroyBehaviour();
     base.DestroyEntity(entity);
     updateName();
 }
 public Entity BuildEntity(Entity et1, EntityWorld world , params object[] args)
 {
     et1.AddComponent(new Power());
     et1.GetComponent<Power>().POWER = 100;
     et1.Refresh();
     return et1;
 }
示例#27
0
        public HealthBar(Entity entity, HealthBarsSettings settings)
        {
            Entity    = entity;
            _distance = new TimeCache <float>(() => entity.DistancePlayer, 200);

            IsHidden = () => entity.IsHidden;

            // If ignored entity found, skip
            foreach (var _entity in IgnoreEntitiesList)
            {
                if (entity.Path.Contains(_entity))
                {
                    return;
                }
            }

            Update(entity, settings);

            //CanNotDie = entity.GetComponent<Stats>().StatDictionary.ContainsKey(GameStat.CannotDie);
            CanNotDie = entity.Path.StartsWith("Metadata/Monsters/Totems/Labyrinth");

            var mods = entity?.GetComponent <ObjectMagicProperties>()?.Mods;

            if (mods != null && mods.Contains("MonsterConvertsOnDeath_"))
            {
                OnHostileChange = () =>
                {
                    if (_init)
                    {
                        Update(Entity, settings);
                    }
                };
            }
        }
示例#28
0
 public static void DeleteLocalString(Entity entity, string key)
 {
     if (!entity.HasComponent<LocalData>()) return;
     LocalData data = entity.GetComponent<LocalData>();
     if (data.LocalStrings.ContainsKey(key))
         data.LocalStrings.Remove(key);
 }
示例#29
0
		private GameObject CreateGameObject(Entity entity)
		{
			if (entity.GetComponent<CardType>() != null)
			{
				return Factory.Cards.MakeCard("", entity.GetComponent<Position>().position);
			}
			else if (entity.GetComponent<SystemType>() != null)
			{
				return Factory.Systems.MakeSystem
					(entity.GetComponent<SystemType>().info.tile.X, entity.GetComponent<SystemType>().info.tile.Y);
			}
			else
			{
				return null;
			}
		}
        public override void Process(Entity e)
        {
            if (!e.HasComponent<FadingText>())
                return;

            e.GetComponent<FadingText>().Draw(spriteBatch, spriteFont);
        }
    public override void Execute(Entity context)
    {
        CharacterController controller = context.GetComponent<CharacterController>();
        transform = controller.transform;
        //transform = context.transform;
        direction = context.GetMedrashPosition() - transform.position;
        direction.y = 0.0f;

        tangent.x = clockwise*direction.z;
        tangent.z = -clockwise*direction.x;
        tangent.y = 0.0f;

        if (context.DistanceToMainCharacter() > context.GetCloseRadius())
            direction = tangent + 0.01f*(direction.magnitude - context.GetFarRadius()) * direction;
        else
            direction = tangent + 0.1f*(direction.magnitude - context.GetFarRadius()) * direction;

        RaycastHit hitInfo;
        if (Physics.Raycast(transform.position + controller.center, direction, out hitInfo, 3.0f)) {
            clockwise *= -1;
            direction *= -1;
        }
        context.SetDirection(direction);
        context.SetRunAnimation();
    }
        public override void Process(Entity e)
        {
            Health health = healthMapper.Get(e);
            Body body = bodyMapper.Get(e);

            int X = (int)ScreenHelper.Center.X;
            int Y = (int)ScreenHelper.Center.Y;
            if (e.Tag.Contains("Boss") || e.Group == "Base")
            {
                Sprite s = e.GetComponent<Sprite>();
                float Width = s.CurrentRectangle.Width;
                float Height = s.CurrentRectangle.Height + 7;

                int posX = X + (int)ConvertUnits.ToDisplayUnits(body.Position.X) - (int)s.CurrentRectangle.Width / 2;
                int posY = Y + (int)ConvertUnits.ToDisplayUnits(body.Position).Y - (int)Height / 2;

                //Draw backing
                _SpriteBatch.Draw(_BarTexture,
                    new Rectangle(
                        posX, posY,
                        (int)Width, 2), Color.DarkRed);

                _SpriteBatch.Draw(_BarTexture,
                    new Rectangle(
                        posX, posY,
                        (int)((health.CurrentHealth / health.MaxHealth) * Width),
                            2), Color.Red);
            }
        }
示例#33
0
        private void DrawToLargeMiniMap(Entity entity)
        {
            var icon = GetMapIcon(entity);

            if (icon == null)
            {
                return;
            }

            var iconZ = entity?.GetComponent <Render>()?.Z;

            if (iconZ == null)
            {
                return;
            }
            try
            {
                var point = LargeMapInformation.ScreenCenter
                            + MapIcon.DeltaInWorldToMinimapDelta(entity.GetComponent <Positioned>().GridPos - LargeMapInformation.PlayerPos,
                                                                 LargeMapInformation.Diag, LargeMapInformation.Scale,
                                                                 ((float)iconZ - LargeMapInformation.PlayerPosZ) /
                                                                 (9f / LargeMapInformation.MapWindow.LargeMapZoom));

                var size = icon.Size * 2; // icon.SizeOfLargeIcon.GetValueOrDefault(icon.Size * 2);
                                          // LogMessage($"{Name}: entity.Path - {entity.Path}");
                Graphics.DrawImage(icon.Texture, new RectangleF(point.X - size / 2f, point.Y - size / 2f, size, size), icon.Color);
            }
            catch (NullReferenceException) { }
        }
示例#34
0
 public bool Pickup(Entity entity)
 {
     if (entity?.GetComponent <Inventory>()?.Pickup(Item) ?? false)
     {
         Remove();
         return(true);
     }
     return(false);
 }
示例#35
0
        public void Trigger(Entity target)
        {
            HealthComponent component = target?.GetComponent <HealthComponent>()?.Copy();

            if (component != null)
            {
                Logger.Log("spell", "Cast damage spell (-{0} hp) on '{1}'", damage, target);
                component.Health -= damage;
            }
        }
示例#36
0
        public void Trigger(Entity target)
        {
            HealthComponent component = target?.GetComponent <HealthComponent>()?.Copy();

            if (component != null)
            {
                Logger.Log("spell", "Cast healing spell (+{0} hp) on '{1}'", healing, target);
                component.Health += healing;
            }
        }
示例#37
0
        public static float EntityDistance(Entity entity, Entity player)
        {
            var component = entity?.GetComponent <Render>();

            if (component == null)
            {
                return(9999999f);
            }
            var objectPosition = component.Pos;

            return(Vector3.Distance(objectPosition, player.GetComponent <Render>().Pos));
        }
 public static bool HaveStat(Entity entity, GameStat stat)
 {
     try
     {
         var result = entity?.GetComponent <Stats>()?.StatDictionary?[stat];
         return(result > 0);
     }
     catch (Exception)
     {
         return(false);
     }
 }
示例#39
0
        private static string CheckItem(Entity item)
        {
            var modsComponent = item?.GetComponent <Mods>();

            if (modsComponent == null)
            {
                return("");
            }
            if (modsComponent.ItemRarity == ItemRarity.Unique)
            {
                return("");
            }
            var st = item.Path.Split('/');


            if (st.Length < 3)
            {
                return("");
            }
            if (st[2] == "Armours")
            {
                return(modsComponent.ItemRarity == ItemRarity.Rare ? st[3] : "");
            }
            if (st[2] == "Weapons" && (st.Last() == "OneHandMace4" || st.Last() == "OneHandMace11" || st.Last() == "OneHandMace18"))
            {
                return("StoneHammer");
            }
            if (st[2] == "Weapons" && modsComponent.ItemRarity != ItemRarity.Rare)
            {
                return("");
            }
            if (st[2] == "Currency" && st.Last().Contains("Essence"))
            {
                return("Essence");
            }
            if ((st[2] == "Rings" || st[2] == "Amulets" || st[2] == "Belts") && modsComponent.ItemRarity == ItemRarity.Magic)
            {
                return("");
            }
            return(st[2]);
        }
        public void TestParseComponents()
        {
            string content = FileUtilities.LoadFile("graph_with_layers.yaml");
            Graph  graph   = YamlGraphStorage.LoadGraph(content);

            Entity?stormwind = graph.GetEntity("Stormwind");

            Assert.NotNull(stormwind, "Expected to find 'Stormwind' in the graph");

            EntityComponent?cityComponent = stormwind?.GetComponent("City");

            Assert.NotNull(cityComponent, "Expected 'Stormwind' to have a 'City' component");

            int?population = cityComponent?.Get <int>("Population");

            Assert.AreEqual(200000, population, "Expected a 'Population' attribute with value '200000'");

            string?levelRange = cityComponent?.Get <System.String>("LevelRange");

            Assert.AreEqual("1-60", levelRange, "Expected a 'LevelRange' attribute with value '1-60'");
        }
        public void TestSaveAttributes()
        {
            Graph           entityGraph     = new ("ComponentGraphTest");
            Entity          entity          = new ("Entity with Component", entityGraph);
            EntityComponent entityComponent = new("TestComponent");

            entityComponent.SetProperty("int", 12);
            entityComponent.SetProperty("long", 15213L);
            entityComponent.SetProperty("enum", Biome.Forest);
            entityComponent.SetProperty("list", new List <int>()
            {
                1, 2, 3, 4, 5, 6
            });
            entity.Components.Add(entityComponent);

            entityGraph.Entities.Add(entity);


            string content = YamlGraphStorage.SaveGraph(entityGraph);

            FileUtilities.WriteFile("graph_with_entity.yaml", "./", content);

            // test save and load in the same order
            Graph  g = YamlGraphStorage.LoadGraph(content);
            Entity?e = g.GetEntity("Entity with Component");

            Assert.NotNull(e, "Expected to find 'Entity with Component'");
            EntityComponent?comp = e?.GetComponent("TestComponent");

            Assert.NotNull(comp, "Expected to find 'TestComponent'");

            Assert.AreEqual(comp?.Get <int>("int"), 12, "int property to be 12");
            Assert.AreEqual(comp?.Get <Biome>("enum"), Biome.Forest, "enum property to be Forest");
            Assert.AreEqual(comp?.Get <List <int> >("list"), new List <int>()
            {
                1, 2, 3, 4, 5, 6
            }, "list property to be 1,2,3,4,5,6");
        }
示例#42
0
        private void DrawToSmallMiniMap(Entity entity)
        {
            var icon = GetMapIcon(entity);

            if (icon == null)
            {
                return;
            }

            var         smallMinimap = GameController.Game.IngameState.IngameUi.Map.SmallMiniMap;
            var         playerPos    = GameController.Player.GetComponent <Positioned>().GridPos;
            var         posZ         = GameController.Player.GetComponent <Render>().Z;
            const float scale        = 240f;
            var         mapRect      = smallMinimap.GetClientRect();
            var         mapCenter    = new Vector2(mapRect.X + mapRect.Width / 2, mapRect.Y + mapRect.Height / 2).Translate(0, 0);
            var         diag         = Math.Sqrt(mapRect.Width * mapRect.Width + mapRect.Height * mapRect.Height) / 2.0;
            var         iconZ        = entity?.GetComponent <Render>()?.Z;

            if (iconZ == null)
            {
                return;
            }

            try
            {
                var point = mapCenter + MapIcon.DeltaInWorldToMinimapDelta(entity.GetComponent <Positioned>().GridPos - playerPos, diag, scale, ((float)iconZ - posZ) / 20);
                var size  = icon.Size;
                var rect  = new RectangleF(point.X - size / 2f, point.Y - size / 2f, size, size);
                mapRect.Contains(ref rect, out var isContain);
                if (isContain)
                {
                    // LogMessage($"{Name}: entity.Path - {entity.Path}");
                    Graphics.DrawImage(icon.Texture, rect, icon.Color);
                }
            }
            catch (NullReferenceException) { }
        }
        public override void Update(float dt)
        {
            foreach (Entity playerShieldEntity in playerShieldEntities)
            {
                TransformComponent    transformComp = playerShieldEntity.GetComponent <TransformComponent>();
                PlayerShieldComponent shieldComp    = playerShieldEntity.GetComponent <PlayerShieldComponent>();

                if (shieldComp.ShipEntity == null)
                {
                    return;
                }
                if (!playerShipFamily.Matches(shieldComp.ShipEntity))
                {
                    throw new Exception("Player shield does not have a valid ship entity within PlayerShieldComponent.");
                }
                Entity             playerShip        = shieldComp.ShipEntity;
                TransformComponent shipTransformComp = playerShip.GetComponent <TransformComponent>();

                Vector2 shieldNormal = transformComp.Position - shipTransformComp.Position;
                shieldNormal.Normalize();
                Vector2 shieldTangent = new Vector2(-shieldNormal.Y, shieldNormal.X);

                foreach (Entity collisionEntity in collisionEntities)
                {
                    TransformComponent collisionTransformComp = collisionEntity.GetComponent <TransformComponent>();
                    CollisionComponent collisionComp          = collisionEntity.GetComponent <CollisionComponent>();

                    Vector2[] collisionEntityCorners =
                    {
                        new Vector2(-collisionComp.BoundingBoxComponent.Width / 2, -collisionComp.BoundingBoxComponent.Height / 2),
                        new Vector2(-collisionComp.BoundingBoxComponent.Width / 2, collisionComp.BoundingBoxComponent.Height / 2),
                        new Vector2(collisionComp.BoundingBoxComponent.Width / 2,  collisionComp.BoundingBoxComponent.Height / 2),
                        new Vector2(collisionComp.BoundingBoxComponent.Width / 2, -collisionComp.BoundingBoxComponent.Height / 2)
                    };
                    bool colliding = false;
                    foreach (Vector2 collisionCorner in collisionEntityCorners)
                    {
                        Vector2 shieldCenterToCorner = transformComp.Position - (collisionCorner + collisionTransformComp.Position);
                        // Cast center-to-corner onto normal and tangent
                        float normalCasted  = Vector2.Dot(shieldCenterToCorner, shieldNormal);
                        float tangentCasted = Vector2.Dot(shieldCenterToCorner, shieldTangent);

                        colliding = colliding || Math.Abs(normalCasted) <= shieldComp.Bounds.Y && Math.Abs(tangentCasted) <= shieldComp.Bounds.X;
                    }
                    if (colliding)
                    {
                        if (!collisionComp.collidingWith.Contains(playerShieldEntity))
                        {
                            collisionComp.collidingWith.Add(playerShieldEntity);
                            EventManager.Instance.QueueEvent(new CollisionStartEvent(playerShieldEntity, collisionEntity));
                        }
                    }
                    else
                    {
                        if (collisionComp.collidingWith.Contains(playerShieldEntity))
                        {
                            collisionComp.collidingWith.Remove(playerShieldEntity);
                            EventManager.Instance.QueueEvent(new CollisionEndEvent(playerShieldEntity, collisionEntity));
                        }
                    }
                }
            }
        }
示例#44
0
        public override void Update()
        {
            Entity player = WatchedComponents.OfType <PlayerComponent>().FirstOrDefault()?.Owner;

            foreach (Boss boss in WatchedComponents.OfType <Boss>())
            {
                if (boss.Health <= 0)
                {
                    continue;
                }
                Transform sp   = boss.Owner.GetComponent <Transform>();
                Physical  phys = boss.Owner.GetComponent <Physical>();

                Transform playerSp = player?.GetComponent <Transform>();
                if (sp == null || phys == null)
                {
                    continue;
                }

                phys.GravityMultiplier = 1;
                phys.Velocity          = new Vector2D(0, 362) * Owner.DeltaTime;

                Vector2D?flyTo    = null;
                float    flySpeed = 1;

                bool showParticles = true;

                boss.Difficulty = boss.Health > 20 ? 0 : 1;

                if (boss.State == Boss.Circling)
                {
                    if (boss.Transitioning)
                    {
                        if ((sp.Position - new Vector2D(0, boss.Difficulty >= 1 ? 192 : 128)).Magnitude < 1)
                        {
                            boss.Transitioning = false;
                            boss.StateData     = 0;
                        }
                        else
                        {
                            flyTo    = new Vector2D(0, boss.Difficulty >= 1 ? 192 : 128);
                            flySpeed = 2;
                        }
                    }
                    if (!boss.Transitioning)
                    {
                        boss.StateData += Owner.DeltaTime;
                        if (boss.StateData > 16)
                        {
                            boss.ChangeState(Owner.Random.Next(4) == 0 ? Boss.Drop : Boss.Laser);
                        }
                        else
                        {
                            phys.Velocity += new Vector2D(125.6 * Math.Cos(Math.PI * boss.StateData / 4), 0);
                            Vector2D hoverVelocity = new Vector2D(0, 48 * Math.Cos(Math.PI * boss.StateData));
                            phys.Velocity += hoverVelocity;

                            if (boss.Difficulty >= 1 && Math.Round(boss.StateData, 3) % 4 == 0)
                            {
                                Owner.Entities.Add(new BossProjectileEntity(sp.Position + new Vector2D(0, -48)));
                            }
                        }
                    }
                }
                else if (boss.State == Boss.Laser)
                {
                    if (boss.Transitioning)
                    {
                        if ((sp.Position - new Vector2D(boss.Difficulty >= 1 ? 160 : 0, 256)).Magnitude < 1)
                        {
                            boss.Transitioning = false;
                            boss.StateData     = 0;
                        }
                        else
                        {
                            flyTo    = new Vector2D(boss.Difficulty >= 1 ? 160 : 0, 256);
                            flySpeed = 2;
                        }
                    }
                    if (!boss.Transitioning)
                    {
                        boss.StateData += Owner.DeltaTime;
                        if (boss.Difficulty < 1 && boss.StateData < 1.5)
                        {
                            if (playerSp != null)
                            {
                                flyTo = new Vector2D(playerSp.Position.X, sp.Position.Y);
                            }
                        }
                        else
                        {
                            if (boss.FlameEntity != 0)
                            {
                                Entity entity = Owner.Entities[boss.FlameEntity];
                                if (entity != null)
                                {
                                    entity.Active = false;
                                }
                            }
                            var laser1 = new BossLaser(sp.Position + new Vector2D(0, -44), true);
                            var laser2 = new BossLaser(sp.Position + new Vector2D(-88, -76), false);
                            var laser3 = new BossLaser(sp.Position + new Vector2D(88, -76), false);
                            laser1.Components.Add(new FollowingComponent(boss.Owner.Id)
                            {
                                Offset = new Vector2D(0, -44)
                            });
                            laser2.Components.Add(new FollowingComponent(boss.Owner.Id)
                            {
                                Offset = new Vector2D(-88, -76)
                            });
                            laser3.Components.Add(new FollowingComponent(boss.Owner.Id)
                            {
                                Offset = new Vector2D(88, -76)
                            });
                            Owner.Entities.Add(laser1);
                            Owner.Entities.Add(laser2);
                            Owner.Entities.Add(laser3);
                            boss.ChangeState(Boss.LaserIdle);
                            showParticles = false;
                        }
                    }
                }
                else if (boss.State == Boss.LaserIdle)
                {
                    boss.Transitioning = false;
                    boss.StateData    += Owner.DeltaTime;
                    if (boss.StateData >= 5)
                    {
                        if (boss.FlameEntity != 0)
                        {
                            Entity entity = Owner.Entities[boss.FlameEntity];
                            if (entity != null)
                            {
                                entity.Active = true;
                            }
                        }
                        boss.ChangeState(Boss.Circling);
                    }
                    else
                    {
                        if (boss.Difficulty >= 1)
                        {
                            phys.Velocity += new Vector2D(-64, 0);
                        }
                        showParticles = false;
                    }
                }
                else if (boss.State == Boss.Drop)
                {
                    if (boss.Transitioning)
                    {
                        if ((sp.Position - new Vector2D(-160, 256)).Magnitude < 1)
                        {
                            boss.Transitioning = false;
                            boss.StateData     = 0;
                        }
                        else
                        {
                            flyTo    = new Vector2D(-160, 256);
                            flySpeed = 2;
                        }
                    }
                    if (!boss.Transitioning)
                    {
                        if (sp.Position.X >= 160)
                        {
                            boss.ChangeState(Boss.Circling);
                        }
                        else
                        {
                            boss.StateData += Owner.DeltaTime;
                            phys.Velocity  += new Vector2D(96, 0);
                            if (boss.StateData >= 1)
                            {
                                boss.StateData = 0;
                                if (boss.SentrySpawnerEntity != 0)
                                {
                                    Entity spawner = Owner.Entities[boss.SentrySpawnerEntity];
                                    if (spawner != null)
                                    {
                                        Owner.Events.InvokeEvent(new ActivationEvent(boss, spawner, null));
                                    }
                                }
                            }
                        }
                    }
                }

                //Functions
                if (flyTo != null)
                {
                    phys.Velocity += flySpeed * (flyTo.Value - sp.Position);
                }

                //Particles
                if (showParticles && (boss.FlameParticleProgress == 0 || boss.FlameParticleProgress == 5 * 3 || boss.FlameParticleProgress == 5 * 5 || boss.FlameParticleProgress == 2 * 5 || boss.FlameParticleProgress == 7 * 5))
                {
                    int variant  = boss.FlameParticleProgress == 0 ? 0 : boss.FlameParticleProgress == 3 * 5 ? 1 : boss.FlameParticleProgress == 5 * 5 ? 2 : boss.FlameParticleProgress == 2 * 5 ? 3 : 4;
                    var particle = new BossFlameParticle(sp.Position + phys.Velocity * Owner.DeltaTime + new Vector2D(0, -40), variant);
                    particle.GetComponent <Physical>().Velocity = phys.Velocity * 0.35;
                    Owner.Entities.Add(particle);
                }
                boss.FlameParticleProgress++;
                if (boss.FlameParticleProgress >= 5 * 8)
                {
                    boss.FlameParticleProgress = 0;
                }
            }
        }
示例#45
0
文件: Pierce.cs 项目: Octanum/Corvus
        protected override void OnFinished()
        {
            var ac = Entity.GetComponent <AttributesComponent>();

            ac.DexModifier -= Attributes.Intensity;
        }
示例#46
0
 private void SetUp()
 {
     var Data             = Entity.GetComponent <KnightData>();
     var SelfSpeedManager = Entity.GetComponent <SpeedManager>();
 }
示例#47
0
    private void SetAppearance()
    {
        var KnightSpriteData = Entity.GetComponent <KnightSpriteData>();

        SetKnight(KnightSpriteData.Idle, KnightSpriteData.IdleOffset, KnightSpriteData.IdleSize);
    }
示例#48
0
 protected virtual void Follow()
 {
     Owner?.GetComponent <FollowerComponent>()?.AddFollower(this);
 }
        private StashItem ProcessItem(Entity item)
        {
            try
            {
                if (item == null)
                {
                    return(null);
                }

                var mods = item?.GetComponent <Mods>();

                if (mods?.ItemRarity != ItemRarity.Rare)
                {
                    return(null);
                }

                var bIdentified = mods.Identified;

                if (bIdentified && !Settings.AllowIdentified)
                {
                    return(null);
                }

                if (mods.ItemLevel < 60)
                {
                    return(null);
                }

                var newItem = new StashItem
                {
                    BIdentified = bIdentified,
                    LowLvl      = mods.ItemLevel < 75
                };

                if (string.IsNullOrEmpty(item.Metadata))
                {
                    LogError("Item metadata is empty. Can be fixed by restarting the game", 10);
                    return(null);
                }

                if (Settings.IgnoreElderShaper.Value)
                {
                    var baseComp = item.GetComponent <Base>();

                    if (baseComp.isElder || baseComp.isShaper)
                    {
                        return(null);
                    }
                }

                var bit = GameController.Files.BaseItemTypes.Translate(item.Metadata);

                if (bit == null)
                {
                    return(null);
                }

                newItem.ItemClass = bit.ClassName;
                newItem.ItemName  = bit.BaseName;
                newItem.ItemType  = GetStashItemTypeByClassName(newItem.ItemClass);

                if (newItem.ItemType != StashItemType.Undefined)
                {
                    return(newItem);
                }
            }
            catch (Exception e)
            {
                LogError($"Error in \"ProcessItem\": {e}", 10);
                return(null);
            }

            return(null);
        }
示例#50
0
 public override void OnAdd(Entity owner)
 {
     base.OnAdd(owner);
     owner.GetComponent <TransformComponent>(ComponentFamily.Transform).OnMove += HandleOnMove;
 }
        public override void Process(Entity entity)
        {
            ThrustComponent   tc = entity.GetComponent <ThrustComponent>();
            RotationComponent rc = entity.GetComponent <RotationComponent>();

            if (InputManager.Instance.isKeyReleased(Keys.Space))
            {
                PositionComponent pc    = entity.GetComponent <PositionComponent>();
                InertiaComponent  ic    = entity.GetComponent <InertiaComponent>();
                Entity            laser = this.EntityWorld.CreateEntity();

                laser.AddComponent(new ProjectileComponent(15, new TimeSpan(0, 0, 0, 0, 450)));
                laser.AddComponent(new PositionComponent(pc.Position));
                laser.AddComponent(new RotationComponent(rc.Angle, 0f, false));
                float radians = MathHelper.ToRadians(rc.Angle);
                laser.AddComponent(new InertiaComponent(Vector2.Multiply(Vector2.Normalize(new Vector2((float)Math.Sin(radians), -(float)Math.Cos(radians))), laser.GetComponent <ProjectileComponent>().MaxSpeed)));
                laser.AddComponent(new TextureComponent(new Coord(0, 0), "lasers", new Vector2(0, 0)));
            }
        }
示例#52
0
文件: Tile.cs 项目: Savlon/__GAME
 public virtual void StepOn(Level level, int x, int y, Entity source)
 {
     source.GetComponent <Animator> ().SetBool("Mask", false);
     source.Speed = source.NormalSpeed;
 }
示例#53
0
        private BaseIcon EntityAddedLogic(Entity entity)
        {
            if (SkipEntity(entity))
            {
                return(null);
            }

            //Monsters
            if (entity.Type == EntityType.Monster)
            {
                if (!entity.IsAlive)
                {
                    return(null);
                }

                if (entity.League == LeagueType.Legion)
                {
                    return(new LegionIcon(entity, GameController, Settings, modIcons));
                }
                if (entity.League == LeagueType.Delirium)
                {
                    return(new DeliriumIcon(entity, GameController, Settings, modIcons));
                }

                return(new MonsterIcon(entity, GameController, Settings, modIcons));
            }

            //NPC
            if (entity.Type == EntityType.Npc)
            {
                return(new NpcIcon(entity, GameController, Settings));
            }

            //Player
            if (entity.Type == EntityType.Player)
            {
                if (GameController.IngameState.Data.LocalPlayer.Address == entity.Address ||
                    GameController.IngameState.Data.LocalPlayer.GetComponent <Render>().Name == entity.RenderName)
                {
                    return(null);
                }

                if (!entity.IsValid)
                {
                    return(null);
                }
                return(new PlayerIcon(entity, GameController, Settings, modIcons));
            }

            //Chests
            if (Chests.AnyF(x => x == entity.Type) && !entity.IsOpened)
            {
                return(new ChestIcon(entity, GameController, Settings));
            }

            //Area transition
            if (entity.Type == EntityType.AreaTransition)
            {
                return(new MiscIcon(entity, GameController, Settings));
            }

            //Shrine
            if (entity.HasComponent <Shrine>())
            {
                return(new ShrineIcon(entity, GameController, Settings));
            }

            if (entity.HasComponent <Transitionable>() && entity.HasComponent <MinimapIcon>())
            {
                //Mission marker
                if (entity.Path.Equals("Metadata/MiscellaneousObjects/MissionMarker", StringComparison.Ordinal) ||
                    entity.GetComponent <MinimapIcon>().Name.Equals("MissionTarget", StringComparison.Ordinal))
                {
                    return(new MissionMarkerIcon(entity, GameController, Settings));
                }

                return(new MiscIcon(entity, GameController, Settings));
            }

            if (entity.HasComponent <MinimapIcon>() && entity.HasComponent <Targetable>())
            {
                return(new MiscIcon(entity, GameController, Settings));
            }

            if (entity.Path.Contains("Metadata/Terrain/Leagues/Delve/Objects/EncounterControlObjects/AzuriteEncounterController"))
            {
                return(new MiscIcon(entity, GameController, Settings));
            }

            if (entity.Type == EntityType.LegionMonolith)
            {
                return(new MiscIcon(entity, GameController, Settings));
            }

            return(null);
        }
 public new static bool HasToBeCreated(Entity entity) => entity.GetComponent(typeof(TransformComponent)) != null;
示例#55
0
    public void processInput(string input)
    {
        var moving = player.GetComponent <Movement>().moving;
        var inp    = input.Split(' ');

        if (inp[0].Equals(PlayerCommands.ExitEast) && !moving && !player.attacking)
        {
            player.Location().Check("", "move", "east");
        }
        else if (inp[0].Equals(PlayerCommands.ExitNorth) && !moving && !player.attacking)
        {
            player.Location().Check("", "move", "north");
        }
        else if (inp[0].Equals(PlayerCommands.ExitSouth) && !moving && !player.attacking)
        {
            player.Location().Check("", "move", "south");
        }
        else if (inp[0].Equals(PlayerCommands.ExitWest) && !moving && !player.attacking)
        {
            player.Location().Check("", "move", "west");
        }
        else if (inp[0].Equals(PlayerCommands.Step) && !moving)
        {
            if (inp.Length == 3)
            {
                player.Location().Check(inp[1] + " " + inp[2], "move", "step");
            }
            else
            {
                player.Location().Check(inp[1] + " 1", "move", "step");
            }
        }
        else if (inp[0].Equals(PlayerCommands.Attack) && inp.Length == 2 && !player.attacking)
        {
            player.Location().Check(inp[1], "ent", "attack");
        }
        else if (inp[0].Equals(PlayerCommands.Inspect) && inp.Length == 2 && !player.attacking && !moving)
        {
            player.Location().Check(inp[1], "ent", "inspect");
        }
        else if (inp[0].Equals(PlayerCommands.Target) && inp.Length == 2 && !player.attacking && !moving)
        {
            player.Location().Check(inp[1], "ent", "target");
        }
        else if (inp[0].Equals(PlayerCommands.Get) && inp.Length == 2 && !player.attacking && !moving)
        {
            player.Location().Check(inp[1], "item", "get");
        }
        else if (inp[0].Equals(PlayerCommands.Drop) && inp.Length == 2 && !player.attacking && !moving)
        {
            player.DropItem(inp[1]);
        }
        else if (inp[0].Equals(PlayerCommands.Character))
        {
            GameObject info  = GameObject.Find("InfoPanel").gameObject;
            var        child = info.transform.Find("CharacterPanel");
            info.GetComponent <InfoPanel>().Deactivate();
            child.gameObject.SetActive(true);
        }
        else if (inp[0].Equals(PlayerCommands.Inventory))
        {
            GameObject info  = GameObject.Find("InfoPanel").gameObject;
            var        child = info.transform.Find("InventoryPanel");
            info.GetComponent <InfoPanel>().Deactivate();
            child.gameObject.SetActive(true);
        }
        else if (inp[0].Equals(PlayerCommands.Rest) && !moving && !player.attacking)
        {
            player.resting = true;
            chat.transform.Find("ScrollView").gameObject.transform.Find("Viewport").gameObject.transform.Find("Content").gameObject.GetComponent <Text>().color = new Color(0, 0, 1);
            chat.GetComponent <UpdateChatText>().UpdateChat("<color=#00ffffff>> Resting. </color>");
            chat.transform.Find("ScrollView").gameObject.transform.Find("Viewport").gameObject.transform.Find("Content").gameObject.GetComponent <Text>().color = new Color(1, 1, 1);
            chat.transform.Find("ScrollView").gameObject.GetComponent <ScrollRect>().gameObject.transform.Find("Scrollbar Vertical").gameObject.GetComponent <Scrollbar>().value = 0.0f;
        }
        else if (inp[0].Equals(PlayerCommands.Flee) && player.attacking)
        {
            var arr = new string[] { "north", "south", "east", "west" };
            player.attacking = false;
            player.Location().Check("", "move", arr[Random.Range(0, 3)]);
        }
        else
        {
            player.Location().print("< What?", "#00ffffff");
        }
    }
 void handleAddEA(Entity entity)
 {
     handle(entity, CID.ComponentA, entity.GetComponent(CID.ComponentA));
 }
 void handleAddEB(Entity entity)
 {
     handle(entity, CID.ComponentB, entity.GetComponent(CID.ComponentB));
 }
示例#58
0
        public void Update(Entity entity, IconsBuilderSettings settings)
        {
            if (!_HasIngameIcon)
            {
                MainTexture          = new HudTexture();
                MainTexture.FileName = "Icons.png";
                MainTexture.Size     = settings.SizeMiscIcon;
            }
            else
            {
                MainTexture.Size = settings.SizeDefaultIcon;
                Text             = RenderName;
                Priority         = IconPriority.VeryHigh;
                if (entity.HasComponent <MinimapIcon>() && entity.GetComponent <MinimapIcon>().Name.Equals("DelveRobot", StringComparison.Ordinal))
                {
                    Text = "Follow Me";
                }

                return;
            }

            if (entity.HasComponent <Targetable>())
            {
                if (entity.Path.Equals("Metadata/Terrain/Leagues/Synthesis/Objects/SynthesisPortal", StringComparison.Ordinal))
                {
                    Show = () => entity.IsValid;
                }
                else
                {
                    Show = () =>
                    {
                        var isVisible = false;

                        if (entity.HasComponent <MinimapIcon>())
                        {
                            var minimapIcon = entity.GetComponent <MinimapIcon>();
                            if (minimapIcon == null)
                            {
                                return(false);
                            }
                            isVisible = minimapIcon.IsVisible && !minimapIcon.IsHide;
                        }

                        return(entity.IsValid && isVisible && entity.IsTargetable);
                    };
                }
            }
            else
            {
                Show = () => entity.IsValid && entity.HasComponent <MinimapIcon>() && entity.GetComponent <MinimapIcon>().IsVisible;
            }

            if (entity.HasComponent <Transitionable>() && entity.HasComponent <MinimapIcon>())
            {
                if (entity.Path.Equals("Metadata/MiscellaneousObjects/Abyss/AbyssCrackSpawners/AbyssCrackSkeletonSpawner"))
                {
                    MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.AbyssCrack);

                    Show = () => entity.IsValid && ((entity.HasComponent <MinimapIcon>() && entity.GetComponent <MinimapIcon>().IsHide == false) ||
                                                    (entity.HasComponent <Transitionable>() && entity.GetComponent <Transitionable>().Flag1 == 1));
                }

                else if (entity.Path.Equals("Metadata/MiscellaneousObjects/Abyss/AbyssStartNode"))
                {
                    MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.Abyss);

                    Show = () => entity.IsValid && ((entity.HasComponent <MinimapIcon>() && entity.GetComponent <MinimapIcon>().IsHide == false) ||
                                                    (entity.HasComponent <Transitionable>() && entity.GetComponent <Transitionable>().Flag1 == 1));
                }
                else if (entity.Path.Equals("Metadata/MiscellaneousObjects/Abyss/AbyssNodeSmall", StringComparison.Ordinal) ||
                         entity.Path.Equals("Metadata/MiscellaneousObjects/Abyss/AbyssNodeLarge", StringComparison.Ordinal) ||
                         entity.Path.StartsWith("Metadata/MiscellaneousObjects/Abyss/AbyssFinalNodeChest"))
                {
                    Show = () => entity.IsValid && ((entity.HasComponent <MinimapIcon>() && entity.GetComponent <MinimapIcon>().IsHide == false) ||
                                                    (entity.HasComponent <Transitionable>() && entity.GetComponent <Transitionable>().Flag1 == 1));
                }
                else if (entity.Path.StartsWith("Metadata/Terrain/Leagues/Incursion/Objects/IncursionPortal", StringComparison.Ordinal))
                {
                    Show = () => entity.IsValid && entity.HasComponent <Transitionable>() && entity.GetComponent <Transitionable>().Flag1 < 3;
                }
                else
                {
                    Priority = IconPriority.Critical;
                    Show     = () => false;
                }
            }
            else if (entity.HasComponent <Targetable>())
            {
                if (entity.Path.Contains("Metadata/Terrain/Leagues/Delve/Objects/DelveMineral"))
                {
                    Priority       = IconPriority.High;
                    MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.DelveMineralVein);
                    Text           = "Sulphite";
                    Show           = () => entity.IsValid && entity.IsTargetable;
                }
                else if (entity.Path.Contains("Metadata/Terrain/Leagues/Delve/Objects/EncounterControlObjects/AzuriteEncounterController"))
                {
                    Priority       = IconPriority.High;
                    Text           = "Start";
                    Show           = () => entity.IsValid && entity.HasComponent <Transitionable>() && entity.GetComponent <Transitionable>().Flag1 < 3;
                    MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.PartyLeader);
                }
            }
        }
示例#59
0
        public void Update(Entity entity, IconsBuilderSettings settings, Dictionary <string, Size2> modIcons)
        {
            Show = () => entity.IsAlive;
            if (entity.IsHidden && settings.HideBurriedMonsters)
            {
                Show = () => !entity.IsHidden && entity.IsAlive;
            }
            ID = entity.Id;

            if (!_HasIngameIcon)
            {
                MainTexture = new HudTexture("Icons.png");
            }

            switch (Rarity)
            {
            case MonsterRarity.White:
                MainTexture.Size = settings.SizeEntityWhiteIcon;
                break;

            case MonsterRarity.Magic:
                MainTexture.Size = settings.SizeEntityMagicIcon;
                break;

            case MonsterRarity.Rare:
                MainTexture.Size = settings.SizeEntityRareIcon;
                break;

            case MonsterRarity.Unique:
                MainTexture.Size = settings.SizeEntityUniqueIcon;
                break;

            default:
                throw new ArgumentException(
                          $"{nameof(MonsterIcon)} wrong rarity for {entity.Path}. Dump: {entity.GetComponent<ObjectMagicProperties>().DumpObject()}");

                break;
            }

            //if (_HasIngameIcon && entity.HasComponent<MinimapIcon>() && !entity.GetComponent<MinimapIcon>().Name.Equals("NPC") && entity.League != LeagueType.Heist)
            // return;

            if (!entity.IsHostile)
            {
                if (!_HasIngameIcon)
                {
                    MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.LootFilterSmallGreenCircle);
                    Priority       = IconPriority.Low;
                    Show           = () => !settings.HideMinions && entity.IsAlive;
                }

                //Spirits icon
            }
            else if (Rarity == MonsterRarity.Unique && entity.Path.Contains("Metadata/Monsters/Spirit/"))
            {
                MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.LootFilterLargeGreenHexagon);
            }
            else
            {
                string modName = null;

                if (entity.HasComponent <ObjectMagicProperties>())
                {
                    var objectMagicProperties = entity?.GetComponent <ObjectMagicProperties>();
                    if (objectMagicProperties != null)
                    {
                        var mods = objectMagicProperties.Mods;

                        if (mods != null)
                        {
                            if (mods.Contains("MonsterConvertsOnDeath_"))
                            {
                                Show = () => entity.IsAlive && entity.IsHostile;
                            }

                            modName = mods.FirstOrDefaultF(modIcons.ContainsKey);
                        }
                    }
                }

                if (modName != null)
                {
                    MainTexture    = new HudTexture("sprites.png");
                    MainTexture.UV = SpriteHelper.GetUV(modIcons[modName], new Size2F(7, 8));
                    Priority       = IconPriority.VeryHigh;
                }
                else
                {
                    switch (Rarity)
                    {
                    case MonsterRarity.White:
                        MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.LootFilterLargeRedCircle);
                        if (settings.ShowWhiteMonsterName)
                        {
                            Text = RenderName.Split(',').FirstOrDefault();
                        }
                        break;

                    case MonsterRarity.Magic:
                        MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.LootFilterLargeBlueCircle);
                        if (settings.ShowMagicMonsterName)
                        {
                            Text = RenderName.Split(',').FirstOrDefault();
                        }

                        break;

                    case MonsterRarity.Rare:
                        MainTexture.UV = SpriteHelper.GetUV(MapIconsIndex.LootFilterLargeYellowCircle);
                        if (settings.ShowRareMonsterName)
                        {
                            Text = RenderName.Split(',').FirstOrDefault();
                        }
                        break;

                    case MonsterRarity.Unique:
                        MainTexture.UV    = SpriteHelper.GetUV(MapIconsIndex.LootFilterLargeCyanHexagon);
                        MainTexture.Color = Color.DarkOrange;
                        if (settings.ShowUniqueMonsterName)
                        {
                            Text = RenderName.Split(',').FirstOrDefault();
                        }
                        break;

                    default:
                        throw new ArgumentOutOfRangeException(
                                  $"Rarity wrong was is {Rarity}. {entity.GetComponent<ObjectMagicProperties>().DumpObject()}");
                    }
                }
            }
        }
示例#60
0
 public void LeaveFormation(EncounterState state, Entity parent)
 {
     this.IsInFormation = false;
     state.GetUnit(parent.GetComponent <UnitComponent>().UnitId).NotifyEntityRouted(parent);
     this.AddPrestige(-10, state, "Your allies will remember how you broke from formation! [b]You lose 10 prestige.[/b]", PrestigeSource.BREAKING_FORMATION);
 }