Beispiel #1
0
 // Function from file: containment_field.dm
 public bool set_master(Obj_Machinery_Field_Generator master1 = null, dynamic master2 = null)
 {
     if (!(master1 != null) || !Lang13.Bool(master2))
     {
         return(false);
     }
     this.FG1 = master1;
     this.FG2 = master2;
     return(true);
 }
Beispiel #2
0
        // Function from file: field_generator.dm
        public bool draw_power(double?draw = null, int?failsafe = null, Obj_Machinery_Field_Generator G = null, Obj_Machinery_Field_Generator last = null)
        {
            draw     = draw ?? 0;
            failsafe = failsafe ?? 0;

            Obj_Machinery_Field_Generator FG = null;


            if (this.Varpower)
            {
                return(true);
            }

            if (G != null && G == this || (failsafe ?? 0) >= 8)
            {
                return(false);
            }
            else
            {
                failsafe++;
            }

            if ((this.power ?? 0) >= (draw ?? 0))
            {
                this.power -= draw ?? 0;
                return(true);
            }
            else
            {
                draw      -= this.power ?? 0;
                this.power = 0;

                foreach (dynamic _a in Lang13.Enumerate(this.connected_gens, typeof(Obj_Machinery_Field_Generator)))
                {
                    FG = _a;


                    if (FG == null)
                    {
                        continue;
                    }

                    if (FG == last)
                    {
                        continue;
                    }

                    if (G != null)
                    {
                        if (FG.draw_power(draw, failsafe, G, this))
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else if (FG.draw_power(draw, failsafe, this, this))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }
Beispiel #3
0
        // Function from file: field_generator.dm
        public void cleanup(  )
        {
            Obj_Machinery_Field_Containment F  = null;
            Obj_Machinery_Field_Generator   FG = null;
            bool            temp = false;
            Obj_Singularity O    = null;

            this.clean_up = true;

            foreach (dynamic _a in Lang13.Enumerate(this.fields, typeof(Obj_Machinery_Field_Containment)))
            {
                F = _a;


                if (F == null)
                {
                    continue;
                }
                GlobalFuncs.qdel(F);
            }
            this.fields = new ByTable();

            foreach (dynamic _b in Lang13.Enumerate(this.connected_gens, typeof(Obj_Machinery_Field_Generator)))
            {
                FG = _b;


                if (FG == null)
                {
                    continue;
                }
                FG.connected_gens.Remove(this);

                if (!FG.clean_up)
                {
                    FG.cleanup();
                }
                this.connected_gens.Remove(FG);
            }
            this.connected_gens = new ByTable();
            this.clean_up       = false;
            this.update_icon();
            Task13.Schedule(1, (Task13.Closure)(() => {
                temp = true;

                foreach (dynamic _c in Lang13.Enumerate(typeof(Game13), typeof(Obj_Singularity)))
                {
                    O = _c;


                    if (O.last_warning != 0 && temp)
                    {
                        if (Game13.time - O.last_warning > 50)
                        {
                            temp = false;
                            GlobalFuncs.message_admins("A singulo exists and a containment field has failed.");
                            this.investigate_log("has <font color='red'>failed</font> whilst a singulo exists.", "singulo");
                        }
                    }
                    O.last_warning = Game13.time;
                }
                return;
            }));
            return;
        }
Beispiel #4
0
        // Function from file: field_generator.dm
        public bool setup_field(int NSEW = 0)
        {
            Ent_Static T         = null;
            dynamic    G         = null;
            int?       steps     = null;
            int?       dist      = null;
            Ent_Static A         = null;
            int?       dist2     = null;
            int        field_dir = 0;
            Obj_Machinery_Field_Containment CF = null;
            Mob_Living L                      = null;
            bool       listcheck              = false;
            Obj_Machinery_Field_Generator FG  = null;
            Obj_Machinery_Field_Generator FG2 = null;

            T     = this.loc;
            steps = 0;

            if (!(NSEW != 0))
            {
                return(false);
            }
            dist = null;
            dist = 0;

            while ((dist ?? 0) <= 9)
            {
                T = Map13.GetStep(T, NSEW);

                if (T.density)
                {
                    return(false);
                }

                foreach (dynamic _a in Lang13.Enumerate(T.contents, typeof(Ent_Static)))
                {
                    A = _a;


                    if (A is Mob)
                    {
                        continue;
                    }

                    if (!(A is Obj_Machinery_Field_Generator))
                    {
                        if ((A is Obj_Machinery_Door || A is Obj_Machinery_TheSingularitygen) && A.density)
                        {
                            return(false);
                        }
                    }
                }
                steps += 1;
                G      = Lang13.FindIn(typeof(Obj_Machinery_Field_Generator), T);

                if (!(G == null))
                {
                    steps -= 1;

                    if (!Lang13.Bool(G.active))
                    {
                        return(false);
                    }
                    break;
                }
                dist += 1;
            }

            if (G == null)
            {
                return(false);
            }
            T     = this.loc;
            dist2 = null;
            dist2 = 0;

            while ((dist2 ?? 0) < (steps ?? 0))
            {
                field_dir = Map13.GetDistance(T, Map13.GetStep(G.loc, NSEW));
                T         = Map13.GetStep(T, NSEW);

                if (!Lang13.Bool(Lang13.FindIn(typeof(Obj_Machinery_Field_Containment), T)))
                {
                    CF = new Obj_Machinery_Field_Containment();
                    CF.set_master(this, G);
                    this.fields.Add(CF);
                    G.fields += CF;
                    CF.loc    = T;
                    CF.dir    = field_dir;

                    foreach (dynamic _b in Lang13.Enumerate(CF.loc, typeof(Mob_Living)))
                    {
                        L = _b;

                        CF.Crossed(L);
                    }
                }
                dist2 += 1;
            }
            listcheck = false;

            foreach (dynamic _c in Lang13.Enumerate(this.connected_gens, typeof(Obj_Machinery_Field_Generator)))
            {
                FG = _c;


                if (FG == null)
                {
                    continue;
                }

                if (FG == G)
                {
                    listcheck = true;
                    break;
                }
            }

            if (!listcheck)
            {
                this.connected_gens.Add(G);
            }
            listcheck = false;

            foreach (dynamic _d in Lang13.Enumerate(G.connected_gens, typeof(Obj_Machinery_Field_Generator)))
            {
                FG2 = _d;


                if (FG2 == null)
                {
                    continue;
                }

                if (FG2 == this)
                {
                    listcheck = true;
                    break;
                }
            }

            if (!listcheck)
            {
                G.connected_gens.Add(this);
            }
            return(false);
        }