How to change DiscoFloor settings (Pattern, Volume, Speed, Gradient)

Hello I am trying to change the settings of the DiscoFloor and I am unsure how to implement this 

I see under AudioVisualisationEntity there is

public void ServerUpdateSettings(global::BaseEntity.RPCMessage msg)
{
    int num = msg.read.Int32();
    int num2 = msg.read.Int32();
    int num3 = msg.read.Int32();
    int num4 = msg.read.Int32();
    if (this.currentColour != (global::AudioVisualisationEntity.LightColour)num || this.currentVolumeSensitivity != (global::AudioVisualisationEntity.VolumeSensitivity)num2 || this.currentSpeed != (global::AudioVisualisationEntity.Speed)num3 || this.currentGradient != num4)
    {
        this.currentColour = (global::AudioVisualisationEntity.LightColour)num;
        this.currentVolumeSensitivity = (global::AudioVisualisationEntity.VolumeSensitivity)num2;
        this.currentSpeed = (global::AudioVisualisationEntity.Speed)num3;
        this.currentGradient = num4;
        this.MarkDirty();
        base.SendNetworkUpdate(global::BasePlayer.NetworkQueue.Update);
    }
}

I do not know if this is what you would use, but I also do not know how to pass the proper RPCMessage to contain the four values
Thanks
- Superdog

Did you ever figure this out? This is about where I got before I found your post.

spewki

Did you ever figure this out? This is about where I got before I found your post.

entity.currentColour = AudioVisualisationEntity.LightColour.Red
Or
entity.currentColour = (AudioVisualisationEntity.LightColour) num1;   

num1   is int 0-4

public enum LightColour
  {
    Red,
    Green,
    Blue,
    Yellow,
    Pink,
  }


Its all right there

public class AudioVisualisationEntity : IOEntity
{
  private EntityRef<BaseEntity> connectedTo;
  public GameObjectRef SettingsDialog;

  public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
  {
    using (TimeWarning.New("AudioVisualisationEntity.OnRpcMessage"))
    {
      if (rpc == 4002266471U)
      {
        if ((UnityEngine.Object) player != (UnityEngine.Object) null)
        {
          Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
          if (Global.developer > 2)
            Debug.Log((object) ("SV_RPCMessage: " + player?.ToString() + " - ServerUpdateSettings "));
          using (TimeWarning.New("ServerUpdateSettings"))
          {
            using (TimeWarning.New("Conditions"))
            {
              if (!BaseEntity.RPC_Server.CallsPerSecond.Test(4002266471U, "ServerUpdateSettings", (BaseEntity) this, player, 5UL))
                return true;
              if (!BaseEntity.RPC_Server.IsVisible.Test(4002266471U, "ServerUpdateSettings", (BaseEntity) this, player, 3f))
                return true;
            }
            try
            {
              using (TimeWarning.New("Call"))
                this.ServerUpdateSettings(new BaseEntity.RPCMessage()
                {
                  connection = msg.connection,
                  player = player,
                  read = msg.read
                });
            }
            catch (Exception ex)
            {
              Debug.LogException(ex);
              player.Kick("RPC Error in ServerUpdateSettings");
            }
          }
          return true;
        }
      }
    }
    return base.OnRpcMessage(player, rpc, msg);
  }

  public AudioVisualisationEntity.LightColour currentColour { get; private set; }

  public AudioVisualisationEntity.VolumeSensitivity currentVolumeSensitivity { get; private set; } = AudioVisualisationEntity.VolumeSensitivity.Medium;

  public AudioVisualisationEntity.Speed currentSpeed { get; private set; } = AudioVisualisationEntity.Speed.Medium;

  public int currentGradient { get; private set; }

  public override void OnFlagsChanged(BaseEntity.Flags old, BaseEntity.Flags next)
  {
    base.OnFlagsChanged(old, next);
    if (!this.isServer || old.HasFlag((System.Enum) BaseEntity.Flags.Reserved8) == next.HasFlag((System.Enum) BaseEntity.Flags.Reserved8) || !next.HasFlag((System.Enum) BaseEntity.Flags.Reserved8))
      return;
    int depth = BoomBox.BacktrackLength * 4;
    IOEntity audioSource = this.GetAudioSource((IOEntity) this, ref depth);
    if ((UnityEngine.Object) audioSource != (UnityEngine.Object) null)
      this.ClientRPC<NetworkableId>(RpcTarget.NetworkGroup("Client_PlayAudioFrom"), audioSource.net.ID);
    this.connectedTo.Set((BaseEntity) audioSource);
  }

  private IOEntity GetAudioSource(IOEntity entity, ref int depth)
  {
    if (depth <= 0)
      return (IOEntity) null;
    foreach (IOEntity.IOSlot input in entity.inputs)
    {
      IOEntity entity1 = input.connectedTo.Get(this.isServer);
      if ((UnityEngine.Object) entity1 == (UnityEngine.Object) this)
        return (IOEntity) null;
      if ((UnityEngine.Object) entity1 != (UnityEngine.Object) null && entity1.TryGetComponent<IAudioConnectionSource>(out IAudioConnectionSource _))
        return entity1;
      AudioVisualisationEntity component;
      if ((UnityEngine.Object) entity1 != (UnityEngine.Object) null && entity1.TryGetComponent<AudioVisualisationEntity>(out component) && component.connectedTo.IsSet)
        return component.connectedTo.Get(this.isServer) as IOEntity;
      if ((UnityEngine.Object) entity1 != (UnityEngine.Object) null)
      {
        --depth;
        IOEntity audioSource = this.GetAudioSource(entity1, ref depth);
        if ((UnityEngine.Object) audioSource != (UnityEngine.Object) null && audioSource.TryGetComponent<IAudioConnectionSource>(out IAudioConnectionSource _))
          return audioSource;
      }
    }
    return (IOEntity) null;
  }

  public override void Save(BaseNetworkable.SaveInfo info)
  {
    base.Save(info);
    if (info.msg.connectedSpeaker == null)
      info.msg.connectedSpeaker = Facepunch.Pool.Get<ProtoBuf.ConnectedSpeaker>();
    info.msg.connectedSpeaker.connectedTo = this.connectedTo.uid;
    if (info.msg.audioEntity == null)
      info.msg.audioEntity = Facepunch.Pool.Get<AudioEntity>();
    info.msg.audioEntity.colourMode = (int) this.currentColour;
    info.msg.audioEntity.volumeRange = (int) this.currentVolumeSensitivity;
    info.msg.audioEntity.speed = (int) this.currentSpeed;
    info.msg.audioEntity.gradient = this.currentGradient;
  }

  [BaseEntity.RPC_Server]
  [BaseEntity.RPC_Server.IsVisible(3f)]
  [BaseEntity.RPC_Server.CallsPerSecond(5)]
  public void ServerUpdateSettings(BaseEntity.RPCMessage msg)
  {
    int num1 = msg.read.Int32();
    int num2 = msg.read.Int32();
    int num3 = msg.read.Int32();
    int num4 = msg.read.Int32();
    if (this.currentColour == (AudioVisualisationEntity.LightColour) num1 && this.currentVolumeSensitivity == (AudioVisualisationEntity.VolumeSensitivity) num2 && this.currentSpeed == (AudioVisualisationEntity.Speed) num3 && this.currentGradient == num4)
      return;
    this.currentColour = (AudioVisualisationEntity.LightColour) num1;
    this.currentVolumeSensitivity = (AudioVisualisationEntity.VolumeSensitivity) num2;
    this.currentSpeed = (AudioVisualisationEntity.Speed) num3;
    this.currentGradient = num4;
    this.MarkDirty();
    this.SendNetworkUpdate();
  }

  public override void Load(BaseNetworkable.LoadInfo info)
  {
    base.Load(info);
    if (info.msg.audioEntity != null)
    {
      this.currentColour = (AudioVisualisationEntity.LightColour) info.msg.audioEntity.colourMode;
      this.currentVolumeSensitivity = (AudioVisualisationEntity.VolumeSensitivity) info.msg.audioEntity.volumeRange;
      this.currentSpeed = (AudioVisualisationEntity.Speed) info.msg.audioEntity.speed;
      this.currentGradient = info.msg.audioEntity.gradient;
    }
    if (info.msg.connectedSpeaker == null)
      return;
    this.connectedTo.uid = info.msg.connectedSpeaker.connectedTo;
  }

  public enum LightColour
  {
    Red,
    Green,
    Blue,
    Yellow,
    Pink,
  }

  public enum VolumeSensitivity
  {
    Small,
    Medium,
    Large,
  }

  public enum Speed
  {
    Low,
    Medium,
    High,
  }
}
pDJKuUlrtuVaveJ.png Razor

entity.currentColour = AudioVisualisationEntity.LightColour.Red
Or
entity.currentColour = (AudioVisualisationEntity.LightColour) num1;   

num1   is int 0-4

public enum LightColour
  {
    Red,
    Green,
    Blue,
    Yellow,
    Pink,
  }

Its all right there

public class AudioVisualisationEntity : IOEntity
{
  private EntityRef<BaseEntity> connectedTo;
  public GameObjectRef SettingsDialog;

  public override bool OnRpcMessage(BasePlayer player, uint rpc, Message msg)
  {
    using (TimeWarning.New("AudioVisualisationEntity.OnRpcMessage"))
    {
      if (rpc == 4002266471U)
      {
        if ((UnityEngine.Object) player != (UnityEngine.Object) null)
        {
          Assert.IsTrue(player.isServer, "SV_RPC Message is using a clientside player!");
          if (Global.developer > 2)
            Debug.Log((object) ("SV_RPCMessage: " + player?.ToString() + " - ServerUpdateSettings "));
          using (TimeWarning.New("ServerUpdateSettings"))
          {
            using (TimeWarning.New("Conditions"))
            {
              if (!BaseEntity.RPC_Server.CallsPerSecond.Test(4002266471U, "ServerUpdateSettings", (BaseEntity) this, player, 5UL))
                return true;
              if (!BaseEntity.RPC_Server.IsVisible.Test(4002266471U, "ServerUpdateSettings", (BaseEntity) this, player, 3f))
                return true;
            }
            try
            {
              using (TimeWarning.New("Call"))
                this.ServerUpdateSettings(new BaseEntity.RPCMessage()
                {
                  connection = msg.connection,
                  player = player,
                  read = msg.read
                });
            }
            catch (Exception ex)
            {
              Debug.LogException(ex);
              player.Kick("RPC Error in ServerUpdateSettings");
            }
          }
          return true;
        }
      }
    }
    return base.OnRpcMessage(player, rpc, msg);
  }

  public AudioVisualisationEntity.LightColour currentColour { get; private set; }

  public AudioVisualisationEntity.VolumeSensitivity currentVolumeSensitivity { get; private set; } = AudioVisualisationEntity.VolumeSensitivity.Medium;

  public AudioVisualisationEntity.Speed currentSpeed { get; private set; } = AudioVisualisationEntity.Speed.Medium;

  public int currentGradient { get; private set; }

  public override void OnFlagsChanged(BaseEntity.Flags old, BaseEntity.Flags next)
  {
    base.OnFlagsChanged(old, next);
    if (!this.isServer || old.HasFlag((System.Enum) BaseEntity.Flags.Reserved8) == next.HasFlag((System.Enum) BaseEntity.Flags.Reserved8) || !next.HasFlag((System.Enum) BaseEntity.Flags.Reserved8))
      return;
    int depth = BoomBox.BacktrackLength * 4;
    IOEntity audioSource = this.GetAudioSource((IOEntity) this, ref depth);
    if ((UnityEngine.Object) audioSource != (UnityEngine.Object) null)
      this.ClientRPC<NetworkableId>(RpcTarget.NetworkGroup("Client_PlayAudioFrom"), audioSource.net.ID);
    this.connectedTo.Set((BaseEntity) audioSource);
  }

  private IOEntity GetAudioSource(IOEntity entity, ref int depth)
  {
    if (depth <= 0)
      return (IOEntity) null;
    foreach (IOEntity.IOSlot input in entity.inputs)
    {
      IOEntity entity1 = input.connectedTo.Get(this.isServer);
      if ((UnityEngine.Object) entity1 == (UnityEngine.Object) this)
        return (IOEntity) null;
      if ((UnityEngine.Object) entity1 != (UnityEngine.Object) null && entity1.TryGetComponent<IAudioConnectionSource>(out IAudioConnectionSource _))
        return entity1;
      AudioVisualisationEntity component;
      if ((UnityEngine.Object) entity1 != (UnityEngine.Object) null && entity1.TryGetComponent<AudioVisualisationEntity>(out component) && component.connectedTo.IsSet)
        return component.connectedTo.Get(this.isServer) as IOEntity;
      if ((UnityEngine.Object) entity1 != (UnityEngine.Object) null)
      {
        --depth;
        IOEntity audioSource = this.GetAudioSource(entity1, ref depth);
        if ((UnityEngine.Object) audioSource != (UnityEngine.Object) null && audioSource.TryGetComponent<IAudioConnectionSource>(out IAudioConnectionSource _))
          return audioSource;
      }
    }
    return (IOEntity) null;
  }

  public override void Save(BaseNetworkable.SaveInfo info)
  {
    base.Save(info);
    if (info.msg.connectedSpeaker == null)
      info.msg.connectedSpeaker = Facepunch.Pool.Get<ProtoBuf.ConnectedSpeaker>();
    info.msg.connectedSpeaker.connectedTo = this.connectedTo.uid;
    if (info.msg.audioEntity == null)
      info.msg.audioEntity = Facepunch.Pool.Get<AudioEntity>();
    info.msg.audioEntity.colourMode = (int) this.currentColour;
    info.msg.audioEntity.volumeRange = (int) this.currentVolumeSensitivity;
    info.msg.audioEntity.speed = (int) this.currentSpeed;
    info.msg.audioEntity.gradient = this.currentGradient;
  }

  [BaseEntity.RPC_Server]
  [BaseEntity.RPC_Server.IsVisible(3f)]
  [BaseEntity.RPC_Server.CallsPerSecond(5)]
  public void ServerUpdateSettings(BaseEntity.RPCMessage msg)
  {
    int num1 = msg.read.Int32();
    int num2 = msg.read.Int32();
    int num3 = msg.read.Int32();
    int num4 = msg.read.Int32();
    if (this.currentColour == (AudioVisualisationEntity.LightColour) num1 && this.currentVolumeSensitivity == (AudioVisualisationEntity.VolumeSensitivity) num2 && this.currentSpeed == (AudioVisualisationEntity.Speed) num3 && this.currentGradient == num4)
      return;
    this.currentColour = (AudioVisualisationEntity.LightColour) num1;
    this.currentVolumeSensitivity = (AudioVisualisationEntity.VolumeSensitivity) num2;
    this.currentSpeed = (AudioVisualisationEntity.Speed) num3;
    this.currentGradient = num4;
    this.MarkDirty();
    this.SendNetworkUpdate();
  }

  public override void Load(BaseNetworkable.LoadInfo info)
  {
    base.Load(info);
    if (info.msg.audioEntity != null)
    {
      this.currentColour = (AudioVisualisationEntity.LightColour) info.msg.audioEntity.colourMode;
      this.currentVolumeSensitivity = (AudioVisualisationEntity.VolumeSensitivity) info.msg.audioEntity.volumeRange;
      this.currentSpeed = (AudioVisualisationEntity.Speed) info.msg.audioEntity.speed;
      this.currentGradient = info.msg.audioEntity.gradient;
    }
    if (info.msg.connectedSpeaker == null)
      return;
    this.connectedTo.uid = info.msg.connectedSpeaker.connectedTo;
  }

  public enum LightColour
  {
    Red,
    Green,
    Blue,
    Yellow,
    Pink,
  }

  public enum VolumeSensitivity
  {
    Small,
    Medium,
    Large,
  }

  public enum Speed
  {
    Low,
    Medium,
    High,
  }
}

It says this property cant be assigned to.

I tried this

 

if (shipAttachment.RadioOutput)
{
ioEntity.SetFlag(BaseEntity.Flags.On, true); AudioVisualisationEntity audioVisualisationEntity = ioEntity.GetComponent<AudioVisualisationEntity>(); audioVisualisationEntity.currentColour = AudioVisualisationEntity.LightColour.Blue;
}

 

Ahh yes public AudioVisualisationEntity.LightColour currentColour { get; private set; }

this works with carbon.

 ioEntity.SetFlag(BaseEntity.Flags.On, true);
 AudioVisualisationEntity audioVisualisationEntity = ioEntity.GetComponent<AudioVisualisationEntity>();
 audioVisualisationEntity.currentColour = AudioVisualisationEntity.LightColour.Blue;

Is good

Use carbon for testing as oxide seems to not want to publisize everything to public and limit or impeed what you can do with out useing other methods to get access the the varable  once ya get it working ya can take your time to put in a pull request in git that will not be placed in untell next force wiped.

Ok so if I understand this correctly, I need to ask UMod maintainers to add this as something we can do?

spewki

Ok so if I understand this correctly, I need to ask UMod maintainers to add this as something we can do?

Yes asking usaly does not get it done but you can always try.. Best way is to patch it in git and put in a PR.

Should I just switch over to Carbon? Is it maintained by the same people?

spewki

Should I just switch over to Carbon? Is it maintained by the same people?

Diffrent group i just use carbon for plugin creations as it is so mutch easer to do with out being limited while creating.