예제 #1
0
 private void UpdateRendererColor()
 {
     if (this.MyRender)
     {
         if (this.Clear)
         {
             this.MyRender.sharedMaterial = ((!LocalPlayer.Create.CurrentBlueprint._useFlatMeshMaterial) ? this.ClearMat : this.ClearMatFlatMesh);
         }
         else
         {
             this.MyRender.sharedMaterial = this.RedMat;
         }
     }
     if (LocalPlayer.Create.CraftStructures != null)
     {
         for (int i = 0; i < LocalPlayer.Create.CraftStructures.Count; i++)
         {
             Craft_Structure craft_Structure = LocalPlayer.Create.CraftStructures[i];
             if (craft_Structure)
             {
                 if (this.Clear)
                 {
                     craft_Structure.SetGhostMaterial((!LocalPlayer.Create.CurrentBlueprint._useFlatMeshMaterial) ? this.ClearMat : this.ClearMatFlatMesh);
                 }
                 else
                 {
                     craft_Structure.SetGhostMaterial(this.RedMat);
                 }
             }
         }
     }
 }
예제 #2
0
 public static void AddBlueprintToQueue(Craft_Structure structure)
 {
     if (Instance != null && !Instance.CurrentQueue.Contains(structure) && !Instance.OverflowDictionary.ContainsKey(structure))
     {
         Instance.OverflowDictionary.Add(structure, Environment.TickCount);
         Instance.CurrentQueue.Add(structure);
     }
 }
예제 #3
0
 public override void OnEvent(CancelBluePrint evnt)
 {
     if (evnt.BluePrint)
     {
         Craft_Structure componentInChildren = evnt.BluePrint.GetComponentInChildren <Craft_Structure>();
         if (componentInChildren)
         {
             componentInChildren.CancelBlueprintSafe();
         }
     }
 }
 private void Update()
 {
     if (ModAPI.Input.GetButtonDown("BluePrint_Remove"))
     {
         Craft_Structure[] array = UnityEngine.Object.FindObjectsOfType <Craft_Structure>();
         if (array != null && array.Length > 0)
         {
             Craft_Structure[] array2 = array;
             for (int i = 0; i < array2.Length; i++)
             {
                 Craft_Structure craft_Structure = array2[i];
                 craft_Structure.CancelBlueprint();
             }
         }
     }
 }
예제 #5
0
        protected virtual IEnumerator OnTreeCutDown(GameObject trunk)
        {
            Transform fallingT;

            if (trunk.GetComponent <Rigidbody>())
            {
                fallingT = trunk.transform;
            }
            else
            {
                fallingT = trunk.GetComponentInChildren <Rigidbody>().transform;
            }
            base.transform.parent = fallingT;
            foreach (Collider collider in base.GetComponentsInChildren <Collider>())
            {
                collider.enabled = false;
            }
            if (!BoltNetwork.isClient)
            {
                yield return(YieldPresets.WaitPointHeightSeconds);
            }
            else
            {
                yield return(YieldPresets.WaitPointSixSeconds);
            }
            foreach (StructureAnchor structureAnchor in base.GetComponentsInChildren <StructureAnchor>())
            {
                UnityEngine.Object.Destroy(structureAnchor.gameObject);
            }
            Craft_Structure ghost = base.GetComponentInChildren <Craft_Structure>();

            if (ghost && ghost.transform.parent == base.transform)
            {
                if (!BoltNetwork.isClient)
                {
                    ghost.CancelBlueprintSafe();
                }
            }
            else
            {
                yield return(YieldPresets.WaitThreeSeconds);

                BuildingHealth bh = base.GetComponent <BuildingHealth>();
                bh.Collapse(base.transform.position + Vector3.down);
            }
            yield break;
        }
예제 #6
0
        private void MakeComplete(Craft_Structure structure)
        {
            try
            {
                if (structure._requiredIngredients.Count <= 0)
                {
                    return;
                }

                for (int i = 0; i < structure._requiredIngredients.Count; ++i)
                {
                    Craft_Structure.BuildIngredients buildIngredients = structure._requiredIngredients[i];
                    if (structure.GetPresentIngredients().Length <= i)
                    {
                        continue;
                    }

                    ReceipeIngredient receipeIngredient = structure.GetPresentIngredients()[i];
                    if (receipeIngredient._amount >= buildIngredients._amount)
                    {
                        continue;
                    }

                    for (int j = 0; j < buildIngredients._amount - receipeIngredient._amount; j++)
                    {
                        if (BoltNetwork.isRunning)
                        {
                            AddIngredient ingredient = AddIngredient.Create(GlobalTargets.OnlyServer);
                            ingredient.IngredientNum = i;
                            ingredient.ItemId        = buildIngredients._itemID;
                            ingredient.Construction  = structure.entity;
                            ingredient.Send();
                        }
                        else
                        {
                            structure.AddIngrendient_Actual(i, true);
                        }

                        SleepFor(0.300f);
                    }

                    SleepFor(0.300f);
                }
            }
            catch
            { }
        }
예제 #7
0
        protected override IEnumerator OnTreeCutDown(GameObject trunk)
        {
            Transform fallingT;

            if (trunk.GetComponent <Rigidbody>())
            {
                fallingT = trunk.transform;
            }
            else
            {
                fallingT = trunk.GetComponentInChildren <Rigidbody>().transform;
            }
            base.transform.parent = fallingT;
            foreach (Collider collider in base.GetComponentsInChildren <Collider>())
            {
                collider.enabled = false;
            }
            if (!BoltNetwork.isClient)
            {
                yield return(YieldPresets.WaitPointHeightSeconds);
            }
            else
            {
                yield return(YieldPresets.WaitPointSixSeconds);
            }
            Craft_Structure ghost = base.GetComponentInChildren <Craft_Structure>();

            if (ghost && ghost.transform.parent == base.transform)
            {
                if (!BoltNetwork.isClient)
                {
                    ghost.CancelBlueprintSafe();
                }
            }
            else
            {
                yield return(YieldPresets.WaitThreeSeconds);

                CollapseStructure cs = base.gameObject.AddComponent <CollapseStructure>();
                cs._destructionForceMultiplier = 0.1f;
                cs._capsuleDirection           = CapsuleDirections.Z;
            }
            yield break;
        }
예제 #8
0
        public static void InstantlyFinishBlueprint(Craft_Structure structure)
        {
            try
            {
                if (structure._requiredIngredients.Count > 0)
                {
                    for (var itemNumber = 0; itemNumber < structure._requiredIngredients.Count; itemNumber++)
                    {
                        var requiredItems = structure._requiredIngredients[itemNumber];
                        if (structure.GetPresentIngredients().Length > itemNumber)
                        {
                            var presentItems = structure.GetPresentIngredients()[itemNumber];

                            if (presentItems._amount >= requiredItems._amount)
                            {
                                continue;
                            }

                            for (var i = 0; i < requiredItems._amount - presentItems._amount; i++)
                            {
                                if (BoltNetwork.isRunning)
                                {
                                    var addIngredient = AddIngredient.Create(GlobalTargets.OnlyServer);
                                    addIngredient.IngredientNum = itemNumber;
                                    addIngredient.ItemId        = requiredItems._itemID;
                                    addIngredient.Construction  = structure.entity;
                                    PacketQueue.Add(addIngredient);
                                }
                                else
                                {
                                    structure.AddIngrendient_Actual(itemNumber, true);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                // ignored
            }
        }
예제 #9
0
 public static void InstantBuilder(Craft_Structure structure)
 {
     try
     {
         if (structure._requiredIngredients.Count > 0)
         {
             for (int i = 0; i < structure._requiredIngredients.Count; i++)
             {
                 Craft_Structure.BuildIngredients buildIngredients = structure._requiredIngredients[i];
                 if (structure.GetPresentIngredients().Length > i)
                 {
                     ReceipeIngredient receipeIngredient = structure.GetPresentIngredients()[i];
                     if (receipeIngredient._amount < buildIngredients._amount)
                     {
                         for (int j = 0; j < buildIngredients._amount - receipeIngredient._amount; j++)
                         {
                             if (BoltNetwork.isRunning)
                             {
                                 AddIngredient ingredient = AddIngredient.Create(GlobalTargets.OnlyServer);
                                 ingredient.IngredientNum = i;
                                 ingredient.ItemId        = buildIngredients._itemID;
                                 ingredient.Construction  = structure.entity;
                                 ingredient.Send();
                             }
                             else
                             {
                                 structure.AddIngrendient_Actual(i, true, null);
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (System.Exception)
     {
     }
 }