protected override void OnSelect(ToolController owner)
    {
        Debug.Log("Satellite Tool Selected");
        satInv = owner.GetComponent <SatelliteInventory>();
        if (satInv == null || satInv.StoredSatellites.Count == 0 || satInv.StoredSatellites[0] == null)
        {
            satInv.NoSatTooltip.SetActive(true);
            //Debug.Log("NoSat Found");
            return;
        }

        //this is such a gross way of checking what satellite type a thing is im sorry
        if (satInv.StoredSatellites[0].name == "FuelSatellite")
        {
            foreach (var cloud in cloudVisualizers)
            {
                cloud.VisualizeArea();
            }
        }

        SatellitePreview = GameObject.Instantiate(satInv.StoredSatellites[0].PreviewPrefab);
        SatellitePreview.transform.position = satInv.SatelliteSpawnPos.position;
        SatellitePreview.transform.rotation = satInv.SatelliteSpawnPos.rotation;
        SatellitePreview.transform.SetParent(owner.GetComponentInChildren <Camera>().transform);
        SatBehavior = SatellitePreview.GetComponent <SatelliteBehavior>();
    }
Exemple #2
0
        public static void Initialize(ToolController toolController)
        {
            if (sm_initialized)
            {
                return;
            }

            Debug.Log("Traffic++: Initializing Transport Tool.\n");

            TransportTool       originalTransportTool = toolController.GetComponent <TransportTool>();
            CustomTransportTool customTransportTool   = toolController.gameObject.AddComponent <CustomTransportTool>();

            // contributed by Japa
            FieldInfo toolControllerField = typeof(ToolController).GetField("m_tools", BindingFlags.Instance | BindingFlags.NonPublic);

            if (toolControllerField != null)
            {
                toolControllerField.SetValue(toolController, toolController.GetComponents <ToolBase>());
            }
            FieldInfo toolModifierDictionary = typeof(ToolsModifierControl).GetField("m_Tools", BindingFlags.Static | BindingFlags.NonPublic);

            if (toolModifierDictionary != null)
            {
                toolModifierDictionary.SetValue(null, null);
            }

            sm_initialized = true;

            Debug.Log("Traffic++: Transport Tool initialized.\n");
        }
        public static void RemoveTool(this ToolController toolController, Type toolType)
        {
            var toolInstance = toolController.GetComponent(toolType);

            if (toolInstance == null)
            {
                return;
            }

            GameObject.Destroy(toolInstance);

            UpdateTools(toolController);
        }
        public static ToolBase AddTool(this ToolController toolController, Type toolType)
        {
            var toolInstance = toolController.GetComponent(toolType);

            if (toolInstance != null)
            {
                return((ToolBase)toolInstance);
            }

            toolInstance = toolController.gameObject.AddComponent(toolType);

            UpdateTools(toolController);

            return((ToolBase)toolInstance);
        }
        private IEnumerator ToggleTool_Internal(bool newState)
        {
            yield return(0);

            if (TouchThisTool.instance.enabled && !newState)
            {
                TouchThisTool.instance.enabled = newState;
                ToolController tc = FindObjectOfType <ToolController>();
                tc.CurrentTool = tc.GetComponent <DefaultTool>();
            }
            else
            {
                TouchThisTool.instance.enabled = newState;
            }
        }
Exemple #6
0
    protected override void OnActivate(ToolController owner, GameObject target)
    {
        Debug.Log("Activated");
        SalvComp = target.GetComponent <Salvagable>();
        if (SalvComp.Instanced)
        {
            Rigidbody TargetRB = target.GetComponent <Rigidbody>();
            target.SetActive(false);
            GameObject NewSalvageObj = GameObject.Instantiate(SalvComp.UnInstancedPrefab);
            NewSalvageObj.transform.position = target.transform.position;
            NewSalvageObj.transform.rotation = target.transform.rotation;
            Rigidbody NewRB = NewSalvageObj.GetComponent <Rigidbody>();
            NewRB.velocity        = TargetRB.velocity;
            NewRB.angularVelocity = TargetRB.angularVelocity;
            target = NewSalvageObj;
            owner.GetComponent <Player>().SetTarget(NewSalvageObj);
            TargetRB = NewRB;
        }



        OriginalTarget   = target;
        salvageTime      = SalvComp.SalvageItem.SalvageTime;
        SalvageStartTime = Time.unscaledTime;
        if (SalvComp.SalvageItem.IsSalvage)
        {
            if (!owner.PlayerInventory.CanAddToResourceBucket(SalvComp.SalvageItem, SalvComp.Amount))
            {
                Instantiate(popText).popText.SetText(SalvComp.SalvageItem.ResourceType.DisplayName + " Full");
                Deactivate(owner, target);
                return;
            }
        }
        else
        {
            //error pop text
            Instantiate(popText).popText.SetText("Cannot Salvage");
            return;
            //Debug.Log("Could not salvage");
            //Debug.Log(SalvComp.SalvageItem + " is not a resource");
        }
        //EVAN: Start the salvage sound
        AkSoundEngine.PostEvent("SFX_Debris_Select", target);
    }
Exemple #7
0
        void AddTool <T>(ToolController toolController) where T : ToolBase
        {
            if (toolController.GetComponent <T>() != null)
            {
                return;
            }

            toolController.gameObject.AddComponent <T>();

            // contributed by Japa
            FieldInfo toolControllerField = typeof(ToolController).GetField("m_tools", BindingFlags.Instance | BindingFlags.NonPublic);

            if (toolControllerField != null)
            {
                toolControllerField.SetValue(toolController, toolController.GetComponents <ToolBase>());
            }
            FieldInfo toolModifierDictionary = typeof(ToolsModifierControl).GetField("m_Tools", BindingFlags.Static | BindingFlags.NonPublic);

            if (toolModifierDictionary != null)
            {
                toolModifierDictionary.SetValue(null, null); // to force a refresh
            }
        }
Exemple #8
0
 protected override void OnSelect(ToolController owner)
 {
     HoldPos         = owner.GetComponent <Player>().ObjectHoldPosition;
     OwnerRB         = owner.GetComponent <Rigidbody>();
     LastPressedTime = Time.unscaledTime;
 }
 public static ToolBase GetTool(this ToolController toolController, Type toolType)
 {
     return((ToolBase)toolController.GetComponent(toolType));
 }
Exemple #10
0
        public void CancelLaneSelect()
        {
            ToolController toolController = GameObject.FindObjectOfType <ToolController>();

            toolController.CurrentTool = toolController.GetComponent <DefaultTool>();
        }
Exemple #11
0
 protected override void OnSelect(ToolController owner)
 {
     Debug.Log("Repair Tool Selected");
     inventoryComponent = owner.GetComponent <ResourceInventory>();
 }
Exemple #12
0
        internal static void Toggle()
        {
            float alpha    = 0f;
            var   settings = CSL_HideSelectors.Settings;

            ToolController toolController = ToolsModifierControl.toolController;

            GameObject.Find("CursorInfo").GetComponent <UILabel>().opacity = settings.TooltipMode == (int)TooltipMode.Invisible ? 0f : settings.TooltipMode == (int)TooltipMode.Visible ? 1f : alpha;

            if (CSL_HideSelectors.isVisible || (toolController.m_validColor.a != 0f))
            {
                // If isVisible == false but m_validcolor isn't zero, TransparentSelectors' options have been modified so selectors have been re-enabled

                CSL_HideSelectors.oldAlpha  = toolController.m_validColor.a;
                CSL_HideSelectors.isVisible = false;
            }
            else
            {
                alpha = CSL_HideSelectors.oldAlpha;
                CSL_HideSelectors.isVisible = true;
            }

            toolController.m_errorColor.a         = toolController.m_errorColorInfo.a =
                toolController.m_warningColor.a   = toolController.m_warningColorInfo.a =
                    toolController.m_validColor.a = toolController.m_validColorInfo.a = alpha;

            try
            {
                Color oldColor; Color newColor; FieldInfo field;

                field = Type.GetType("MoveIt.MoveItTool, MoveIt").GetField("m_hoverColor", BindingFlags.NonPublic | BindingFlags.Static);
                if (field == null)
                {
                    goto Prop_Line_Tool;
                }
                oldColor = (Color)field.GetValue(null);
                newColor = new Color(oldColor.r, oldColor.g, oldColor.b, alpha);
                field.SetValue(null, newColor);

                field = Type.GetType("MoveIt.MoveItTool, MoveIt").GetField("m_moveColor", BindingFlags.NonPublic | BindingFlags.Static);
                if (field == null)
                {
                    goto Prop_Line_Tool;
                }
                oldColor = (Color)field.GetValue(null);
                newColor = new Color(oldColor.r, oldColor.g, oldColor.b, alpha);
                field.SetValue(null, newColor);

                field = Type.GetType("MoveIt.MoveItTool, MoveIt").GetField("m_selectedColor", BindingFlags.NonPublic | BindingFlags.Static);
                if (field == null)
                {
                    goto Prop_Line_Tool;
                }
                oldColor = (Color)field.GetValue(null);
                newColor = new Color(oldColor.r, oldColor.g, oldColor.b, alpha);
                field.SetValue(null, newColor);
            }

            catch (Exception exception)
            {
                Debug.Log($"[{CSL_HideSelectors.m_name}]: {exception}");
            }

Prop_Line_Tool:
            try
            {
                Type propLineTool = Type.GetType("PropLineTool.PropLineTool, PropLineTool_v1");
                if (propLineTool == null)
                {
                    return;
                }
                FieldInfo field     = propLineTool.GetField("m_PLTColor_default", BindingFlags.Public | BindingFlags.Instance);
                object    component = toolController.GetComponent(propLineTool); //this time it's an instance field, so we need to get a reference to the instance of PropLineTool.
                Color     oldColor  = (Color)field.GetValue(component);          //then we get the value from the instance
                Color     newColor  = new Color(oldColor.r, oldColor.g, oldColor.b, alpha);
                field.SetValue(component, newColor);
            }
            catch (Exception exception)
            {
                Debug.Log($"[{CSL_HideSelectors.m_name}]: {exception}");
            }
        }