/*! \brief Write the template data into the buffer. * \param [in] buffer Pointer to the buffer to write the template to. * \param [in] offset The offset from the start of the buffer where the gadget * will be written. * \param [in,out] strOffset The offset from the start of the template where the * next string should be written in the string table. Updated after each string * is written. * \param [in,out] msgOffset The offset from the start of the template where the * next string should be written in the message table. Updated after each string * is written. * \return Nothing. */ public virtual void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.Flags, (int)_flags); Marshal.WriteInt16(buffer, offset + GadgetTemplateOffset.Type, (short)Type); Marshal.WriteInt16(buffer, offset + GadgetTemplateOffset.Size, (short)GetTemplateSize()); Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.MinX, _bounding_box.MinX); Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.MinY, _bounding_box.MinY); Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.MaxX, _bounding_box.MaxX); Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.MaxY, _bounding_box.MaxY); Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.ComponentID, (int)_component_id); msgOffset = ObjectTemplate.WriteString(_help_message, _max_help, buffer, offset + GadgetTemplateOffset.HelpMessage, msgOffset); Marshal.WriteInt32(buffer, offset + GadgetTemplateOffset.MaxHelp, string.IsNullOrEmpty(_help_message) ? 0 : Math.Max(_help_message.Length + 1, _max_help)); }
public void Save(string levelName) { SaveTemplate temp = new SaveTemplate(); int size =Instances.gridManager.size; temp.gridSize = size; temp.levelName = levelName; temp.objects = new List<ObjectTemplate>(); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { GameObject g = Instances.gridManager.getObject(new Vector2(i,j)); if( g != null) { ObjectTemplate t = new ObjectTemplate(); t.name = g.name; t.x = i; t.y = j; t.rot = Mathf.RoundToInt(g.transform.rotation.eulerAngles.y); temp.objects.Add(t); } } } SavedGameContainer s = new SavedGameContainer(); s.savedTemplate=temp; s.Save("Assets/Resources/Saved Data/"+levelName+".xml"); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); msgOffset = ObjectTemplate.WriteString(_text, _max_text_len, buffer, offset + ActionButtonTemplateOffset.Text, msgOffset); Marshal.WriteInt32(buffer, offset + ActionButtonTemplateOffset.MaxTextLen, string.IsNullOrEmpty(_text) ? 0 : Math.Max(_text.Length + 1, _max_text_len)); strOffset = ObjectTemplate.WriteString(_click_show, 0, buffer, offset + ActionButtonTemplateOffset.ClickShow, strOffset); Marshal.WriteInt32(buffer, offset + ActionButtonTemplateOffset.Event, (int)_event); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); msgOffset = ObjectTemplate.WriteString(_text, _max_text_len, buffer, offset + WritableFieldTemplateOffset.Text, msgOffset); Marshal.WriteInt32(buffer, offset + WritableFieldTemplateOffset.MaxTextLen, Math.Max(_text.Length + 1, _max_text_len)); msgOffset = ObjectTemplate.WriteString(_allowable, _max_allowable_len, buffer, offset + WritableFieldTemplateOffset.Allowable, msgOffset); Marshal.WriteInt32(buffer, offset + WritableFieldTemplateOffset.MaxAllowableLen, Math.Max(_allowable.Length + 1, _max_allowable_len)); Marshal.WriteInt32(buffer, offset + WritableFieldTemplateOffset.Before, _before); Marshal.WriteInt32(buffer, offset + WritableFieldTemplateOffset.After, _after); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); Marshal.WriteInt32(buffer, offset + ButtonTemplateOffset.ButtonFlags, ButtonFlags); msgOffset = ObjectTemplate.WriteString(_text, _max_text_len, buffer, offset + ButtonTemplateOffset.Text, msgOffset); Marshal.WriteInt32(buffer, offset + ButtonTemplateOffset.MaxTextLen, Math.Max(_text.Length + 1, _max_text_len)); strOffset = ObjectTemplate.WriteString(_validation, _max_validation_len, buffer, offset + ButtonTemplateOffset.Validation, strOffset); Marshal.WriteInt32(buffer, offset + ButtonTemplateOffset.MaxValidation, Math.Max(_validation.Length + 1, _max_validation_len)); }
public void FinalizeDataHolder() { QuestTemplate template = QuestMgr.GetTemplate(QuestId); if (template == null) { ContentMgr.OnInvalidDBData( GetType().Name + " (QuestGiverId: {0}) referred to invalid QuestId: " + QuestId, (object)QuestGiverId); } else { ObjectTemplate objectTemplate = ObjectTemplate; if (objectTemplate == null) { ContentMgr.OnInvalidDBData( GetType().Name + " (QuestId: {0}) referred to invalid QuestGiverId: " + QuestGiverId, (object)QuestId); } else { QuestHolderInfo questHolderInfo = objectTemplate.QuestHolderInfo; bool flag = questHolderInfo == null; if (flag) { objectTemplate.QuestHolderInfo = questHolderInfo = new QuestHolderInfo(); } switch (RelationType) { case QuestGiverRelationType.Starter: questHolderInfo.QuestStarts.Add(template); template.Starters.Add(objectTemplate); if (!flag) { break; } ++QuestMgr._questStarterCount; break; case QuestGiverRelationType.Finisher: questHolderInfo.QuestEnds.Add(template); template.Finishers.Add(objectTemplate); if (!flag) { break; } ++QuestMgr._questFinisherCount; break; default: ContentMgr.OnInvalidDBData( GetType().Name + " (Quest: {0}, QuestGiver: {1}) had invalid QuestGiverRelationType: " + RelationType, (object)QuestId, (object)QuestGiverId); break; } } } }
public static void SetExtraFlags(this ObjectTemplate template) { var words = template.Flags.Split(' '); foreach (var word in words) { template.ExtraFlags.SetBit((int)EnumerationExtensions.GetEnum <ItemExtraFlags>(word)); } }
private void AddResource(ResourceType type, ObjectTemplate template) { type.Info.Count++; var resource = type.GetResource(template); Point position = new Point(resource.X, resource.Y); UpdateTileInfo(position, info.ResourceRadiusNear, type.Info.NearInfo); UpdateTileInfo(position, info.ResourceRadiusFar, type.Info.FarInfo); }
public static IEnumerable <WearLocations> GetWearFlags(this ObjectTemplate template) { if (template.WearFlags.IsNullOrEmpty()) { return(new List <WearLocations>()); } var words = template.WearFlags.Split(' '); return(words.Select(EnumerationExtensions.GetEnum <WearLocations>).ToList()); }
private VillageTemplate CreateVillageTemplate(ObjectTemplate template) { VillageTemplate village = new VillageTemplate(template); village.SmallFlag = smallFlag.GetResource(template, "Small"); village.LargeFlag = largeFlag.GetResource(template, "Large"); village.SmallFuelDepot = smallFuelDepot.GetResource(template, "Small") ?? smallFuelDepot.GetResource(template, "Medium"); village.LargeFuelDepot = largeFuelDepot.GetResource(template, "Large"); return(village); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); strOffset = ObjectTemplate.WriteString(_menu, 0, buffer, offset + PopupMenuTemplateOffset.Menu, strOffset); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); msgOffset = ObjectTemplate.WriteString(_label, 0, buffer, offset + LabelTemplateOffset.Label, msgOffset); }
private void GenerateDataClass(XmlClassItem item, ObjectType type) { string data; if (!string.IsNullOrEmpty(item.switchEnum)) { data = new MutableObjectTemplate(item, _schema, type).TransformText(); } else { data = new ObjectTemplate(item, _schema, type).TransformText(); } _codeWriter.Write(Utils.ClassesNamespace, item.name, data); }
private void ReadObjectTemplates(BinaryReader reader) { uint templateCount = reader.ReadUInt32(); Console.WriteLine("ReadObjectTemplates totally:" + templateCount); this.mapObject.ObjectTemplates = new List <ObjectTemplate>((int)templateCount); // Read custom defs for (int idd = 0; idd < templateCount; ++idd) { ObjectTemplate objectTemplate = new ObjectTemplate(); objectTemplate.AnimationFile = reader.ReadStringWithLength(); Console.WriteLine("Object Animation File:" + objectTemplate.AnimationFile); int[] blockMask = new int[6]; int[] visitMask = new int[6]; foreach (int val in blockMask) { int r = reader.ReadByte(); //Console.WriteLine("BlockMask: " + r); } foreach (int val in visitMask) { int r = reader.ReadByte(); //Console.WriteLine("VisitMask: " + r); } reader.ReadUInt16(); int terrMask = reader.ReadUInt16(); objectTemplate.Type = (EObjectType)reader.ReadUInt32(); objectTemplate.SubId = (int)reader.ReadUInt32(); Console.WriteLine(string.Format("Object Type: {0} SubId: {1}", objectTemplate.Type, objectTemplate.SubId)); // This type is not the template type, used in isOnVisitableFromTopList int type = reader.ReadByte(); int printPriority = reader.ReadByte() * 100; reader.Skip(16); this.mapObject.ObjectTemplates.Add(objectTemplate); } }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); msgOffset = ObjectTemplate.WriteString(_text, _max_text_len, buffer, offset + DisplayFieldTemplateOffset.Text, msgOffset); Marshal.WriteInt32(buffer, offset + DisplayFieldTemplateOffset.MaxTextLen, Math.Max(_text.Length + 1, _max_text_len)); }
/*! \brief Write the keyboard shortcut template data into the buffer. * \param [in] buffer Pointer to the buffer to write the template to. * \param [in] offset The offset from the start of the buffer where the keyboard * shortcut will be written. * \param [in,out] strOffset The offset from the start of the template where the * next string should be written in the string table. Updated after each string * is written. * \return Nothing. */ public void BuildBuffer(IntPtr buffer, int offset, ref int strOffset) { Marshal.WriteInt32(buffer, offset + KeyboardShortcutTemplateOffset.Flags, (int)_flags); Marshal.WriteInt32(buffer, offset + KeyboardShortcutTemplateOffset.WimpKeyCode, _wimp_key_code); Marshal.WriteInt32(buffer, offset + KeyboardShortcutTemplateOffset.KeyEvent, (int)_key_event); strOffset = ObjectTemplate.WriteString(_key_show, 0, buffer, offset + KeyboardShortcutTemplateOffset.KeyShow, strOffset); }
private void RegisterObject(Type type) { var properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance) .Except(type.GetDefaultMembers().OfType <PropertyInfo>()); var toString = type.GetMethod("ToString", Array.Empty <Type>())?.DeclaringType == type; var list = properties .Where(p => p.GetGetMethod() != null) .Select(p => new PropertyTemplate(p.Name, p.PropertyType, p.GetGetMethod() !, p.GetSetMethod())) .OrderBy(x => x.Setter == null ? 1 : 0) .ThenBy(x => x.Name) .ToArray(); var template = new ObjectTemplate(type, toString, list); this.Templates.Add(type, template); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); msgOffset = ObjectTemplate.WriteString(_label, _max_label_len, buffer, offset + OptionButtonTemplateOffset.Label, msgOffset); Marshal.WriteInt32(buffer, offset + OptionButtonTemplateOffset.MaxLabelLen, string.IsNullOrEmpty(_label) ? 0 : Math.Max(_label.Length + 1, _max_label_len)); Marshal.WriteInt32(buffer, offset + OptionButtonTemplateOffset.Event, (int)_event); }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); msgOffset = ObjectTemplate.WriteString(_string_set, 0, buffer, offset + StringSetTemplateOffset.StringSet, msgOffset); msgOffset = ObjectTemplate.WriteString(_menu_title, 0, buffer, offset + StringSetTemplateOffset.MenuTitle, msgOffset); msgOffset = ObjectTemplate.WriteString(_initial_selected_string, _max_selected_string_len, buffer, offset + StringSetTemplateOffset.InitialSelectedString, msgOffset); Marshal.WriteInt32(buffer, offset + StringSetTemplateOffset.MaxSelectedStringLen, Math.Max(_initial_selected_string.Length + 1, _max_selected_string_len)); msgOffset = ObjectTemplate.WriteString(_allowable, _max_allowable, buffer, offset + StringSetTemplateOffset.Allowable, msgOffset); Marshal.WriteInt32(buffer, offset + StringSetTemplateOffset.MaxAllowable, Math.Max(_allowable.Length + 1, _max_allowable)); Marshal.WriteInt32(buffer, offset + StringSetTemplateOffset.Before, _before); Marshal.WriteInt32(buffer, offset + StringSetTemplateOffset.After, _after); }
private void mnuAddFCTemplate_Click(object sender, EventArgs e) { TreeNode pNode = trvDatabase.SelectedNode; if (pNode.Level != 2) { return; } ITemplateDatabase templateDatabase = pNode.Parent.Tag as ITemplateDatabase; frmEditTemplate frm = new frmEditTemplate(); IObjectTemplate template = new ObjectTemplate(); template.Database = templateDatabase; frm.SetTemplate(template); DialogResult result = frm.ShowDialog(); if (result == DialogResult.OK) { pNode.Nodes.Clear(); LoadTemplates(templateDatabase, pNode); } }
public override void BuildBuffer(IntPtr buffer, int offset, ref int strOffset, ref int msgOffset) { base.BuildBuffer(buffer, offset, ref strOffset, ref msgOffset); if (HasSprite) { strOffset = ObjectTemplate.WriteString(_label, 0, buffer, offset + LabelledBoxTemplateOffset.Label, strOffset); } else { msgOffset = ObjectTemplate.WriteString(_label, 0, buffer, offset + LabelledBoxTemplateOffset.Label, msgOffset); } }
internal bool MergeProcedure(Procedure obj, PatternInstanceElement c, UpdateObject uo, ObjectTemplate t) { int saveObject = 0; bool overwrite = (uo == UpdateObject.OverWrite ? true : false); saveObject += MergeVariables(obj.Variables, c, t.Variables, overwrite); saveObject += MergeConditions(obj.Conditions, c, t.Conditons, overwrite); saveObject += MergeRules(obj.Rules, c, t.Rules, overwrite); saveObject += MergeProcedureSource(obj.ProcedurePart, c, t.Source, overwrite); return saveObject > 0; }
public ScriptObject GetResource(ObjectTemplate template, string typeFilter = null) { var resource = template.Objects.FirstOrDefault(o => Info.Name.Equals(o.GetPropertyValue <string>(objectName)) && (typeFilter == null || o.Type.ToLower().Contains(typeFilter.ToLower()))); return(resource); }
internal bool MergeWebPanel(WebPanel obj, PatternInstanceElement c, UpdateObject uo, ObjectTemplate t) { int saveObject = 0; bool overwrite = (uo == UpdateObject.OverWrite ? true : false); saveObject += MergeVariables(obj.Variables, c, t.Variables, overwrite); saveObject += MergeConditions(obj.Conditions, c, t.Conditons, overwrite); if (uo != UpdateObject.OnlySource) { saveObject += MergeWebForm(obj.WebForm, c, t.WebForm, overwrite); } saveObject += MergeRules(obj.Rules, c, t.Rules, overwrite); saveObject += MergeEvents(obj.Events, c, t.Events, overwrite); saveObject += t.DeleteVariables(c, obj, overwrite); return saveObject > 0; }
private void AddTemplateToMap(ObjectTemplate template, Point position) { info.ObjectFactory.AddTemplateToMap(template, map, info, TileInfo.Structure, position, (float)(random.NextDouble() * System.Math.PI * 2), info.Settings.Scenery.Road); }
public static ObjectInstance get_obj_room(ObjectTemplate pObjIndex, RoomTemplate pRoomIndex) { // TODO return(null); }
public VillageTemplate(ObjectTemplate template) { Template = template; IsInstantiated = false; }
public static int generate_itemlevel(AreaData pArea, ObjectTemplate pObjIndex) { // TODO return(0); }
public void AddToHistory(ObjectTemplate template) { History.ToList().Add(template); }
internal bool MergeDataProvider(DataProvider obj, PatternInstanceElement c, UpdateObject uo, ObjectTemplate t) { int saveObject = 0; bool overwrite = (uo == UpdateObject.OverWrite ? true : false); saveObject += MergeVariables(obj.Variables, c, t.Variables, overwrite); saveObject += MergeRules(obj.Rules, c, t.Rules, overwrite); saveObject += MergeDataProviderSource(obj.DataProviderSource, c, t.Source, overwrite); return saveObject > 0; }
public static int count_obj_list(ObjectTemplate pObjIndex, List <ObjectInstance> list) { // TODO return(0); }
internal bool MergeSDT(SDT obj, PatternInstanceElement c, UpdateObject uo, ObjectTemplate t) { int saveObject = 0; bool overwrite = (uo == UpdateObject.OverWrite ? true : false); saveObject += MergeSDTStructure(obj.SDTStructure, c, t.Source, overwrite); return saveObject > 0; }
public static ObjectInstance get_obj_type(ObjectTemplate pObjIndex) { // TODO return(null); }
public virtual void ObjectTileEntered(ObjectTemplate enteredObject) { }
/// <summary> /// Invokes the method to create the build object /// </summary> public override void PostCreate( ) { BuildObject = new ObjectTemplate( m_Type, "" ); base.PostCreate( ); }
private void ReadObjects(BinaryReader reader) { int objectCount = (int)reader.ReadUInt32(); Console.WriteLine(string.Format("Totally {0} objects.", objectCount)); this.mapObject.Objects = new List <CGObject>(objectCount); for (int ww = 0; ww < objectCount; ww++) { int objectId = this.mapObject.Objects.Count(); /* * if (objectId >= 2351) * { * for (int i = 0; i < 20; i++) * { * byte[] data = reader.ReadBytes(10); * Console.WriteLine(StringUtils.ByteArrayToString(data)); * } * * reader.BaseStream.Seek(-200, SeekOrigin.Current); * } */ MapPosition objectPosition = reader.ReadPosition(); int objectTemplateIndex = (int)reader.ReadUInt32(); ObjectTemplate objTemplate = mapObject.ObjectTemplates[objectTemplateIndex]; reader.Skip(5); MapObjectReader objectReader = MapObjectReaderFactory.GetObjectReader(objTemplate.Type); CGObject resultObject = null; if (objectReader != null) { objectReader.Map = this.mapObject; objectReader.MapHeader = this.mapObject.Header; objectReader.ObjectTemplate = objTemplate; resultObject = objectReader.ReadObject(reader, objectId, objectPosition); if (resultObject == null) { continue; } } else { // Normal Object, load from JSON resultObject = new CGObject(); } resultObject.Position = objectPosition; resultObject.Identifier = (uint)objectId; resultObject.Template = objTemplate; if (resultObject.Template.Type != EObjectType.HERO && resultObject.Template.Type != EObjectType.HERO_PLACEHOLDER && resultObject.Template.Type != EObjectType.PRISON) { resultObject.SubId = resultObject.Template.SubId; } resultObject.InstanceName = string.Format("{0}_{1}", resultObject.Identifier, resultObject.Template.Type); //// Console.WriteLine(string.Format(@"Readed object {0}, Position: [{1}, {2}, {3}]", resultObject.InstanceName, objectPosition.PosX, objectPosition.PosY, objectPosition.Level)); mapObject.Objects.Add(resultObject); } }
/// <summary> /// Adds the given ObjectTemplate to the given IGameField. /// </summary> /// <param name="template"> /// The template to add. /// </param> /// <param name="offsetX"> /// The offset to apply on the x-axis. /// </param> /// <param name="offsetY"> /// The offset to apply on the y-axis. /// </param> /// <param name="gameField"> /// The IGameField to fill with data. /// </param> public void AddTemplate( ObjectTemplate template, int offsetX, int offsetY, IGameField gameField ) { this.offsetX = offsetX; this.offsetY = offsetY; this.gameField = gameField; switch( template ) { case ObjectTemplate.Glider: this.AddGlider(); break; case ObjectTemplate.Chaos: this.AddChaos(); break; case ObjectTemplate.Laser0: this.AddLaser0(); break; case ObjectTemplate.Laser2: this.AddLaser2(); break; case ObjectTemplate.Horseshoe: this.AddHorseshoe(); break; case ObjectTemplate.Flower: this.AddFlower(); break; case ObjectTemplate.Claphand: this.AddToad(); break; case ObjectTemplate.Acorn: this.AddAcorn(); break; case ObjectTemplate.Octagon: this.AddOctagon(); break; case ObjectTemplate.Pentadecathlon: this.AddPentadecathlon(); break; case ObjectTemplate.Bugface: this.AddBugface(); break; case ObjectTemplate.Tumbler: this.AddTumbler(); break; case ObjectTemplate.Diehard: this.AddDiehard(); break; case ObjectTemplate.Pulsar: this.AddPulsar(); break; case ObjectTemplate.QueenBeeShuttle: this.AddQueenBeeShuttle(); break; case ObjectTemplate.SpaceshipLightweight: this.AddLightweightSpaceship(); break; default: throw new NotImplementedException( template.ToString() ); } }