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); } } }
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))); }
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; }
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 f*****g 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; }
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"); }
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 f*****g weirdo..." : ""; IoCManager.Resolve<IChatManager>() .SendChatMessage(ChatChannel.Damage, sourceName + " applies the " + owner.Owner.Name + " to " + targetName + " " + BodyPartMessage(targetedArea) + ".", null, sourceActor.Uid); return true; } return false; }
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"); }
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"); }
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"); }
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; }
/// <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); } }
/// <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); }
public void Help(Entity.Player p) { p.SendMessage("/deletelvl <lvl name> - deletes the specified <level>"); }