コード例 #1
0
        public static void Spawn(PrefabId prefabId, Vector3 position, Quaternion rotation)
        {
            if (prefabId == BoltPrefabs.Log)
            {
                var dropItem = DropItem.Create(GlobalTargets.OnlyServer);
                dropItem.PrefabId = prefabId;
                dropItem.Position = position;
                dropItem.Rotation = rotation;
                PacketQueue.Add(dropItem);
                return;
            }

            BoltNetwork.Instantiate(prefabId, position, rotation);
        }
コード例 #2
0
ファイル: InstantBuild.cs プロジェクト: nosubtext/ModAPI-Mods
        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
            }
        }
コード例 #3
0
 public static void Execute()
 {
     if (BoltNetwork.isRunning)
     {
         foreach (var entity in BoltNetwork.entities.Where(entity => entity.isAttached))
         {
             try
             {
                 if (entity.GetComponentInChildren <Craft_Structure>())
                 {
                     // Cancel blueprints
                     var cancelBlueprint = CancelBluePrint.Create(GlobalTargets.OnlyServer);
                     cancelBlueprint.BluePrint = entity;
                     PacketQueue.Add(cancelBlueprint);
                 }
                 else if (entity.StateIs <IBuildingDestructibleState>())
                 {
                     // Destroy building
                     var destroyBuilding = DestroyBuilding.Create(GlobalTargets.OnlyServer);
                     destroyBuilding.BuildingEntity = entity;
                     PacketQueue.Add(destroyBuilding);
                 }
                 else if (entity.gameObject.GetComponentInChildren <BuildingHealthHitRelay>() ||
                          entity.gameObject.GetComponentInChildren <BuildingHealthChunkHitRelay>() ||
                          entity.gameObject.GetComponentInChildren <FoundationChunkTier>() ||
                          entity.gameObject.GetComponentInChildren <BuildingHealth>())
                 {
                     entity.gameObject.SendMessage("LocalizedHit", new LocalizedHitData(entity.gameObject.transform.position, 10000f));
                 }
             }
             catch (Exception)
             {
                 // ignored
             }
         }
     }
 }
コード例 #4
0
ファイル: DestroyTrees.cs プロジェクト: nosubtext/ModAPI-Mods
 public static void Execute()
 {
     if (BoltNetwork.isRunning)
     {
         // Destroy all trees
         foreach (var tree in UnityEngine.Object.FindObjectsOfType <TreeHealth>())
         {
             var entity = tree.LodTree.GetComponent <BoltEntity>();
             //if (entity.isAttached)
             {
                 try
                 {
                     var destroyTree = DestroyTree.Create(GlobalTargets.OnlyServer);
                     destroyTree.Tree = entity;
                     PacketQueue.Add(destroyTree);
                 }
                 catch (Exception)
                 {
                     // ignored
                 }
             }
         }
     }
 }
コード例 #5
0
 public void Send(int type, byte[] data)
 {
     pinnedForSending.Add(new FlowPacket(type, data));
 }
コード例 #6
0
 /// <summary>
 /// Inicia o recebimento/tratamento de requisições.
 /// </summary>
 public void Start()
 {
     this.m_Transport.SetReceiveAction((s, p) => m_PacketQueue.Add(p));
     this.m_Transport.SetDisconnectAction((s, r) => m_PacketQueue.SetDisconnected(r));
     this.m_Transport.Start();
 }