示例#1
0
        private static void ProcessSystemConstructionModules(SolarSystem system)
        {
            bool SendUpdate = GalaxyServer.Millis - system.LastStateUpdate >= SolarSystem.UPDATE_RATE;

            for (int i = system.ConstructionModules.Count - 1; i >= 0; i--)
            {
                ConstructionModule c = system.ConstructionModules[i];
                if (c.UpdateStateAndCheckIfDone(GalaxyServer.Millis))
                {
                    //If we are done, remove it and replace with a station module
                    system.ConstructionModules.RemoveAt(i);
                    system.StationModules.Add(c.ResultingStationModule);

                    ConstructionMessage cm = new ConstructionMessage();
                    cm.TimeRemaining = 0;
                    cm.Guid          = c.Guid;
                    cm.Start         = false;
                    foreach (Client client in system.Clients)
                    {
                        GalaxyServer.AddToSendQueue(client, cm);
                    }
                }
                else if (SendUpdate)
                {
                    ConstructionMessage cm = new ConstructionMessage();
                    cm.TimeRemaining = c.BuildTimeRemaining;
                    cm.Guid          = c.Guid;
                    cm.Start         = false;
                    foreach (Client client in system.Clients)
                    {
                    }
                }
            }
        }
示例#2
0
        public void HandleMessage(ConstructionMessage msg, object extra = null)
        {
            Client        client = (Client)extra;
            Player        player = client.Player;
            Assembly      a      = typeof(StationModule).Assembly;
            StationModule sm     = (StationModule)Activator.CreateInstance(a.GetType("GalaxyShared." + msg.ClassName));

            sm.SetDataFromJSON();
            if (sm.CanBuild(player))
            {
                Vector3            pos = player.Pos + Vector3.Transform(Vector3.Forward * 3, player.Rotation);
                ConstructionModule cm  = new ConstructionModule(GalaxyServer.Millis, pos, player.Rotation, new Dock());
                player.SolarSystem.ConstructionModules.Add(cm);
                msg.TimeRemaining   = cm.BuildTimeRemaining;
                msg.Guid            = cm.Guid;
                msg.ResourcesNeeded = sm.BuildRequirements;
                GalaxyServer.AddToSendQueue(client, msg);
            }
        }