Upload from upload_mods.ps1
This commit is contained in:
89
Score/RemoteCrafting/Scripts/XUiC/XUiC_BroadcastButton.cs
Normal file
89
Score/RemoteCrafting/Scripts/XUiC/XUiC_BroadcastButton.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
// Code from Laydor slightly modified
|
||||
public class XUiC_BroadcastButton : XUiController
|
||||
{
|
||||
private XUiV_Button _button;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
base.Init();
|
||||
_button = viewComponent as XUiV_Button;
|
||||
OnPress += Grab_OnPress;
|
||||
}
|
||||
|
||||
public override void Update(float dt)
|
||||
{
|
||||
base.Update(dt);
|
||||
if (!IsDirty) return;
|
||||
IsDirty = false;
|
||||
SetupButton();
|
||||
}
|
||||
|
||||
public override void OnOpen()
|
||||
{
|
||||
base.OnOpen();
|
||||
|
||||
IsDirty = true;
|
||||
}
|
||||
|
||||
private void Grab_OnPress(XUiController sender, int mouseButton)
|
||||
{
|
||||
//Check if Broadcastmanager is running
|
||||
if (!Broadcastmanager.HasInstance) return;
|
||||
|
||||
if (Broadcastmanager.Instance.Check(xui.lootContainer.ToWorldPos()))
|
||||
{
|
||||
//Unselect button
|
||||
_button.Selected = true;
|
||||
// Remove from Broadcastmanager dictionary
|
||||
Broadcastmanager.Instance.remove(xui.lootContainer.ToWorldPos());
|
||||
}
|
||||
else
|
||||
{
|
||||
//Select button
|
||||
_button.Selected = false;
|
||||
// Add to Broadcastmanager dictionary
|
||||
Broadcastmanager.Instance.add(xui.lootContainer.ToWorldPos());
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupButton()
|
||||
{
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton START");
|
||||
//Unselect button and disable it
|
||||
_button.Enabled = false;
|
||||
_button.Selected = false;
|
||||
_button.IsVisible = false;
|
||||
|
||||
if (xui.lootContainer != null)
|
||||
{
|
||||
Entity entity = GameManager.Instance.World.GetEntity(xui.lootContainer.EntityId) as Entity;
|
||||
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton entity: " + entity.EntityClass.entityClassName);
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton entity is EntityAliveV2: " + (entity is EntityAliveV2));
|
||||
|
||||
if (entity is EntityAliveV2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (xui.lootContainer == null || !Broadcastmanager.HasInstance ||
|
||||
xui.vehicle != null ||
|
||||
(xui.lootContainer != null && GameManager.Instance.World.GetEntity(xui.lootContainer.EntityId) is EntityDrone))
|
||||
{
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton xui.lootContainer == null: " + (xui.lootContainer == null));
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton !Broadcastmanager.HasInstance: " + (!Broadcastmanager.HasInstance));
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton xui.vehicle != null: " + (xui.vehicle != null));
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton EntityNPCRebirth: " + ((xui.lootContainer != null && GameManager.Instance.World.GetEntity(xui.lootContainer.entityId)) is EntityNPCRebirth));
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton EntityDrone: " + ((xui.lootContainer != null && GameManager.Instance.World.GetEntity(xui.lootContainer.entityId) is EntityDrone)));
|
||||
return;
|
||||
}
|
||||
|
||||
//Enable button and set if button is selected
|
||||
_button.IsVisible = true;
|
||||
_button.Enabled = true;
|
||||
_button.Selected = !Broadcastmanager.Instance.Check(xui.lootContainer.ToWorldPos());
|
||||
|
||||
//Log.Out("XUiC_BroadcastButton-SetupButton END");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user