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


C# Entity.SendMessage方法代码示例

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


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

示例1: Use

        public void Use(Entity.Player p, string[] args) {
            int time = 30;
            long uid = -1;
            Player who = null;
            Level where = null;
            if (args.Length == 1) {
                try { time = int.Parse(args[0]); }
                catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
            }
            if (args.Length == 2) {
                if (args[0].StartsWith("uid:")) {
                    try { uid = long.Parse(args[0].Split(':')[0]); }
                    catch { p.SendMessage("Redo aborted!"); }
                    return;
                }
                else {
                    who = Player.Find(args[0]);
                }
                try { time = int.Parse(args[1]); }
                catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
            }
            if (args.Length == 3) {
                if (args[0].StartsWith("uid:")) {
                    try { uid = long.Parse(args[0].Split(':')[0]); }
                    catch { p.SendMessage("Redo aborted!"); }
                    return;
                }
                else {
                    who = Player.Find(args[0]);
                }
                try { time = int.Parse(args[1]); }
                catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
                where = Level.FindLevel(args[1]);
                if (where == null) return;

            }
            if (who == null && uid == -1) {
                who = p;
                if (where == null) where = who.Level;
            }
            if (where != null) {
                if (who != null)
                    who.history.Redo(DateTime.Now.AddSeconds(-time).Ticks, where);
                else
                    BlockChangeHistory.Redo(uid, DateTime.Now.AddSeconds(-time).Ticks, where);
            }
            else {
                foreach (Level l in Level.Levels) {
                    if (who != null)
                        who.history.Redo(DateTime.Now.AddSeconds(-time).Ticks, l);
                    else
                        BlockChangeHistory.Redo(uid, DateTime.Now.AddSeconds(-time).Ticks, where);
                }
            }
        }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:55,代码来源:CmdRedo.cs

示例2: 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 Vector2f(rnd.Next(-28, 28), rnd.Next(-28, 15)));
 }
开发者ID:MSylvia,项目名称:space-station-14,代码行数:9,代码来源:WorktopComponent.cs

示例3: GetSpriteComponentSprite

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

示例4: ApplyTo

        public override bool ApplyTo(Entity target, Entity sourceActor)
        {
            string sourceName = sourceActor.Name;
            string targetName = (sourceActor.Uid == target.Uid) ? "himself" : target.Name;
            if (!active)
            {
                IoCManager.Resolve<IChatManager>()
                    .SendChatMessage(ChatChannel.Damage, sourceName + " tries to attack " + targetName
                                                         + " with the " + owner.Owner.Name + ", but nothing happens!",
                                     null, sourceActor.Uid);
                return true;
            }

            var targetedArea = BodyPart.Torso;

            ComponentReplyMessage reply = sourceActor.SendMessage(this, ComponentFamily.Actor,
                                                                  ComponentMessageType.GetActorSession);

            if (reply.MessageType == ComponentMessageType.ReturnActorSession)
            {
                var session = (IPlayerSession) reply.ParamsList[0];
                targetedArea = session.TargetedArea;
            }
            else
                throw new NotImplementedException("Actor has no session or No actor component that returns a session");

            //Damage the item that is doing the damage.
            owner.Owner.SendMessage(this, ComponentMessageType.Damage, owner.Owner, 5, DamageType.Collateral);

            //Damage the target.
            if (target.HasComponent(ComponentFamily.Damageable))
            {
                target.SendMessage(this, ComponentMessageType.Damage, owner.Owner, damageAmount, damType, targetedArea);


                //string suffix = (sourceActor.Uid == target.Uid) ? " What a fucking weirdo..." : "";
                IoCManager.Resolve<IChatManager>()
                    .SendChatMessage(ChatChannel.Damage,
                                     sourceName + " " + DamTypeMessage(damType) + " " + targetName + " in the " +
                                     BodyPartMessage(targetedArea) + " with a " + owner.Owner.Name + "!",
                                     null, sourceActor.Uid);
                return true;
            }
            return false;
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:45,代码来源:MeleeWeaponCapability.cs

示例5: ApplyTo

        public override bool ApplyTo(Entity target, Entity sourceActor)
        {
            ComponentReplyMessage reply = sourceActor.SendMessage(this, ComponentFamily.Actor,
                                                                  ComponentMessageType.GetActorSession);

            if (reply.MessageType == ComponentMessageType.ReturnActorSession)
            {
                var session = (IPlayerSession) reply.ParamsList[0];
                var _netServer = IoCManager.Resolve<ISS14NetServer>();

                NetOutgoingMessage showScannerMsg = _netServer.CreateMessage();
                showScannerMsg.Write((byte) NetMessage.PlayerUiMessage);
                showScannerMsg.Write((byte) UiManagerMessage.CreateUiElement);
                showScannerMsg.Write((byte) CreateUiType.HealthScannerWindow);
                showScannerMsg.Write(target.Uid);
                _netServer.SendMessage(showScannerMsg, session.connectedClient, NetDeliveryMethod.ReliableUnordered);
                return true;
            }
            else
                throw new NotImplementedException("Actor has no session or No actor component that returns a session");
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:21,代码来源:HealthScanCapability.cs

示例6: ApplyTo

        public override bool ApplyTo(Entity target, Entity sourceActor)
        {
            if (capacity <= 0)
            {
                return false;
                //TODO send the player using the item a message
            }
            var targetedArea = BodyPart.Torso;

            ComponentReplyMessage reply = sourceActor.SendMessage(this, ComponentFamily.Actor,
                                                                  ComponentMessageType.GetActorSession);

            if (reply.MessageType == ComponentMessageType.ReturnActorSession)
            {
                var session = (IPlayerSession) reply.ParamsList[0];
                targetedArea = session.TargetedArea;
            }
            else
                throw new NotImplementedException("Actor has no session or No actor component that returns a session");

            //Reduce the capacity.
            capacity -= 20;

            //Heal the target.
            if (target.HasComponent(ComponentFamily.Damageable))
            {
                target.SendMessage(this, ComponentMessageType.Heal, owner.Owner, 20, damType, targetedArea);

                string sourceName = sourceActor.Name;
                string targetName = (sourceActor.Uid == target.Uid) ? "his" : target.Name + "'s";
                //string suffix = (sourceActor.Uid == target.Uid) ? " What a fucking weirdo..." : "";
                IoCManager.Resolve<IChatManager>()
                    .SendChatMessage(ChatChannel.Damage,
                                     sourceName + " applies the " + owner.Owner.Name + " to " + targetName + " " +
                                     BodyPartMessage(targetedArea) + ".",
                                     null, sourceActor.Uid);
                return true;
            }
            return false;
        }
开发者ID:millpond,项目名称:space-station-14,代码行数:40,代码来源:MedicalCapability.cs

示例7: Use

 public void Use(Entity.Player p, string[] args) {
     int time = 30;
     long uid = -1;
     Level where = null;
     if (args.Length == 1) {
         try { time = int.Parse(args[0]); }
         catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
     }
     if (args.Length == 2) {
         uid = Player.GetUID(args[0]);
         if (uid == -1) {
             p.SendMessage("Player not found");
             return;
         }
         try { time = int.Parse(args[1]); }
         catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
     }
     if (args.Length == 3) {
         uid = Player.GetUID(args[0]);
         if (uid == -1) {
             p.SendMessage("Player not found");
             return;
         }
         try { time = int.Parse(args[1]); }
         catch { p.SendMessage("The time was incorrect, using 30 seconds instead"); }
         where = Level.FindLevel(args[2]);
         if (where == null) {
             p.SendMessage("Level " + args[2] + " does not exist or is not loaded");
             return;
         }
     }
     if (uid == -1) uid = p.UID;
     if(where==null)where=p.Level;
     int count = 0;
     foreach (var ch in RedoHistory.Redo((uint)uid, where.Name, DateTime.Now.AddSeconds(-time).Ticks)) {
         where.BlockChange(ch.Item1, ch.Item2, ch.Item3, ch.Item4, p);
         count++;
     }
     p.SendMessage("&e" + count + MCForge.Core.Server.DefaultColor + " Blocks changed");
 }
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:40,代码来源:CmdRedo.cs

示例8: Help

 public void Help(Entity.Player p) {
     p.SendMessage("/redo [time] redos undid changes whitin the last [time] seconds on the current map for you");
     p.SendMessage("/redo [name] [time] [map] redos changes for another player on selected map");
     p.SendMessage("/redo [name] [time] redos changes for another player on your current map");
     p.SendMessage("Note: The new blocks will look like you built them, not the other player");
 }
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:6,代码来源:CmdRedo.cs

示例9: Help

 public void Help(Entity.Player p) {
     p.SendMessage("/redo [time] redos undid changes whitin the last [time] seconds on the current map for you");
     p.SendMessage("/redo [name] [time] [map] redos changes for another player on selected map");
     p.SendMessage("/redo [name] [time] redos changes for another player on all loaded maps");
     p.SendMessage("/redo [uid:number] [time] [map] redos changes for another player on selected map");
     p.SendMessage("/redo [uid:number] [time] redos changes for another player on all loaded maps");
     p.SendMessage("[time] is the number of seonds, if not parsable 30 seconds are used");
     p.SendMessage("[map] is the name of a level, if no level is found redoing will be aborted");
     p.SendMessage("[uid:number] is the uid of a player preceded by \"uid:\" like uid:1234");
 }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:10,代码来源:CmdRedo.cs

示例10: DoEmptyHandToLargeObjectInteraction

 private bool DoEmptyHandToLargeObjectInteraction(Entity user, Entity obj)
 {
     // Send a message to obj that it has been clicked by user.
     obj.SendMessage(user, ComponentMessageType.ReceiveEmptyHandToLargeObjectInteraction, new object[1] { user });
     return true;
 }
开发者ID:millpond,项目名称:space-station-14,代码行数:6,代码来源:InteractionSystem.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:millpond,项目名称:space-station-14,代码行数:16,代码来源:HumanHandsComponent.cs

示例12: 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:millpond,项目名称:space-station-14,代码行数:10,代码来源:BasicItemComponent.cs

示例13: Help

 public void Help(Entity.Player p)
 {
     p.SendMessage("/deletelvl <lvl name> - deletes the specified <level>");
 }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:4,代码来源:CmdDeleteLvl.cs


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