Ejemplo n.º 1
0
        public void Initialize(string craftingListLoc, ISS13Server server)
        {
            _serverMain = server;

            if (File.Exists(craftingListLoc))
            {
                var          ConfigLoader = new XmlSerializer(typeof(CraftRecipes));
                StreamReader ConfigReader = File.OpenText(craftingListLoc);
                var          _loaded      = (CraftRecipes)ConfigLoader.Deserialize(ConfigReader);
                ConfigReader.Close();
                recipes          = _loaded;
                craftingListFile = craftingListLoc;
                LogManager.Log("Crafting Recipes loaded. " + recipes.List.Count.ToString() + " recipe" +
                               (recipes.List.Count != 1 ? "s." : "."));
            }
            else
            {
                if (LogManager.Singleton != null)
                {
                    LogManager.Log("No Recipes found. Creating Empty List (" + craftingListLoc + ")");
                }
                recipes = new CraftRecipes();
                var dummy = new CraftingEntry();
                dummy.components.Add("Null1");
                dummy.components.Add("Null2");
                recipes.List.Add(dummy);
                craftingListFile = craftingListLoc;
                Save();
            }
        }
Ejemplo n.º 2
0
        public void BeginCrafting(Entity compo1, Entity compo2, Entity source, NetConnection sourceConnection)
        //Check for components and remove.
        {
            if (!isValidRecipe(compo1.Template.Name, compo2.Template.Name))
            {
                return;
            }
            CraftingEntry recipe    = getRecipe(compo1.Template.Name, compo2.Template.Name);
            var           newTicket = new CraftingTicket();

            if (recipe.components.Count < 2)
            {
                return;
            }

            newTicket.component1       = compo1;
            newTicket.component2       = compo2;
            newTicket.sourceEntity     = source;
            newTicket.result           = recipe.result;
            newTicket.doneAt           = DateTime.Now.AddSeconds(recipe.secondsToCreate);
            newTicket.sourceConnection = sourceConnection;

            craftingTickets.Add(newTicket);

            NetOutgoingMessage startCraftMsg = IoCManager.Resolve <ISS13NetServer>().CreateMessage();

            //Not starcraft. sorry.
            startCraftMsg.Write((byte)NetMessage.PlayerUiMessage);
            startCraftMsg.Write((byte)UiManagerMessage.ComponentMessage);
            startCraftMsg.Write((byte)GuiComponentType.ComboGui);
            startCraftMsg.Write((byte)ComboGuiMessage.ShowCraftBar);
            startCraftMsg.Write(recipe.secondsToCreate);

            _netServer.SendMessage(startCraftMsg, sourceConnection, NetDeliveryMethod.ReliableUnordered);
        }