void IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
        {
            if (eventArgs.Target == null)
            {
                return;
            }

            CloseAllSurgeryUIs();
            _optionsCache.Clear();
            _performerCache            = null;
            _bodyManagerComponentCache = null;

            if (eventArgs.Target.TryGetComponent <BodyManagerComponent>(out BodyManagerComponent bodyManager))
            {
                SendBodyPartListToUser(eventArgs, bodyManager);
            }
            else if (eventArgs.Target.TryGetComponent <DroppedBodyPartComponent>(out DroppedBodyPartComponent droppedBodyPart))
            {
                if (droppedBodyPart.ContainedBodyPart == null)
                {
                    Logger.Debug("Installing a mechanism was attempted on an IEntity with a DroppedBodyPartComponent that doesn't have a BodyPart in it!");
                    throw new InvalidOperationException("A DroppedBodyPartComponent exists without a BodyPart in it!");
                }
                if (!droppedBodyPart.ContainedBodyPart.TryInstallDroppedMechanism(this))
                {
                    _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User, Loc.GetString("You can't fit it in!"));
                }
            }
        }
Beispiel #2
0
        protected void OpenSkinSurgery(BodyManagerComponent target, IEntity performer)
        {
            ILocalizationManager localizationManager = IoCManager.Resolve <ILocalizationManager>();

            performer.PopupMessage(performer, localizationManager.GetString("Cut open the skin..."));
            //Delay?
            _skinOpened = true;
        }
Beispiel #3
0
        protected void ClampVesselsSurgery(BodyManagerComponent target, IEntity performer)
        {
            ILocalizationManager localizationManager = IoCManager.Resolve <ILocalizationManager>();

            performer.PopupMessage(performer, localizationManager.GetString("Clamp the vessels..."));
            //Delay?
            _vesselsClamped = true;
        }
Beispiel #4
0
 protected void RemoveOrganSurgery(BodyManagerComponent target, IEntity performer)
 {
     if (_targetOrgan != null)
     {
         ILocalizationManager localizationManager = IoCManager.Resolve <ILocalizationManager>();
         performer.PopupMessage(performer, localizationManager.GetString("Remove the organ..."));
         //Delay?
         _parent.DropMechanism(performer, _targetOrgan);
     }
 }
Beispiel #5
0
        protected void CautizerizeIncisionSurgery(BodyManagerComponent target, IEntity performer)
        {
            ILocalizationManager localizationManager = IoCManager.Resolve <ILocalizationManager>();

            performer.PopupMessage(performer, localizationManager.GetString("Cauterize the incision..."));
            //Delay?
            _skinOpened     = false;
            _vesselsClamped = false;
            _skinRetracted  = false;
        }
Beispiel #6
0
        /// <summary>
        ///     Attempts to perform surgery with the given tooltype. Returns whether the operation was successful.
        /// </summary>
        /// /// <param name="toolType">The SurgeryToolType used for this surgery.</param>
        /// /// <param name="performer">The entity performing the surgery.</param>
        public bool PerformSurgery(SurgeryToolType toolType, BodyManagerComponent target, IEntity performer)
        {
            SurgeryAction step = GetSurgeryStep(toolType);

            if (step == null)
            {
                return(false);
            }
            step(target, performer);
            return(true);
        }
        protected void RemoveBodyPartSurgery(IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
        {
            if (!(container is BodyManagerComponent)) //This surgery requires a DroppedBodyPartComponent.
            {
                return;
            }
            BodyManagerComponent bmTarget = (BodyManagerComponent)container;

            performer.PopupMessage(performer, Loc.GetString("Saw off the limb!"));
            //Delay?
            bmTarget.DisconnectBodyPart(_parent, true);
        }
Beispiel #8
0
        void IAfterInteract.AfterInteract(AfterInteractEventArgs eventArgs)
        {
            if (eventArgs.Target == null)
            {
                return;
            }

            CloseAllSurgeryUIs();
            _optionsCache.Clear();
            _performerCache            = null;
            _bodyManagerComponentCache = null;

            if (eventArgs.Target.TryGetComponent <BodyManagerComponent>(out BodyManagerComponent bodyManager))
            {
                SendBodySlotListToUser(eventArgs, bodyManager);
            }
        }
Beispiel #9
0
        protected void DisconnectOrganSurgery(BodyManagerComponent target, IEntity performer)
        {
            Mechanism mechanismTarget = null;

            //TODO: figureout popup, right now it just takes the first organ available if there is one
            if (_parent.Mechanisms.Count > 0)
            {
                mechanismTarget = _parent.Mechanisms[0];
            }
            if (mechanismTarget != null)
            {
                ILocalizationManager localizationManager = IoCManager.Resolve <ILocalizationManager>();
                performer.PopupMessage(performer, localizationManager.GetString("Detach the organ..."));
                //Delay?
                _targetOrgan = mechanismTarget;
            }
        }
        private void SendBodyPartListToUser(AfterInteractEventArgs eventArgs, BodyManagerComponent bodyManager)
        {
            var toSend = new Dictionary <string, int>(); //Create dictionary to send to client (text to be shown : data sent back if selected)

            foreach (var(key, value) in bodyManager.PartDictionary)
            { //For each limb in the target, add it to our cache if it is a valid option.
                if (value.CanInstallMechanism(ContainedMechanism))
                {
                    _optionsCache.Add(_idHash, value);
                    toSend.Add(key + ": " + value.Name, _idHash++);
                }
            }
            if (_optionsCache.Count > 0)
            {
                OpenSurgeryUI(eventArgs.User.GetComponent <BasicActorComponent>().playerSession);
                UpdateSurgeryUIBodyPartRequest(eventArgs.User.GetComponent <BasicActorComponent>().playerSession, toSend);
                _performerCache            = eventArgs.User;
                _bodyManagerComponentCache = bodyManager;
            }
            else //If surgery cannot be performed, show message saying so.
            {
                _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User, Loc.GetString("You see no way to install the {0}.", Owner.Name));
            }
        }
Beispiel #11
0
        private void SendBodySlotListToUser(AfterInteractEventArgs eventArgs, BodyManagerComponent bodyManager)
        {
            var toSend = new Dictionary <string, int>(); //Create dictionary to send to client (text to be shown : data sent back if selected)

            //Here we are trying to grab a list of all empty BodySlots adjancent to an existing BodyPart that can be attached to. i.e. an empty left hand slot, connected to an occupied left arm slot would be valid.
            List <string> unoccupiedSlots = bodyManager.AllSlots.ToList().Except(bodyManager.OccupiedSlots.ToList()).ToList();

            foreach (string slot in unoccupiedSlots)
            {
                if (bodyManager.TryGetSlotType(slot, out BodyPartType typeResult) && typeResult == ContainedBodyPart.PartType)
                {
                    if (bodyManager.TryGetBodyPartConnections(slot, out List <BodyPart> bodypartResult))
                    {
                        foreach (BodyPart connectedPart in bodypartResult)
                        {
                            if (connectedPart.CanAttachBodyPart(ContainedBodyPart))
                            {
                                _optionsCache.Add(_idHash, slot);
                                toSend.Add(slot, _idHash++);
                            }
                        }
                    }
                }
            }
            if (_optionsCache.Count > 0)
            {
                OpenSurgeryUI(eventArgs.User.GetComponent <BasicActorComponent>().playerSession);
                UpdateSurgeryUIBodyPartSlotRequest(eventArgs.User.GetComponent <BasicActorComponent>().playerSession, toSend);
                _performerCache            = eventArgs.User;
                _bodyManagerComponentCache = bodyManager;
            }
            else //If surgery cannot be performed, show message saying so.
            {
                _sharedNotifyManager.PopupMessage(eventArgs.Target, eventArgs.User, Loc.GetString("You see no way to install the {0}.", Owner.Name));
            }
        }
Beispiel #12
0
 /// <summary>
 ///     Attempts to perform surgery on this BodyPart with the given tool. Returns false if there was an error, true if successful.
 /// </summary>
 public bool AttemptSurgery(SurgeryToolType toolType, BodyManagerComponent target, IEntity performer)
 {
     return(_surgeryData.PerformSurgery(toolType, target, performer));
 }