예제 #1
0
        // Function from file: species_types.dm
        public override dynamic handle_speech(dynamic message = null, Mob_Living_Carbon_Human H = null)
        {
            ByTable message_list = null;
            int     maxchanges   = 0;
            int?    i            = null;
            int     insertpos    = 0;
            string  inserttext   = null;

            message_list = GlobalFuncs.splittext(message, " ");
            maxchanges   = Num13.MaxInt(Num13.Floor(message_list.len / 1.5), 2);
            i            = null;
            i            = Rand13.Int(((int)(maxchanges / 2)), maxchanges);

            while ((i ?? 0) > 0)
            {
                insertpos  = Rand13.Int(1, message_list.len - 1);
                inserttext = message_list[insertpos];

                if (!(String13.SubStr(inserttext, Lang13.Length(inserttext) - 2, 0) == "..."))
                {
                    message_list[insertpos] = inserttext + "...";
                }

                if (Rand13.PercentChance(20) && message_list.len > 3)
                {
                    message_list.Insert(insertpos, "" + Rand13.Pick(new object [] { "BRAINS", "Brains", "Braaaiinnnsss", "BRAAAIIINNSSS" }) + "...");
                }
                i--;
            }
            return(GlobalFuncs.jointext(message_list, " "));
        }
예제 #2
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static void moveRange( ByTable L = null, dynamic fromIndex = null, dynamic toIndex = null, dynamic len = null ) {
			dynamic distance = null;
			dynamic i = null;
			dynamic i2 = null;
			if ( len == null ) {
				len = 1;
			}
			distance = Math.Abs( Lang13.Double( toIndex - fromIndex ) );
			if ( Lang13.Double( len ) >= Lang13.Double( distance ) ) {
				if ( Lang13.Double( fromIndex ) <= Lang13.Double( toIndex ) ) {
					return;
				}
				fromIndex += len;
				i = null;
				i = 0;
				while (Lang13.Double( i ) < Lang13.Double( distance )) {
					L.Insert( Lang13.Int( fromIndex ), null );
					L.Swap( Lang13.Int( fromIndex ), Lang13.Int( toIndex ) );
					L.Cut( Lang13.IntNullable( toIndex ), Lang13.Int( toIndex + 1 ) );
					i++;
				}
			} else {
				if ( Lang13.Double( fromIndex ) > Lang13.Double( toIndex ) ) {
					fromIndex += len;
				}
				i2 = null;
				i2 = 0;
				while (Lang13.Double( i2 ) < Lang13.Double( len )) {
					L.Insert( Lang13.Int( toIndex ), null );
					L.Swap( Lang13.Int( fromIndex ), Lang13.Int( toIndex ) );
					L.Cut( Lang13.IntNullable( fromIndex ), Lang13.Int( fromIndex + 1 ) );
					i2++;
				}
			}
			return;
		}
예제 #3
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static void moveElement( ByTable L = null, dynamic fromIndex = null, dynamic toIndex = null ) {
			if ( fromIndex == toIndex || fromIndex + 1 == toIndex ) {
				return;
			}
			if ( Lang13.Double( fromIndex ) > Lang13.Double( toIndex ) ) {
				fromIndex++;
			}
			L.Insert( Lang13.Int( toIndex ), null );
			L.Swap( Lang13.Int( fromIndex ), Lang13.Int( toIndex ) );
			L.Cut( Lang13.IntNullable( fromIndex ), Lang13.Int( fromIndex + 1 ) );
			return;
		}
예제 #4
0
		// Range: -1 Access: 0 Flags: ( 0, 4, 255 )
		public static Icon getFlatIcon( dynamic A = null, int? defdir = null, dynamic deficon = null, string defstate = null, int? defblend = null ) {
			Icon flat = null;
			bool noIcon = false;
			dynamic curicon = null;
			string curstate = null;
			int? curdir = null;
			int? curblend = null;
			ByTable layers = null;
			dynamic copy = null;
			dynamic process = null;
			bool pSet = false;
			int curIndex = 0;
			dynamic current = null;
			dynamic currentLayer = null;
			dynamic compare = null;
			int cmpIndex = 0;
			Icon add = null;
			int? flatX1 = null;
			int? flatX2 = null;
			int? flatY1 = null;
			int? flatY2 = null;
			int? addX1 = null;
			int? addX2 = null;
			int? addY1 = null;
			int? addY2 = null;
			dynamic I = null;
			if ( defdir == null ) {
				defdir = Lang13.IntNullable( A.dir );
			}
			if ( deficon == null ) {
				deficon = A.icon;
			}
			if ( defstate == null ) {
				defstate = A.icon_state;
			}
			if ( defblend == null ) {
				defblend = Lang13.IntNullable( A.blend_mode );
			}
			flat = new Icon( "icons/effects/effects.dmi", "nothing" );
			if ( !Lang13.Bool( A ) ) {
				return flat;
			}
			if ( Lang13.Double( A.alpha ) <= 0 ) {
				return flat;
			}
			noIcon = GlobalVars.FALSE;
			if ( Lang13.Bool( A.icon ) ) {
				curicon = A.icon;
			} else {
				curicon = deficon;
			}
			if ( !Lang13.Bool( curicon ) ) {
				noIcon = GlobalVars.TRUE;
			}
			if ( Lang13.Bool( A.icon_state ) ) {
				curstate = A.icon_state;
			} else {
				curstate = defstate;
			}
			if ( !noIcon && !Icon13.states( curicon, 0 ).contains( curstate ) ) {
				if ( Icon13.states( curicon, 0 ).contains( "" ) ) {
					curstate = "";
				} else {
					noIcon = GlobalVars.TRUE;
				}
			}
			if ( Lang13.Int( A.dir ) != 2 ) {
				curdir = Lang13.IntNullable( A.dir );
			} else {
				curdir = defdir;
			}
			if ( Lang13.Bool( A.blend_mode ) == GlobalVars.BLEND_DEFAULT ) {
				curblend = defblend;
			} else {
				curblend = Lang13.IntNullable( A.blend_mode );
			}
			layers = new ByTable();
			if ( !noIcon ) {
				copy = new Image( curicon, null, curstate, A.layer, curdir );
				copy.color = A.color;
				copy.alpha = A.alpha;
				copy.blend_mode = curblend;
				layers[copy] = A.layer;
			}
			process = A.underlays;
			pSet = false;
			curIndex = 1;
			while (GlobalVars.TRUE) {
				if ( curIndex <= Lang13.Double( process.len ) ) {
					current = process[curIndex];
					if ( !Lang13.Bool( current ) ) {
						curIndex++;
						continue;
					}
					currentLayer = current.layer;
					if ( Lang13.Double( currentLayer ) < 0 ) {
						if ( Lang13.Double( currentLayer ) <= -1000 ) {
							return flat;
						}
						if ( !pSet ) {
							currentLayer = A.layer + currentLayer / 1000;
						} else {
							currentLayer = A.layer + ( currentLayer + 1000 ) / 1000;
						}
					}
					cmpIndex = 1;
					while (cmpIndex <= layers.len) {
						compare = layers[cmpIndex];
						if ( Lang13.Double( currentLayer ) < Lang13.Double( layers[compare] ) ) {
							layers.Insert( cmpIndex, current );
							layers[current] = currentLayer;
							break;
						}
						cmpIndex++;
					}
					if ( cmpIndex > layers.len ) {
						layers[current] = currentLayer;
					}
					curIndex++;
				}
				if ( curIndex > Lang13.Double( process.len ) ) {
					if ( !pSet ) {
						curIndex = 1;
						pSet = true;
						process = A.overlays;
					} else {
						break;
					}
				}
			}
			add = null;
			flatX1 = 1;
			flatX2 = flat.Width();
			flatY1 = 1;
			flatY2 = flat.Height();
			addX1 = null;
			addX2 = null;
			addY1 = null;
			addY2 = null;
			I = null;
			foreach (dynamic _a in layers ) {
				I = _a;
				if ( Lang13.Bool( I.alpha ) == false ) {
					continue;
				}
				if ( I == copy ) {
					curblend = GlobalVars.BLEND_OVERLAY ?1:0;
					add = new Icon( I.icon, I.icon_state, Lang13.IntNullable( I.dir ) );
				} else {
					add = GlobalFuncs.getFlatIcon( new Image( I ), curdir, curicon, curstate, curblend );
				}
				addX1 = Num13.minInt( flatX1 ??0, Lang13.Int( I.pixel_x + 1 ) );
				addX2 = Num13.maxInt( flatX2 ??0, Lang13.Int( I.pixel_x + add.Width() ) );
				addY1 = Num13.minInt( flatY1 ??0, Lang13.Int( I.pixel_y + 1 ) );
				addY2 = Num13.maxInt( flatY2 ??0, Lang13.Int( I.pixel_y + add.Height() ) );
				if ( addX1 != flatX1 || addX2 != flatX2 || addY1 != flatY1 || addY2 != flatY2 ) {
					flat.Crop( ( addX1 ??0) - ( flatX1 ??0) + 1, ( addY1 ??0) - ( flatY1 ??0) + 1, ( addX2 ??0) - ( flatX1 ??0) + 1, ( addY2 ??0) - ( flatY1 ??0) + 1 );
					flatX1 = addX1;
					flatX2 = addX2;
					flatY1 = addY1;
					flatY2 = addY2;
				}
				flat.Blend( add, GlobalFuncs.blendMode2iconMode( curblend ), Lang13.IntNullable( I.pixel_x + 2 - flatX1 ), Lang13.IntNullable( I.pixel_y + 2 - flatY1 ) );
			};
			if ( Lang13.Bool( A.color ) ) {
				flat.Blend( A.color, 2 );
			}
			if ( Lang13.Double( A.alpha ) < 255 ) {
				flat.Blend( String13.color_code( 255, 255, 255, Lang13.Int( A.alpha ) ), 2 );
			}
			return new Icon( flat, "", GlobalVars.SOUTH );
		}
예제 #5
0
파일: DmmSuite.cs 프로젝트: Somnium13/SS13
        // Function from file: reader.dm
        public void parse_grid(string model = null, int xcrd = 0, double ycrd = 0, int zcrd = 0)
        {
            ByTable members            = null;
            ByTable members_attributes = null;
            double  index            = 0;
            int     old_position     = 0;
            int     dpos             = 0;
            string  full_def         = null;
            Type    atom_def         = null;
            ByTable fields           = null;
            int     variables_start  = 0;
            ByTable turfs_underlays  = null;
            dynamic instance         = null;
            Tile    crds             = null;
            int     first_turf_index = 0;
            dynamic T  = null;
            dynamic UT = null;

            members            = new ByTable();
            members_attributes = new ByTable();
            index        = 1;
            old_position = 1;

            do
            {
                dpos     = this.find_next_delimiter_position(model, old_position, ",", "{", "}");
                full_def = String13.SubStr(model, old_position, dpos);
                atom_def = Lang13.FindClass(String13.SubStr(full_def, 1, String13.FindIgnoreCase(full_def, "{", 1, 0)));
                members.Add(atom_def);
                old_position    = dpos + 1;
                fields          = new ByTable();
                variables_start = String13.FindIgnoreCase(full_def, "{", 1, 0);

                if (variables_start != 0)
                {
                    full_def = String13.SubStr(full_def, variables_start + 1, Lang13.Length(full_def));
                    fields   = this.readlist(full_def, ";");
                }
                members_attributes.len++;
                members_attributes[index++] = fields;
                Task13.Sleep(-1);
            } while (dpos != 0);
            turfs_underlays = new ByTable();
            index           = members.len;
            GlobalVars._preloader.setup(members_attributes[index]);
            instance = Lang13.FindObj(members[index]);
            crds     = Map13.GetTile(xcrd, ((int)(ycrd)), zcrd);

            if (crds != null)
            {
                instance.contents.Add(crds);
            }

            if (Lang13.Bool(GlobalVars.use_preloader) && Lang13.Bool(instance))
            {
                GlobalVars._preloader.load(instance);
            }
            members.Remove(members[index]);
            first_turf_index = 1;

            while (!Lang13.Bool(members[first_turf_index].IsSubclassOf(typeof(Tile))))
            {
                first_turf_index++;
            }
            T = this.instance_atom(members[first_turf_index], members_attributes[first_turf_index], xcrd, ycrd, zcrd);

            if (Lang13.Bool(T))
            {
                index = first_turf_index + 1;

                while (index <= members.len)
                {
                    turfs_underlays.Insert(1, new Image(T.icon, null, T.icon_state, T.layer, T.dir));
                    UT = this.instance_atom(members[index], members_attributes[index], xcrd, ycrd, zcrd);
                    this.add_underlying_turf(UT, T, turfs_underlays);
                    T = UT;
                    index++;
                }
            }

            foreach (dynamic _a in Lang13.IterateRange(1, first_turf_index - 1))
            {
                index = _a;

                this.instance_atom(members[index], members_attributes[index], xcrd, ycrd, zcrd);
            }
            return;
        }
예제 #6
0
        private void parse_grid(string model = null, int xcrd = 0, double ycrd = 0, int zcrd = 0)
        {
            ByTable members            = null;
            ByTable members_attributes = null;
            double  index            = 0;
            int     old_position     = 0;
            int     dpos             = 0;
            string  full_def         = null;
            Type    atom_def         = null;
            ByTable fields           = null;
            int     variables_start  = 0;
            ByTable turfs_underlays  = null;
            dynamic instance         = null;
            Tile    crds             = null;
            int     first_turf_index = 0;
            dynamic T  = null;
            dynamic UT = null;

            members            = new ByTable();
            members_attributes = new ByTable();
            index        = 1;
            old_position = 1;
            while (true)               // Was a do-while, sorry for the mess.
            {
                dpos     = this.find_next_delimiter_position(model, old_position, ",", "{", "}");
                full_def = String13.SubStr(model, old_position, dpos);
                string path = String13.SubStr(full_def, 1, String13.Find(full_def, "{", 1, 0));
                atom_def = Lang13.FindClass(path);
                members.Add(atom_def);
                old_position    = dpos + 1;
                fields          = new ByTable();
                variables_start = String13.Find(full_def, "{", 1, 0);
                if (variables_start != 0)
                {
                    full_def = String13.SubStr(full_def, variables_start + 1, Lang13.Length(full_def));
                    fields   = this.text2list(full_def, ";");
                }
                members_attributes.len++;
                members_attributes[index++] = fields;
                Task13.Sleep(-1);
                if (!(dpos != 0))
                {
                    break;
                }
            }

            turfs_underlays = new ByTable();
            index           = members.len;

            // Setup zone...
            GlobalVars._preloader.setup(members_attributes[index]);
            instance = Lang13.FindObj(members[index]);

            crds = Map13.GetTile(xcrd, ((int)(ycrd)), zcrd);
            if (crds != null)
            {
                instance.contents.Add(crds);
            }

            if (Lang13.Bool(GlobalVars.use_preloader) && Lang13.Bool(instance))
            {
                GlobalVars._preloader.load(instance);
            }

            members.Remove(members[index]);

            // Load tile(s?!?)
            first_turf_index = 1;
            while (members[first_turf_index] == null || !members[first_turf_index].IsSubclassOf(typeof(Tile)))
            {
                first_turf_index++;
            }

            try {
                T = this.instance_atom(members[first_turf_index], members_attributes[first_turf_index], xcrd, ycrd, zcrd);
            }
            catch (Exception e)
            {
                Logger.Error("Failed to init tile [" + members[first_turf_index] + "] at ( " + xcrd + ", " + ycrd + ", " + zcrd + " )", e);
            }

            if (Lang13.Bool(T))
            {
                index = first_turf_index + 1;
                while (index <= members.len)
                {
                    turfs_underlays.Insert(1, new Image(T.icon, null, T.icon_state, T.layer, T.dir));
                    UT = this.instance_atom(members[index], members_attributes[index], xcrd, ycrd, zcrd);
                    this.add_underlying_turf(UT, T, turfs_underlays);
                    T = UT;
                    index++;
                }
            }

            // Setup objs
            foreach (dynamic _a in Lang13.IterateRange(1, first_turf_index - 1))
            {
                index = _a;
                try {
                    this.instance_atom(members[index], members_attributes[index], xcrd, ycrd, zcrd);
                }
                catch (Exception e) {
                    Logger.Error("Failed to init object [" + members[index] + "] at ( " + xcrd + ", " + ycrd + ", " + zcrd + " )", e);
                }
            }
            return;
        }
예제 #7
0
        // Function from file: photography.dm
        public Icon camera_get_icon(ByTable turfs = null, dynamic center = null)
        {
            ByTable     atoms  = null;
            dynamic     T      = null;
            Ent_Dynamic A      = null;
            Ent_Dynamic O      = null;
            ByTable     sorted = null;
            int?        j      = null;
            double      i      = 0;
            dynamic     c      = null;
            dynamic     c2     = null;
            Icon        res    = null;
            Ent_Static  A2     = null;
            Icon        img    = null;
            double?     offX   = null;
            double?     offY   = null;
            dynamic     T2     = null;

            atoms = new ByTable();

            foreach (dynamic _b in Lang13.Enumerate(turfs))
            {
                T = _b;

                atoms.Add(T);

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


                    if (A.invisibility != 0)
                    {
                        if (this.see_ghosts)
                        {
                            if (A is Mob_Dead_Observer)
                            {
                                O = A;

                                if (Lang13.Bool(O.orbiting))
                                {
                                    continue;
                                }
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    atoms.Add(A);
                }
            }
            sorted = new ByTable();
            j      = null;

            foreach (dynamic _c in Lang13.IterateRange(1, atoms.len))
            {
                i = _c;

                c = atoms[i];
                j = sorted.len;

                while ((j ?? 0) > 0)
                {
                    c2 = sorted[j];

                    if (Convert.ToDouble(c2.layer) <= Convert.ToDouble(c.layer))
                    {
                        break;
                    }
                    j--;
                }
                sorted.Insert((j ?? 0) + 1, c);
            }
            res = new Icon("icons/effects/96x96.dmi", "");

            foreach (dynamic _d in Lang13.Enumerate(sorted, typeof(Ent_Static)))
            {
                A2 = _d;

                img = GlobalFuncs.getFlatIcon(A2);

                if (A2 is Mob_Living && Lang13.Bool(((dynamic)A2).lying))
                {
                    img.Turn(((dynamic)A2).lying);
                }
                offX = (A2.x - Convert.ToDouble(center.x)) * 32 + A2.pixel_x + 33;
                offY = (A2.y - Convert.ToDouble(center.y)) * 32 + A2.pixel_y + 33;

                if (A2 is Ent_Dynamic)
                {
                    offX += Convert.ToDouble(((dynamic)A2).step_x);
                    offY += Convert.ToDouble(((dynamic)A2).step_y);
                }
                res.Blend(img, GlobalFuncs.blendMode2iconMode(Lang13.BoolNullable(A2.blend_mode)), offX, offY);

                if (A2 is Obj_Item_Areaeditor_Blueprints)
                {
                    this.blueprints = true;
                }
            }

            foreach (dynamic _e in Lang13.Enumerate(turfs))
            {
                T2 = _e;

                res.Blend(GlobalFuncs.getFlatIcon(T2.loc), GlobalFuncs.blendMode2iconMode(Lang13.BoolNullable(T2.blend_mode)), Lang13.DoubleNullable((T2.x - center.x) * 32 + 33), Lang13.DoubleNullable((T2.y - center.y) * 32 + 33));
            }
            return(res);
        }