public void Deserialize(MemoryStream ms) { ms.ReadString(out name); ms.Read(out position); ms.ReadFloat(out speed); int t_flags; ms.ReadInt(out t_flags); flags = (SpaceshipFlags)t_flags; }
public Spaceship(IMyGridTerminalSystem system, IMyIntergridCommunicationSystem igc) { this.system = system; this.igc = igc; cpu = FindRunningPB(system); control = FindBlockOfType <IMyRemoteControl>(system, this, Settings.TAG); connector = FindBlockOfType <IMyShipConnector>(system, this, Settings.TAG); debug = FindBlockOfType <IMyTextPanel>(system, this, Settings.TAG); if (debug == null) { IMyCockpit cockpit = FindBlockOfType <IMyCockpit>(system, this, Settings.TAG); if (cockpit.SurfaceCount > 0) { debug = cockpit.GetSurface(0); } } debug.Font = "Monospace"; debug.ContentType = ContentType.TEXT_AND_IMAGE; /* * screen = cockpit.GetSurface(0); * screen.ContentType = ContentType.SCRIPT; * MySpriteDrawFrame frame = screen.DrawFrame(); * * * frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(0, 0), new Vector2(512, 512), Color.Black)); * frame.Add(MySprite.CreateText("Ftiaxe Me!!!", "DEBUG", Color.White)); * frame.Dispose(); */ listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL); listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL); listener.SetMessageCallback(Settings.COMM_CHANNEL); thrusters = new ThrustersManager(this, control, system); autopilot = new Autopilot(this, control, FindBlockOfType <IMyGyro>(system, this)); cas = new CollisionAvoidanceSystem(this); fd = new FlightDirector(this); if (connector.Status == MyShipConnectorStatus.Connected) { flags = SpaceshipFlags.Dock; } else { flags = SpaceshipFlags.Idle; } }
public void Deserialize(MemoryStream ms) { debug.WriteText("Reading\n"); int destinations_total; ms.ReadInt(out destinations_total); debug.WriteText(destinations_total.ToString() + "\n"); for (int i = 0; i < destinations_total; i++) { var destination = new Destination(); destination.Deserialize(ms); debug.WriteText(string.Format("DestinationID {0}\n", destination.id), true); destinations.Add(destination.id, destination); } tasks.Deserialize(ms); fd.Deserialize(ms); long temp_flags; ms.ReadLong(out temp_flags); flags = (SpaceshipFlags)temp_flags; bool temp_is_enabled; ms.ReadBool(out temp_is_enabled); if (temp_is_enabled) { Enable(); } }