当前位置: 首页>>代码示例>>C#>>正文


C# Entity.HasComponent方法代码示例

本文整理汇总了C#中Entity.HasComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.HasComponent方法的具体用法?C# Entity.HasComponent怎么用?C# Entity.HasComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity.HasComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EntityBeliefs

        public EntityBeliefs(Beliefs beliefs, Entity ent)
        {
            Beliefs = beliefs;
            Entity = ent;

            Type = ent.HasComponent<Survivor>() ? EntityType.Survivor
                : ent.HasComponent<Zombie>() ? EntityType.Zombie
                : ent.HasComponent<WoodPile>() ? EntityType.PlankPile
                : ent.HasComponent<WoodenBreakable>() ? EntityType.PlankSource
                : EntityType.Other;

            Update();
        }
开发者ID:alexturpin,项目名称:Zombles,代码行数:13,代码来源:Beliefs.cs

示例2: OnAdded

 public override void OnAdded(Entity entity)
 {
     if (entity.HasComponent<ShipComponent>())
     {
         entity.AddComponent(new SpatialTokenComponent { Token = Ships.AllocateToken(entity) });
     }
 }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:7,代码来源:SpatialDatabaseSystem.cs

示例3: DeleteLocalString

 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);
 }
开发者ID:zunath,项目名称:MMXEngine,代码行数:7,代码来源:LocalDataMethods.cs

示例4: Process

        public override void Process(Entity e)
        {
            if (!e.HasComponent<FadingText>())
                return;

            e.GetComponent<FadingText>().Draw(spriteBatch, spriteFont);
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:7,代码来源:FadingTextRenderSystem.cs

示例5: OnRemoveEntity

 private void OnRemoveEntity(Entity entity)
 {
     if (entity.HasComponent<ShipComponent>())
     {
         var token = entity.GetComponent<SpatialTokenComponent>().Token;
         token.Dispose();
     }
 }
开发者ID:raycrasher,项目名称:Fell-Sky,代码行数:8,代码来源:SpatialDatabaseSystem.cs

示例6: OnUse

 public override void OnUse(Entity targetEnt)
 {
     if (targetEnt.HasComponent(ComponentFamily.StatusEffects)) //Use component messages instead.
     {
         var statComp = (StatusEffectComp) targetEnt.GetComponent(ComponentFamily.StatusEffects);
         statComp.AddEffect("Bleeding", 10);
         parent.StartCooldown(this);
     }
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:9,代码来源:ExampleAction.cs

示例7: Process

 public override void Process(Entity entity)
 {
     if (!entity.HasComponent<TimeStamp>())
     {
         Int32 unixTimestamp = (Int32)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
         entity.AddComponent(new TimeStamp(unixTimestamp));
         entity.Refresh();
     }
 }
开发者ID:ZloyZlobin,项目名称:JoustCommon,代码行数:9,代码来源:CommandSystems.cs

示例8: Process

        public override void Process(Entity e)
        {
            if (!e.HasComponent<AI>())
                return;

            AI ai = e.GetComponent<AI>();

            bool behavior;

            if (ai.Target != null)
            {
                if (World.EntityManager.GetEntity((ai.Target.UserData as Entity).Id) == null)
                    ai.Target = null;
                else if (!(!ai.Recalculate && ai.Calculated) && ai.Target != null && (ai.Target.UserData as Entity) != null && !(behavior = ai.Behavior(ai.Target))) //Run ai behavior, if behavior returns true look for new target.
                {
                    ai.Calculated = true;

                    if (ai.Target == null && e.Group != "Players" && e.Group != "Structures" && !e.Tag.Contains("Cannon"))
                    {
                        if (e.HasComponent<Health>())
                            e.GetComponent<Health>().SetHealth(null, 0);
                        else
                            e.Delete();
                    }

                    return;
                }
            }

            ai.Calculated = true;
            ai.Target = _FindNewTarget(ai, e.GetComponent<Body>());

            if (ai.Target == null && e.Group != "Players" && e.Group != "Structures" && !e.Tag.Contains("Boss"))
            {
                if (e.HasComponent<Health>())
                    e.GetComponent<Health>().SetHealth(null, 0);
                else
                    e.Delete();
            }
            else if (ai.Target == null && e.Group == "Players")
                ai.Behavior(null);

            e.Refresh();
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:44,代码来源:AISystem.cs

示例9: Matches

        public override bool Matches(Entity entity)
        {
            for (int i = 0, indicesLength = indices.Length; i < indicesLength; i++) {
                if (entity.HasComponent(indices[i])) {
                    return false;
                }
            }

            return true;
        }
开发者ID:fversnel,项目名称:Entitas-CSharp,代码行数:10,代码来源:NoneOfMatcher.cs

示例10: GetIconSprite

 public static Sprite GetIconSprite(Entity entity)
 {
     if(entity.HasComponent(ComponentFamily.Icon))
     {
         var icon = entity.GetComponent<IconComponent>(ComponentFamily.Icon).Icon;
         if (icon == null)
             return IoCManager.Resolve<IResourceManager>().GetNoSprite();
         return icon;
     }
     return IoCManager.Resolve<IResourceManager>().GetNoSprite();
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:11,代码来源:Utilities.cs

示例11: GetIsHostile

 public static bool GetIsHostile(Entity entity)
 {
     try
     {
         return entity.HasComponent<Hostile>();
     }
     catch (Exception)
     {
         return false;
     }
 }
开发者ID:zunath,项目名称:MMXEngine,代码行数:11,代码来源:CreatureMethods.cs

示例12: SetMaster

        public void SetMaster(Entity m)
        {
            if (!m.HasComponent(ComponentFamily.Renderable))
                return;
            var mastercompo = m.GetComponent<IRenderableComponent>(ComponentFamily.Renderable);
            //If there's no sprite component, then FUCK IT
            if (mastercompo == null)
                return;

            mastercompo.AddSlave(this);
            master = mastercompo;
        }
开发者ID:Gartley,项目名称:ss13remake,代码行数:12,代码来源:AnimatedSpriteComponent.cs

示例13: HandleCollision

 public void HandleCollision(Entity entity, Entity other)
 {
     if (other.HasComponent<CollisionBehaviorComponent> ())
     {
         CollisionDispatcher dispatcher = other.GetComponent<CollisionBehaviorComponent> ()
             .Behavior as CollisionDispatcher;
         if (dispatcher != null)
         {
             dispatcher.DispatchCollision (this, other, entity);
         }
     }
 }
开发者ID:47th,项目名称:Monogame,代码行数:12,代码来源:CollisionDispatcher.cs

示例14: AddModifier

 /// <summary>
 /// Add a Modifier script to an Entity, based on a code block (delegate) and a VectorFunction
 /// </summary>
 /// <param name="e">Entity to add modifier script to</param>
 /// <param name="scriptCode">Code block (delegate) that is the script</param>
 /// <param name="func">Function whose value will be passed in ScriptContext.FunctionValue to script</param>
 /// <returns></returns>
 public static VectorModifierScript AddModifier(Entity e, VectorModifierDelegate scriptCode, IVectorFunction func)
 {
     if (!e.HasComponent<ScriptComp>())
     {
         e.AddComponent(new ScriptComp());
         e.Refresh();
     }
     var sc = e.GetComponent<ScriptComp>();
     var script = new VectorModifierScript(scriptCode, func);
     sc.Add(script);
     return script;
 }
开发者ID:IndiegameGarden,项目名称:TTengine,代码行数:19,代码来源:TTFactory.cs

示例15: Process

        public override void Process(Entity e)
        {
            if (!e.HasComponent<FadingText>())
                return;

            FadingText f = e.GetComponent<FadingText>();

            f.Update(world.Delta);

            if (f.Fraction() <= 0)
            {
                e.Delete();
            }
        }
开发者ID:LostCodeStudios,项目名称:SpaceHordes,代码行数:14,代码来源:FadingTextProcessingSystem.cs


注:本文中的Entity.HasComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。