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 = (Sprite)reply.ParamsList[0]; _entityDescription.Position = new Point(10, (int)_entitySprite.Height + _entityDescription.ClientArea.Height + 10); } else { _entityDescription.Position = new Point(10, 10); } }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.Damage: ApplyDamage((Entity)list[0], (int)list[1], (DamageType)list[2]); break; case ComponentMessageType.GetCurrentHealth: var reply2 = new ComponentReplyMessage(ComponentMessageType.CurrentHealth, GetHealth(), GetMaxHealth()); reply = reply2; break; } return(reply); }
public override ComponentReplyMessage ReceiveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.ReceiveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.ContextAdd: AddEntry((ContextMenuEntry)list[0]); break; case ComponentMessageType.ContextRemove: RemoveEntryByName((string)list[0]); break; case ComponentMessageType.ContextGetEntries: reply = new ComponentReplyMessage(ComponentMessageType.ContextGetEntries, _entries); break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { // TODO refactor me - GUI should reference component directly rather than doing this message shit case ComponentMessageType.GetCurrentLocationHealth: var location = (BodyPart)list[0]; if (DamageZones.Exists(x => x.Location == location)) { DamageLocation dmgLoc = DamageZones.First(x => x.Location == location); reply = new ComponentReplyMessage(ComponentMessageType.CurrentLocationHealth, location, dmgLoc.UpdateTotalHealth(), dmgLoc.MaxHealth); } break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.InventoryInformation: Owner.SendComponentNetworkMessage(this, NetDeliveryMethod.ReliableUnordered, ComponentMessageType.InventoryInformation); break; case ComponentMessageType.InventoryAdd: SendInventoryAdd((Entity)list[0]); break; case ComponentMessageType.InventoryRemove: SendInventoryRemove((Entity)list[0]); break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.ItemEquipped: HandleEquipped((Entity)list[0]); break; case ComponentMessageType.ItemUnEquipped: HandleUnEquipped(); break; case ComponentMessageType.GetWearLoc: reply = new ComponentReplyMessage(ComponentMessageType.ReturnWearLoc, wearloc); break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.DisassociateEntity: UnEquipEntity((Entity)list[0]); break; case ComponentMessageType.EquipItemToPart: //Equip an entity straight up. EquipEntityToPart((EquipmentSlot)list[0], (Entity)list[1]); break; case ComponentMessageType.EquipItem: EquipEntity((Entity)list[0]); break; case ComponentMessageType.EquipItemInHand: //Move an entity from a hand to an equipment slot EquipEntityInHand(); break; case ComponentMessageType.UnEquipItemToFloor: //remove an entity from a slot and drop it on the floor UnEquipEntity((Entity)list[0]); break; case ComponentMessageType.UnEquipItemToHand: //remove an entity from a slot and put it in the current hand slot. if (!Owner.HasComponent(ComponentFamily.Hands)) { break; //TODO REAL ERROR MESSAGE OR SOME F**K SHIT } UnEquipEntityToHand((Entity)list[0]); break; case ComponentMessageType.UnEquipItemToSpecifiedHand: //remove an entity from a slot and put it in the current hand slot. if (!Owner.HasComponent(ComponentFamily.Hands)) { break; //TODO REAL ERROR MESSAGE OR SOME F**K SHIT } UnEquipEntityToHand((Entity)list[0], (Hand)list[1]); break; case ComponentMessageType.GetHasInternals: if (HasInternals()) { reply = new ComponentReplyMessage(ComponentMessageType.GetHasInternals, true); } break; } return(reply); }
/// <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); } } }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.GetCurrentLocationHealth: var location = (BodyPart)list[0]; if (DamageZones.Exists(x => x.Location == location)) { DamageLocation dmgLoc = DamageZones.First(x => x.Location == location); reply = new ComponentReplyMessage(ComponentMessageType.CurrentLocationHealth, location, dmgLoc.UpdateTotalHealth(), dmgLoc.MaxHealth); } break; case ComponentMessageType.GetCurrentHealth: reply = new ComponentReplyMessage(ComponentMessageType.CurrentHealth, GetHealth(), GetMaxHealth()); break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.ItemEquipped: IsCurrentlyWorn = true; IsCurrentlyCarried = false; break; case ComponentMessageType.ItemUnEquipped: IsCurrentlyWorn = false; break; case ComponentMessageType.Dropped: IsCurrentlyCarried = false; break; case ComponentMessageType.PickedUp: IsCurrentlyCarried = true; break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.GetActorConnection: reply = new ComponentReplyMessage(ComponentMessageType.ReturnActorConnection, playerSession.ConnectedClient); break; case ComponentMessageType.GetActorSession: reply = new ComponentReplyMessage(ComponentMessageType.ReturnActorSession, playerSession); break; case ComponentMessageType.Die: playerSession.AddPostProcessingEffect(PostProcessingEffectType.Death, -1); IoCManager.Resolve <IRoundManager>().CurrentGameMode.PlayerDied(playerSession); // Tell the current game mode a player just died break; } return(reply); }
/// <summary> /// Allows components to send messages /// </summary> /// <param name="sender">the component doing the sending</param> /// <param name="type">the type of message</param> /// <param name="args">message parameters</param> public void SendMessage(object sender, ComponentMessageType type, List <ComponentReplyMessage> replies, params object[] args) { //LogComponentMessage(sender, type, args); foreach (Component component in GetComponents()) { //Check to see if the component is still a part of this entity --- collection may change in process. if (_components.ContainsValue(component)) { if (replies != null) { ComponentReplyMessage reply = component.RecieveMessage(sender, type, args); if (reply.MessageType != ComponentMessageType.Empty) { replies.Add(reply); } } else { component.RecieveMessage(sender, type, args); } } } }
public override ComponentReplyMessage ReceiveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.ReceiveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.SetSpriteByKey: if (Owner != null) { _currentSpriteKey = (string)list[0]; } break; case ComponentMessageType.SetBaseName: if (Owner != null) { _currentBaseName = (string)list[0]; } break; case ComponentMessageType.SetVisible: Visible = (bool)list[0]; break; } return(reply); }
/// <summary> /// Message handler -- /// SpriteChanged means the spritecomponent changed the current sprite. /// </summary> /// <param name="sender"></param> /// <param name="type"></param> /// <param name="reply"></param> /// <param name="list"></param> public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.SpriteChanged: if (collisionEnabled) { GetAABB(); var cm = IoCManager.Resolve <ICollisionManager>(); cm.UpdateCollidable(this); } break; case ComponentMessageType.DisableCollision: DisableCollision(); break; case ComponentMessageType.EnableCollision: EnableCollision(); break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.DisassociateEntity: RemoveFromInventory((IEntity)list[0]); break; case ComponentMessageType.InventoryAdd: // TODO Refactor craftingmanager to access this component directly, not using a message AddToInventory((IEntity)list[0]); break; case ComponentMessageType.InventorySetSize: maxSlots = (int)list[0]; break; } return(reply); }
public override ComponentReplyMessage ReceiveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.ReceiveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.GetSprite: reply = new ComponentReplyMessage(ComponentMessageType.CurrentSprite, GetBaseSprite()); break; case ComponentMessageType.SetSpriteByKey: SetSpriteByKey((string)list[0]); break; case ComponentMessageType.SlaveAttach: SetMaster(Owner.EntityManager.GetEntity((int)list[0])); break; case ComponentMessageType.ItemUnEquipped: case ComponentMessageType.Dropped: UnsetMaster(); break; } return(reply); }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.WallMountTile: //Attach to a specific tile. var toAttach = (Vector2)list[0]; AttachToTile(toAttach); break; case ComponentMessageType.WallMountSearch: //Look for the best tile to attach to based on owning entity's direction. FindTile(); break; } return(reply); }
private void Setup() { ComponentReplyMessage reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Head); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _head.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Torso); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _chest.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Left_Arm); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _arml.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Right_Arm); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _armr.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Groin); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _groin.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Left_Leg); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _legl.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } reply = assigned.SendMessage(this, ComponentFamily.Damageable, ComponentMessageType.GetCurrentLocationHealth, BodyPart.Right_Leg); if (reply.MessageType == ComponentMessageType.CurrentLocationHealth) { _legr.Color = GetColor((int)reply.ParamsList[1], (int)reply.ParamsList[2]); } if (assigned.HasComponent(ComponentFamily.Damageable)) { var comp = (HealthComponent)assigned.GetComponent(ComponentFamily.Damageable); _overallHealth.Text = comp.GetHealth().ToString() + " / " + comp.GetMaxHealth().ToString(); } }
public override ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = ComponentReplyMessage.Empty; if (type != ComponentMessageType.Damage) { reply = base.RecieveMessage(sender, type, list); } if (sender == this) { return(ComponentReplyMessage.Empty); } switch (type) { case ComponentMessageType.GetCurrentLocationHealth: var location = (BodyPart)list[0]; if (damageZones.Exists(x => x.location == location)) { DamageLocation dmgLoc = damageZones.First(x => x.location == location); var reply1 = new ComponentReplyMessage(ComponentMessageType.CurrentLocationHealth, location, dmgLoc.UpdateTotalHealth(), dmgLoc.maxHealth); reply = reply1; } break; case ComponentMessageType.GetCurrentHealth: var reply2 = new ComponentReplyMessage(ComponentMessageType.CurrentHealth, GetHealth(), GetMaxHealth()); reply = reply2; break; case ComponentMessageType.Damage: if (list.Count() > 3) //We also have a target location { ApplyDamage((Entity)list[0], (int)list[1], (DamageType)list[2], (BodyPart)list[3]); } else //We dont have a target location { ApplyDamage((Entity)list[0], (int)list[1], (DamageType)list[2]); } break; case ComponentMessageType.Heal: if (list.Count() > 3) // We also have a target location { ApplyHeal((Entity)list[0], (int)list[1], (DamageType)list[2], (BodyPart)list[3]); } break; } return(reply); }
public void UnEquipEntityToHand(IEntity e, InventoryLocation h) { ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Hands, ComponentMessageType.IsHandEmpty, h); if (reply.MessageType == ComponentMessageType.IsHandEmptyReply && (bool)reply.ParamsList[0]) { UnEquipEntity(e); Owner.SendMessage(this, ComponentMessageType.PickUpItemToHand, e, h); } }
private void UnEquipEntityToHand(Entity e, Hand h) { var hands = (HumanHandsComponent)Owner.GetComponent(ComponentFamily.Hands); ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Hands, ComponentMessageType.IsHandEmpty, h); if (reply.MessageType == ComponentMessageType.IsHandEmptyReply && (bool)reply.ParamsList[0]) { UnEquipEntity(e); Owner.SendMessage(this, ComponentMessageType.PickUpItemToHand, e, h); } }
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); }
public bool CheckClick(Vector2f worldPos, out int drawdepth) { ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Renderable, ComponentMessageType.CheckSpriteClick, worldPos); if (reply.MessageType == ComponentMessageType.SpriteWasClicked && (bool)reply.ParamsList[0]) { drawdepth = (int)reply.ParamsList[1]; return((bool)reply.ParamsList[0]); } drawdepth = -1; return(false); }
/// <summary> /// Gets the current AABB from the sprite component. /// </summary> private void GetAABB() { ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Renderable, ComponentMessageType.GetAABB); if (reply.MessageType == ComponentMessageType.CurrentAABB) { currentAABB = (RectangleF)reply.ParamsList[0]; } else { return; } }
private bool CanEquip(IEntity e) { if (!e.HasComponent(ComponentFamily.Equippable)) { return(false); } ComponentReplyMessage reply = e.SendMessage(this, ComponentFamily.Equippable, ComponentMessageType.GetWearLoc); return(reply.MessageType == ComponentMessageType.ReturnWearLoc && IsItem(e) && IsEmpty((EquipmentSlot)reply.ParamsList[0]) && activeSlots.Contains((EquipmentSlot)reply.ParamsList[0])); }
protected bool HasInternals() { ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Equipment, ComponentMessageType.GetHasInternals); if (reply.MessageType == ComponentMessageType.GetHasInternals) { var hasInternals = (bool)reply.ParamsList[0]; if (hasInternals) { return(true); } } return(false); }
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 ComponentReplyMessage RecieveMessage(object sender, ComponentMessageType type, params object[] list) { ComponentReplyMessage reply = base.RecieveMessage(sender, type, list); if (sender == this) //Don't listen to our own messages! { return(ComponentReplyMessage.Empty); } switch (type) { } return(reply); }
/// <summary> /// Gets the current AABB from the sprite component. /// </summary> private void GetAABB() { ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Renderable, ComponentMessageType.GetAABB); if (reply.MessageType == ComponentMessageType.CurrentAABB) { var tileSize = IoCManager.Resolve <IMapManager>().TileSize; currentAABB = (FloatRect)reply.ParamsList[0]; currentAABB = new FloatRect( currentAABB.Left / tileSize, currentAABB.Top / tileSize, currentAABB.Width / tileSize, currentAABB.Height / tileSize); } }
// Equips whatever we currently have in our active hand private void EquipEntityInHand() { if (!Owner.HasComponent(ComponentFamily.Hands)) { return; //TODO REAL ERROR MESSAGE OR SOME F**K SHIT } //Get the item in the hand ComponentReplyMessage reply = Owner.SendMessage(this, ComponentFamily.Hands, ComponentMessageType.GetActiveHandItem); if (reply.MessageType == ComponentMessageType.ReturnActiveHandItem && CanEquip((Entity)reply.ParamsList[0])) { RemoveFromOtherComps((Entity)reply.ParamsList[0]); //Equip EquipEntity((Entity)reply.ParamsList[0]); } }