ActivateFence() private méthode

private ActivateFence ( Rot4 direction, int fenceLength ) : void
direction Rot4
fenceLength int
Résultat void
Exemple #1
0
        private void TryToConnectToPylon(Building_LaserFencePylon linkedPylon, Rot4 direction, int fenceLength, bool forceConnection)
        {
            Rot4 linkedPylonDirection = direction;

            linkedPylonDirection.Rotate(RotationDirection.Clockwise); // Rotate 2 times to get the opposite direction.
            linkedPylonDirection.Rotate(RotationDirection.Clockwise);
            // Check connection is allowed.
            if (forceConnection)
            {
                linkedPylon.connectionIsAllowedByUser[linkedPylonDirection.AsInt]       = true;
                linkedPylon.cachedConnectionIsAllowedByUser[linkedPylonDirection.AsInt] = true;
            }
            if (linkedPylon.connectionIsAllowedByUser[linkedPylonDirection.AsInt] == false)
            {
                this.connectionIsAllowedByUser[direction.AsInt]       = false;
                this.cachedConnectionIsAllowedByUser[direction.AsInt] = false;
                return;
            }
            // Check linkedPylon is powered.
            CompPowerTrader linkedPowerComp = linkedPylon.TryGetComp <CompPowerTrader>();

            if ((linkedPowerComp != null) &&
                linkedPowerComp.PowerOn)
            {
                if (linkedPylon.linkedPylons[linkedPylonDirection.AsInt] != null)
                {
                    // If linkedPylon is already connected to a third pylon, first disconnect from it.
                    linkedPylon.DisconnectFromPylon(linkedPylonDirection);
                }
                this.linkedPylons[direction.AsInt] = linkedPylon;
                this.ActivateFence(direction, fenceLength);
                linkedPylon.linkedPylons[linkedPylonDirection.AsInt] = this;
                linkedPylon.ActivateFence(linkedPylonDirection, fenceLength);
            }
        }
        /// <summary>
        /// Connect to a given pylon if allowed or forced.
        /// </summary>
        public void TryConnectToPylon(Building_LaserFencePylon linkedPylon, Rot4 direction, int fenceLength, bool forceConnection, bool pawnIsPresent)
        {
            // Check connection is allowed.
            if (forceConnection)
            {
                linkedPylon.connectionIsAllowed[direction.Opposite.AsInt]       = true;
                linkedPylon.cachedConnectionIsAllowed[direction.Opposite.AsInt] = true;
                TryNotifyConsoleConfigurationChanged();
            }
            if (pawnIsPresent)
            {
                // Avoid connecting when a neutral pawn is in the path but set new configuration so connection will actually happen when pawn will move.
                return;
            }
            if (linkedPylon.connectionIsAllowed[direction.Opposite.AsInt] == false)
            {
                this.connectionIsAllowed[direction.AsInt]       = false;
                this.cachedConnectionIsAllowed[direction.AsInt] = false;
                TryNotifyConsoleConfigurationChanged();
                return;
            }
            // Check linkedPylon is powered.
            CompPowerTrader linkedPowerComp = linkedPylon.TryGetComp <CompPowerTrader>();

            if ((linkedPowerComp != null) &&
                linkedPowerComp.PowerOn)
            {
                this.ActivateFence(direction, fenceLength);
                linkedPylon.ActivateFence(direction.Opposite, fenceLength);
            }
        }
        /// <summary>
        /// Connect to a given pylon if allowed or forced.
        /// </summary>
        public void TryConnectToPylon(Building_LaserFencePylon linkedPylon, Rot4 direction, int fenceLength, bool forceConnection)
        {
            // Check connection is allowed.
            if (forceConnection)
            {
                linkedPylon.connectionIsAllowedByUser[direction.Opposite.AsInt]       = true;
                linkedPylon.cachedConnectionIsAllowedByUser[direction.Opposite.AsInt] = true;
            }
            if (linkedPylon.connectionIsAllowedByUser[direction.Opposite.AsInt] == false)
            {
                this.connectionIsAllowedByUser[direction.AsInt]       = false;
                this.cachedConnectionIsAllowedByUser[direction.AsInt] = false;
                return;
            }
            // Check linkedPylon is powered.
            CompPowerTrader linkedPowerComp = linkedPylon.TryGetComp <CompPowerTrader>();

            if ((linkedPowerComp != null) &&
                linkedPowerComp.PowerOn)
            {
                this.ActivateFence(direction, fenceLength);
                linkedPylon.ActivateFence(direction.Opposite, fenceLength);
            }
        }
 private void TryToConnectToPylon(Building_LaserFencePylon linkedPylon, Rot4 direction, int fenceLength, bool forceConnection)
 {
     Rot4 linkedPylonDirection = direction;
     linkedPylonDirection.Rotate(RotationDirection.Clockwise); // Rotate 2 times to get the opposite direction.
     linkedPylonDirection.Rotate(RotationDirection.Clockwise);
     // Check connection is allowed.
     if (forceConnection)
     {
         linkedPylon.connectionIsAllowedByUser[linkedPylonDirection.AsInt] = true;
         linkedPylon.cachedConnectionIsAllowedByUser[linkedPylonDirection.AsInt] = true;
     }
     if (linkedPylon.connectionIsAllowedByUser[linkedPylonDirection.AsInt] == false)
     {
         this.connectionIsAllowedByUser[direction.AsInt] = false;
         this.cachedConnectionIsAllowedByUser[direction.AsInt] = false;
         return;
     }
     // Check linkedPylon is powered.
     CompPowerTrader linkedPowerComp = linkedPylon.TryGetComp<CompPowerTrader>();
     if ((linkedPowerComp != null)
         && linkedPowerComp.PowerOn)
     {
         if (linkedPylon.linkedPylons[linkedPylonDirection.AsInt] != null)
         {
             // If linkedPylon is already connected to a third pylon, first disconnect from it.
             linkedPylon.DisconnectFromPylon(linkedPylonDirection);
         }
         this.linkedPylons[direction.AsInt] = linkedPylon;
         this.ActivateFence(direction, fenceLength);
         linkedPylon.linkedPylons[linkedPylonDirection.AsInt] = this;
         linkedPylon.ActivateFence(linkedPylonDirection, fenceLength);
     }
 }