Example #1
0
    public PowerSource DisablePowerSource()
    {
        if (lockPower)
        {
            return(null);
        }
        powerSource.transform.SetParent(null);
        powerSource.parentSocket = null;
        powerSource.ToggleKinematics(false);
        PowerSource outSource = powerSource;

        powerSource = null;
        Text("OFFLINE", Color.red);
        if (poweredObject != null)
        {
            poweredObject.TakePower(this);
        }
        PlaySound(losePower);
        EventManager.instance.FireEvent(eventPowerOff);
        return(outSource);
    }
Example #2
0
 public bool EnablePowerSource(PowerSource source, bool playSound = true)
 {
     if (!HasPower)
     {
         source.transform.position = socket.position;
         source.transform.SetParent(socket);
         source.transform.rotation = Quaternion.identity;
         powerSource = source;
         powerSource.parentSocket = this;
         if (powerSource.playerHolding != null)
         {
             powerSource.playerHolding.TakeProp();
         }
         powerSource.ToggleKinematics(true);
         powerSource.gameObject.layer = 8; //Prop
         if (!lockPower)
         {
             Text("ONLINE", Color.green);
         }
         else
         {
             Text("LOCKED", Color.green);
         }
         if (poweredObject != null)
         {
             poweredObject.GivePower(this);
         }
         if (playSound)
         {
             PlaySound(getPower);
         }
         EventManager.instance.FireEvent(eventPowerOn);
         return(true);
     }
     else
     {
         return(false);
     }
 }