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


C# Entity.SendMessage方法代码示例

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


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

示例1: PlaceItem

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

示例2: ContextMenu

        public ContextMenu(Entity entity, Vector2f creationPos, IResourceManager resourceManager,
                           IUserInterfaceManager userInterfaceManager, bool showExamine = true)
        {
            _owningEntity = entity;
            _resourceManager = resourceManager;
            _userInterfaceManager = userInterfaceManager;

            var entries = new List<ContextMenuEntry>();
            var replies = new List<ComponentReplyMessage>();

            entity.SendMessage(this, ComponentMessageType.ContextGetEntries, replies);

            if (replies.Any())
                entries =
                    (List<ContextMenuEntry>)
                    replies.First(x => x.MessageType == ComponentMessageType.ContextGetEntries).ParamsList[0];

            if (showExamine)
            {
                var examineButton =
                    new ContextMenuButton(
                        new ContextMenuEntry
                            {ComponentMessage = "examine", EntryName = "Examine", IconName = "context_eye"}, _buttonSize,
                        _resourceManager);
                examineButton.Selected += ContextSelected;
                _buttons.Add(examineButton);
                examineButton.Update(0);
            }

            var sVarButton =
                new ContextMenuButton(
                    new ContextMenuEntry {ComponentMessage = "svars", EntryName = "SVars", IconName = "context_eye"},
                    _buttonSize, _resourceManager);
            sVarButton.Selected += ContextSelected;
            _buttons.Add(sVarButton);
            sVarButton.Update(0);

            foreach (ContextMenuEntry entry in entries)
            {
                var newButton = new ContextMenuButton(entry, _buttonSize, _resourceManager);
                newButton.Selected += ContextSelected;
                _buttons.Add(newButton);
                newButton.Update(0);
            }

            float currY = creationPos.Y;
            foreach (ContextMenuButton button in _buttons)
            {
                button.Position = new Vector2i((int) creationPos.X, (int) currY);
                currY += _buttonSize.Y;
            }
            ClientArea = new IntRect((int) creationPos.X, (int) creationPos.Y, (int) _buttonSize.X,
                                       _buttons.Count()*(int) _buttonSize.Y);
        }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:54,代码来源:ContextMenu.cs

示例3: GetSpriteComponentSprite

 public static Sprite GetSpriteComponentSprite(Entity entity)
 {
     ComponentReplyMessage reply = entity.SendMessage(entity, ComponentFamily.Renderable,
                                                      ComponentMessageType.GetSprite);
     if (reply.MessageType == ComponentMessageType.CurrentSprite)
     {
         var sprite = (Sprite) reply.ParamsList[0];
         return sprite;
     }
     return null;
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:11,代码来源:Utilities.cs

示例4: HandleItemToLargeObjectInteraction

        /// <summary>
        /// Entry point for interactions between an item and this object
        /// Basically, the actor uses an item on this object
        /// </summary>
        /// <param name="actor">the actor entity</param>
        protected void HandleItemToLargeObjectInteraction(Entity actor)
        {
            //Get the item
            ComponentReplyMessage reply = actor.SendMessage(this, ComponentFamily.Hands,
                                                            ComponentMessageType.GetActiveHandItem);

            if (reply.MessageType != ComponentMessageType.ReturnActiveHandItem)
                return; // No item in actor's active hand. This shouldn't happen.

            var item = (Entity) reply.ParamsList[0];

            reply = item.SendMessage(this, ComponentFamily.Item, ComponentMessageType.ItemGetCapabilityVerbPairs);
            if (reply.MessageType == ComponentMessageType.ItemReturnCapabilityVerbPairs)
            {
                var verbs = (Lookup<ItemCapabilityType, ItemCapabilityVerb>) reply.ParamsList[0];
                if (verbs.Count == 0 || verbs == null)
                    RecieveItemInteraction(actor, item);
                else
                    RecieveItemInteraction(actor, item, verbs);
            }
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:26,代码来源:BasicLargeObjectComponent.cs

示例5: ExamineWindow

        public ExamineWindow(Size size, Entity entity, IResourceManager resourceManager)
            : base(entity.Name, size, resourceManager)
        {
            _resourceManager = resourceManager;
            _entityDescription = new Label(entity.GetDescriptionString(), "CALIBRI", _resourceManager);

            components.Add(_entityDescription);

            ComponentReplyMessage reply = entity.SendMessage(entity, ComponentFamily.Renderable,
                                                             ComponentMessageType.GetSprite);

            SetVisible(true);

            if (reply.MessageType == ComponentMessageType.CurrentSprite)
            {
                _entitySprite = (CluwneSprite) reply.ParamsList[0];
                _entityDescription.Position = new Point(10,
                                                        (int) _entitySprite.Height +
                                                        _entityDescription.ClientArea.Height + 10);
            }
            else
                _entityDescription.Position = new Point(10, 10);
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:23,代码来源:ExamineWindow.cs

示例6: HandleEmptyHandToItemInteraction

 /// <summary>
 /// Entry point for interactions between an empty hand and this item
 /// Basically, the actor touches this item with an empty hand
 /// </summary>
 /// <param name="actor"></param>
 public virtual void HandleEmptyHandToItemInteraction(Entity actor)
 {
     //Pick up the item
     actor.SendMessage(this, ComponentMessageType.PickUpItem, Owner);
 }
开发者ID:Gartley,项目名称:ss13remake,代码行数:10,代码来源:BasicItemComponent.cs

示例7: AddEntity

        public bool AddEntity(Entity user, Entity inventory, Entity toAdd, InventoryLocation location = InventoryLocation.Any)
        {
            if (EntityIsInEntity(inventory, toAdd))
            {
                RemoveEntity(user, inventory, toAdd, InventoryLocation.Any);
            }
            var comHands = inventory.GetComponent<HumanHandsComponent>(ComponentFamily.Hands);
            var comEquip = inventory.GetComponent<EquipmentComponent>(ComponentFamily.Equipment);
            var comInv = inventory.GetComponent<InventoryComponent>(ComponentFamily.Inventory);

            if ((location == InventoryLocation.Inventory) && comInv != null)
            {
                if (comInv.CanAddEntity(user, toAdd))
                {
                    HideEntity(toAdd);
                    return comInv.AddEntity(user, toAdd);
                }
            }
            else if ((location == InventoryLocation.HandLeft || location == InventoryLocation.HandRight) && comHands != null)
            {
                if (comHands.CanAddEntity(user, toAdd, location))
                {
                    comHands.AddEntity(user, toAdd, location);
                    ShowEntity(toAdd);
                    //Do sprite stuff and attaching
                    EnslaveMovementAndSprite(inventory, toAdd);
                    toAdd.GetComponent<BasicItemComponent>(ComponentFamily.Item).HandlePickedUp(inventory, location);
                    // TODO Find a better way
                    toAdd.SendMessage(this, ComponentMessageType.PickedUp);
                    return true;
                }
            }
            else if ((location == InventoryLocation.Equipment || location == InventoryLocation.Any) && comEquip != null)
            {
                if (comEquip.CanAddEntity(user, toAdd))
                {
                    comEquip.AddEntity(user, toAdd);
                    ShowEntity(toAdd);
                    EnslaveMovementAndSprite(inventory, toAdd);
                    EquippableComponent eqCompo = toAdd.GetComponent<EquippableComponent>(ComponentFamily.Equippable);
                    eqCompo.currentWearer = user;
                    toAdd.SendMessage(this, ComponentMessageType.ItemEquipped);
                    //Do sprite stuff and attaching.
                    return true;
                }
            }     
            else if (location == InventoryLocation.Any)
            {
                //Do sprite stuff and attaching.
                bool done = false;

                if (comInv != null)
                    done = comInv.AddEntity(user, toAdd);

                if (comEquip != null && !done)
                    done = comEquip.AddEntity(user, toAdd);

                if (comHands != null && !done)
                    done = comHands.AddEntity(user, toAdd, location);

                return done;
            }

            return false;
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:65,代码来源:InventorySystem.cs

示例8: RemoveEntity

        public bool RemoveEntity(Entity user, Entity inventory, Entity toRemove, InventoryLocation location = InventoryLocation.Any)
        {
            var comHands = inventory.GetComponent<HumanHandsComponent>(ComponentFamily.Hands);
            var comEquip = inventory.GetComponent<EquipmentComponent>(ComponentFamily.Equipment);
            var comInv = inventory.GetComponent<InventoryComponent>(ComponentFamily.Inventory);

            if (location == InventoryLocation.Any)
            {
                return RemoveEntity(user, inventory, toRemove, GetEntityLocationInEntity(inventory, toRemove));
            }

            if ((location == InventoryLocation.Inventory) && comInv != null)
            {
                if (comInv.RemoveEntity(user, toRemove))
                {
                    //Do sprite stuff and detaching
                    return true;
                }
            }
            else if ((location == InventoryLocation.HandLeft || location == InventoryLocation.HandRight) && comHands != null)
            {
                if (comHands.RemoveEntity(user, toRemove))
                {
                    // TODO Find a better way
                    FreeMovementAndSprite(toRemove);
                    toRemove.SendMessage(this, ComponentMessageType.Dropped);
                    return true;
                }
            }
            else if ((location == InventoryLocation.Equipment) && comEquip != null)
            {
                if (comEquip.RemoveEntity(user, toRemove))
                {
                    //Do sprite stuff and detaching
                    EquippableComponent eqCompo = toRemove.GetComponent<EquippableComponent>(ComponentFamily.Equippable);
                    if(eqCompo != null) eqCompo.currentWearer = null;
                    FreeMovementAndSprite(toRemove);
                    // TODO Find a better way
                    toRemove.SendMessage(this, ComponentMessageType.ItemUnEquipped);
                    return true;
                }
            }

            return false;
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:45,代码来源:InventorySystem.cs

示例9: HandleRemoved

 private void HandleRemoved(Entity entity)
 {
     entity.SendMessage(this, ComponentMessageType.Dropped);
     entity.SendMessage(this, ComponentMessageType.SetVisible, true);
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:5,代码来源:InventoryComponent.cs

示例10: HandleAdded

 private void HandleAdded(Entity entity)
 {
     entity.SendMessage(this, ComponentMessageType.PickedUp, Owner, InventoryLocation.None);
     entity.SendMessage(this, ComponentMessageType.SetVisible, false);
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:5,代码来源:InventoryComponent.cs

示例11: Pickup

        /// <summary>
        /// Put the specified entity in the specified hand
        /// </summary>
        /// <param name="entity"></param>
        private void Pickup(Entity entity, InventoryLocation hand)
        {
            if (entity != null && IsEmpty(hand))
            {
                RemoveFromOtherComps(entity);

                SetEntity(hand, entity);
                Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null,
                                                          ComponentMessageType.HandsPickedUpItem, entity.Uid, hand);
                entity.SendMessage(this, ComponentMessageType.PickedUp, Owner, hand);
            }
        }
开发者ID:Gartley,项目名称:ss13remake,代码行数:16,代码来源:HumanHandsComponent.cs

示例12: CanEquip

        private bool CanEquip(Entity e)
        {
            if (!e.HasComponent(ComponentFamily.Equippable))
                return false;

            ComponentReplyMessage reply = e.SendMessage(this, ComponentFamily.Equippable,
                                                        ComponentMessageType.GetWearLoc);
            if (reply.MessageType == ComponentMessageType.ReturnWearLoc)
            {
                if (IsItem(e) && IsEmpty((EquipmentSlot) reply.ParamsList[0]) && e != null &&
                    activeSlots.Contains((EquipmentSlot) reply.ParamsList[0]))
                {
                    return true;
                }
            }

            return false;
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:18,代码来源:EquipmentComponent.cs

示例13: EquipEntity

        // Equips Entity e and automatically finds the appropriate part
        public void EquipEntity(Entity e)
        {
            if (equippedEntities.ContainsValue(e)) //Its already equipped? Unequip first. This shouldnt happen.
                UnEquipEntity(e);

            if (CanEquip(e))
            {
                ComponentReplyMessage reply = e.SendMessage(this, ComponentFamily.Equippable,
                                                            ComponentMessageType.GetWearLoc);
                if (reply.MessageType == ComponentMessageType.ReturnWearLoc)
                {
                    RemoveFromOtherComps(e);
                    EquipEntityToPart((EquipmentSlot) reply.ParamsList[0], e);
                }
            }
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:17,代码来源:EquipmentComponent.cs

示例14: EquipEntityToPart

        // Equips Entity e to Part part
        public void EquipEntityToPart(EquipmentSlot part, Entity e)
        {
            if (equippedEntities.ContainsValue(e)) //Its already equipped? Unequip first. This shouldnt happen.
                UnEquipEntity(e);

            if (CanEquip(e)) //If the part is empty, the part exists on this mob, and the entity specified is not null
            {
                RemoveFromOtherComps(e);

                equippedEntities.Add(part, e);
                e.SendMessage(this, ComponentMessageType.ItemEquipped, Owner);
                //Owner.SendDirectedComponentNetworkMessage(this, NetDeliveryMethod.ReliableOrdered, null,
                //                                          EquipmentComponentNetMessage.ItemEquipped, part, e.Uid);
            }
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:16,代码来源:EquipmentComponent.cs


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