Exemplo n.º 1
0
 /// <summary>
 ///     Returns whether the given <see cref="Mechanism"/> can be installed on this BodyPart.
 /// </summary>
 public bool CanInstallMechanism(Mechanism mechanism)
 {
     if (_sizeUsed + mechanism.Size > Size)
     {
         return(false); //No space
     }
     return(_surgeryData.CanInstallMechanism(mechanism));
 }
 public void LoosenOrganSurgeryCallback(Mechanism target, IBodyPartContainer container, ISurgeon surgeon, IEntity performer)
 {
     if (target != null && _parent.Mechanisms.Contains(target))
     {
         performer.PopupMessage(performer, Loc.GetString("Loosen the organ..."));
         //Delay?
         _disconnectedOrgans.Add(target);
     }
 }
 public void InitializeDroppedMechanism(Mechanism data)
 {
     ContainedMechanism = data;
     Owner.Name         = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(ContainedMechanism.Name);
     if (Owner.TryGetComponent <SpriteComponent>(out SpriteComponent component))
     {
         component.LayerSetRSI(0, data.RSIPath);
         component.LayerSetState(0, data.RSIState);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 ///     Tries to destroy the given Mechanism in the given BodyPart. Returns false if there was an error, true otherwise. Does NOT spawn a dropped entity.
 /// </summary>
 public bool DestroyMechanism(BodyPart bodyPartTarget, Mechanism mechanismTarget)
 {
     if (!_mechanisms.Contains(mechanismTarget))
     {
         return(false);
     }
     _mechanisms.Remove(mechanismTarget);
     _sizeUsed -= mechanismTarget.Size;
     return(true);
 }
Exemplo n.º 5
0
 /// <summary>
 ///     Attempts to add a Mechanism. Returns true if successful, false if there was an error (e.g. not enough room in BodyPart). Use InstallDroppedMechanism if you want to easily install an IEntity with a DroppedMechanismComponent.
 /// </summary>
 public bool InstallMechanism(Mechanism mechanism)
 {
     if (_sizeUsed + mechanism.Size > Size)
     {
         return(false); //No space
     }
     _mechanisms.Add(mechanism);
     _sizeUsed += mechanism.Size;
     return(true);
 }
Exemplo n.º 6
0
 /// <summary>
 ///     Attempts to add a <see cref="Mechanism"/>. Returns true if successful, false if there was an error (e.g. not enough room in BodyPart). Call InstallDroppedMechanism instead if you want to easily install an IEntity with a DroppedMechanismComponent.
 /// </summary>
 public bool TryInstallMechanism(Mechanism mechanism)
 {
     if (CanInstallMechanism(mechanism))
     {
         _mechanisms.Add(mechanism);
         _sizeUsed += mechanism.Size;
         return(true);
     }
     return(false);
 }
Exemplo n.º 7
0
        /// <summary>
        ///     Tries to remove the given Mechanism reference from the given BodyPart reference. Returns null if there was an error in spawning the entity or removing the mechanism, otherwise returns a reference to the DroppedMechanismComponent on the newly spawned entity.
        /// </summary>
        public DroppedMechanismComponent DropMechanism(IEntity dropLocation, Mechanism mechanismTarget)
        {
            if (!_mechanisms.Contains(mechanismTarget))
            {
                return(null);
            }
            _mechanisms.Remove(mechanismTarget);
            _sizeUsed -= mechanismTarget.Size;
            IEntityManager entityManager    = IoCManager.Resolve <IEntityManager>();
            var            mechanismEntity  = entityManager.SpawnEntity("BaseDroppedMechanism", dropLocation.Transform.GridPosition);
            var            droppedMechanism = mechanismEntity.GetComponent <DroppedMechanismComponent>();

            droppedMechanism.InitializeDroppedMechanism(mechanismTarget);
            return(droppedMechanism);
        }
Exemplo n.º 8
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;
            }
        }
 public override bool CanInstallMechanism(Mechanism toBeInstalled)
 {
     return(_skinOpened && _vesselsClamped && _skinRetracted);
 }
Exemplo n.º 10
0
 /// <summary>
 ///     Returns whether a <see cref="Mechanism"/> can be installed into the <see cref="BodyPart"/> this ISurgeryData represents.
 /// </summary>
 public abstract bool CanInstallMechanism(Mechanism toBeInstalled);