public Being(ThingType type) { // Actor(type), // mAction(STAND), // mTarget(NULL), // mGender(GENDER_UNSPECIFIED), // mDirection(DOWN) // const AttributeScope &attr = attributeManager.getAttributeScope(BeingScope); // LOG_DEBUG("Being creation: initialisation of " << attr.size() << " attributes."); // for (AttributeScope::const_iterator it1 = attr.begin(), // it1_end = attr.end(); // it1 != it1_end; // ++it1) // { // if (mAttributes.count(it1.first)) // LOG_WARN("Redefinition of attribute '" << it1.first << "'!"); // LOG_DEBUG("Attempting to create attribute '" << it1.first << "'."); // mAttributes.insert(std::make_pair(it1.first, // Attribute(*it1.second))); // } // // TODO: Way to define default base values? // // Should this be handled by the virtual modifiedAttribute? // // URGENT either way //#if 0 // // Initialize element resistance to 100 (normal damage). // for (i = BASE_ELEM_BEGIN; i < BASE_ELEM_END; ++i) // { // mAttributes[i] = Attribute(TY_ST); // mAttributes[i].setBase(100); // } //#endif }
public Thing GetThing(ThingType a_type) { if (m_race == Races.Cubes) { switch (a_type) { case ThingType.C_Cube: return(m_cube); case ThingType.C_Barbarian: return(m_barbarian); case ThingType.C_Extractor: return(m_extractor); case ThingType.C_Igloo: return(m_igloo); case ThingType.C_Barrack: return(m_barrack); } } //This is just so you can't access anothers race units! return(null); }
public Thing(ThingType type, string name, int effect, int cost) { Type = type; Name = name; Effect = effect; Cost = cost; }
public Entity FindNearest(Entity thing, ThingType thingType) { Entity foundThing = null; float bestDist = 99999999f; var b = thing.entityWorld.EntityManager.GetEntities(Aspect.All(typeof(ThingComp))); foreach (Entity e in b) { var tc = e.GetComponent <ThingComp>(); if (tc == this) { continue; } if (!tc.Active) { continue; } if (tc.Type == thingType) { float dist = (tc.Position - this.Position).Length(); if (dist < bestDist) { bestDist = dist; foundThing = e; } } } return(foundThing); }
protected void ConvertDeclarationList(IEnumerable <ThingModel.ThingType> declarations) { foreach (var thingType in declarations) { var declaration = new ThingType { string_name = StringToKey(thingType.Name), string_description = StringToKey(thingType.Description) }; foreach (var propertyType in thingType.GetProperties()) { declaration.properties.Add(new PropertyType { string_key = StringToKey(propertyType.Key), string_name = StringToKey(propertyType.Name), string_description = StringToKey(propertyType.Description), required = propertyType.Required, type = PrototypesBinding[propertyType.Type] }); } Transaction.thingtypes_declaration_list.Add(declaration); } }
private void Parse() { DatSignature = m_BinaryReader.ReadUnsignedInt(); ContentRevision = (ushort)DatSignature; int[] counts = new int[(int)ThingCategory.LastCategory]; for (int category = 0; category < (int)ThingCategory.LastCategory; category++) { int count = m_BinaryReader.ReadUnsignedShort() + 1; counts[category] = count; } for (int category = 0; category < (int)ThingCategory.LastCategory; category++) { ushort firstId = 1; if (category == (int)ThingCategory.Item) { firstId = 100; } ThingTypeDictionaries[category] = new ThingTypesDict(); for (ushort id = firstId; id < counts[category]; id++) { ThingType thingType = new ThingType() { ID = id, Category = (ThingCategory)category, }; thingType.Unserialize(m_BinaryReader, m_ClientVersion); ThingTypeDictionaries[category][id] = thingType; } } }
public ObjectData GetThingData(ushort id, ThingCategory category, bool singleFrameGroup) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return(null); } if (singleFrameGroup) { thing = ThingType.ToSingleFrameGroup(thing); } SpriteGroup spriteGroups = new SpriteGroup(); Console.WriteLine(thing.FrameGroupCount); for (byte i = 0; i < thing.FrameGroupCount; i++) { FrameGroupType groupType = (FrameGroupType)i; FrameGroup frameGroup = thing.GetFrameGroup(groupType); int length = frameGroup.SpriteIDs.Length; Sprite[] sprites = new Sprite[length]; for (int s = 0; s < length; s++) { sprites[s] = this.Sprites.GetSprite(frameGroup.SpriteIDs[s]); } spriteGroups.Add(groupType, sprites); } return(new ObjectData(thing, spriteGroups)); }
public SpriteSheet GetSpriteSheet(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return(null); } FrameGroup group = thing.GetFrameGroup(groupType); int totalX = group.PatternZ * group.PatternX * group.Layers; int totalY = group.Frames * group.PatternY; int bitmapWidth = (totalX * group.Width) * Sprite.DefaultSize; int bitmapHeight = (totalY * group.Height) * Sprite.DefaultSize; int pixelsWidth = group.Width * Sprite.DefaultSize; int pixelsHeight = group.Height * Sprite.DefaultSize; Bitmap bitmap = new Bitmap(bitmapWidth, bitmapHeight, PixelFormat.Format32bppArgb); Dictionary <int, Rect> rectList = new Dictionary <int, Rect>(); BitmapLocker lockBitmap = new BitmapLocker(bitmap); lockBitmap.LockBits(); for (int f = 0; f < group.Frames; f++) { for (int z = 0; z < group.PatternZ; z++) { for (int y = 0; y < group.PatternY; y++) { for (int x = 0; x < group.PatternX; x++) { for (int l = 0; l < group.Layers; l++) { int index = group.GetTextureIndex(l, x, y, z, f); int fx = (index % totalX) * pixelsWidth; int fy = (int)(Math.Floor((decimal)(index / totalX)) * pixelsHeight); rectList.Add(index, new Rect(fx, fy, pixelsWidth, pixelsHeight)); for (int w = 0; w < group.Width; w++) { for (int h = 0; h < group.Height; h++) { index = group.GetSpriteIndex(w, h, l, x, y, z, f); int px = ((group.Width - w - 1) * Sprite.DefaultSize); int py = ((group.Height - h - 1) * Sprite.DefaultSize); uint spriteId = group.SpriteIDs[index]; lockBitmap.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px + fx, py + fy); } } } } } } } lockBitmap.UnlockBits(); return(new SpriteSheet(bitmap, rectList)); }
public void InitialiseThing(string name, string desc, List <Sprite> charImgs, ThingType thingType, ThingInfo info) { _itemName = name; _description = desc; _itemImages = charImgs; _itemThingType = thingType; _thingInfo = info; }
byte mUpdateFlags; /**< Changes in actor status. */ #endregion Fields #region Constructors public Actor(ThingType type) : base(type) { mMoveTime=0; mUpdateFlags=0; mPublicID=65535; mSize=0; }
public RepositoryThing(int id, ThingType type, string name, int effect, int cost) { Id = id; Type = type; Name = name; Effect = effect; Cost = cost; }
public Bitmap GetObjectImage(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType thing = this.Things.GetThing(id, category); if (thing == null) { return(null); } Bitmap bitmap = this.spriteCache.GetPicture(id, category); if (bitmap != null) { return(bitmap); } FrameGroup group = thing.GetFrameGroup(groupType); int width = Sprite.DefaultSize * group.Width; int height = Sprite.DefaultSize * group.Height; bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); BitmapLocker lockBitmap = new BitmapLocker(bitmap); lockBitmap.LockBits(); byte layers = group.Layers; byte x = 0; if (category == ThingCategory.Outfit) { layers = 1; x = (byte)(2 % group.PatternX); } // draw sprite for (byte l = 0; l < layers; l++) { for (byte w = 0; w < group.Width; w++) { for (byte h = 0; h < group.Height; h++) { int index = group.GetSpriteIndex(w, h, l, x, 0, 0, 0); uint spriteId = group.SpriteIDs[index]; int px = (group.Width - w - 1) * Sprite.DefaultSize; int py = (group.Height - h - 1) * Sprite.DefaultSize; lockBitmap.CopyPixels(this.Sprites.GetSpriteBitmap(spriteId), px, py); } } } lockBitmap.UnlockBits(); lockBitmap.Dispose(); this.spriteCache.SetPicture(id, category, bitmap); return(bitmap); }
public void InitialiseThing(string name, string desc, string charName, List <Sprite> charImgs, ThingType thingType, ThingInfo info) { Name = name; Description = desc; CharacterName = charName; CharacterImages = charImgs; ThingType = thingType; _thingInfo = info; }
/// <inheritdoc/> public BaseThing CreateThing(Random rdm, int x, int y, ThingType type, string definitionName) { return(type switch { ThingType.Site => this.CreateSite(rdm, x, y, definitionName), ThingType.NotablePerson => this.CreateNotablePerson(rdm, x, y, definitionName), ThingType.WorldSquare => this.CreateWorldSquare(rdm, x, y, definitionName), _ => throw new InvalidOperationException($"Can not handle {type}."), });
public Bitmap GetObjectImage(ThingType thing) { if (thing != null) { return(this.GetObjectImage(thing.ID, thing.Category, FrameGroupType.Default)); } return(null); }
public Thing(string name, int rails, ThingType thingtype, float length) { this.Name = name; this.ThingType = thingtype; this.RailCount = rails; this.Length = length; this.Vehicles = new List <int>(); this.ElecData = new ElectricalData(); this.ThingsAtWings = new string[16]; }
public int GetCountForItem(ThingType thingTypeFilter, Tradeable tradeable) { int key = tradeable.GetHashCode(); if (requestedItems[thingTypeFilter].dict.ContainsKey(key)) { return(requestedItems[thingTypeFilter].dict[key].amount); } return(0); }
public void AddToBuildQueue(ThingType a_thingy, Vector3 a_position) { m_buildingQueue.Enqueue(a_thingy); //Puts the build position in the center of a tile //m_position = new Vector3((int)a_position.X + Map.m_tileSizeDivided, (int)a_position.Y + Map.m_tileSizeDivided, m_map.m_tiles[(int)a_position.X,(int)a_position.Y].m_height); m_position = a_position; StartBuild(); }
private void AddThingDef(ThingDef def, ThingType type) { if (def.MadeFromStuff) { foreach (var s in stuff) { if (!s.stuffProps.CanMake(def)) { continue; } var key = new ThingKey(def, s); var entry = CreateThingEntry(def, s, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } } } else if (def.race != null && def.race.Animal) { if (def.race.hasGenders) { var femaleEntry = CreateThingEntry(def, Gender.Female, type); if (femaleEntry != null) { AddRecordIfNotThereAlready(new ThingKey(def, Gender.Female), femaleEntry); } var maleEntry = CreateThingEntry(def, Gender.Male, type); if (maleEntry != null) { AddRecordIfNotThereAlready(new ThingKey(def, Gender.Male), maleEntry); } } else { var key = new ThingKey(def, Gender.None); var entry = CreateThingEntry(def, Gender.None, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } } } else { var key = new ThingKey(def, null); var entry = CreateThingEntry(def, null, Gender.None, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } } }
public ThingEntry AddThingDefWithStuff(ThingDef def, ThingDef stuff, ThingType type) { ThingKey key = new ThingKey(def, stuff); ThingEntry entry = CreateThingEntry(def, stuff, type); if (entry != null) { AddRecordIfNotThereAlready(key, entry); } return(entry); }
//------------------------------------------------------------------------------------------------------------------------- public ThingTypeDescriptor(ThingType ThingType, List <NodeDescriptor> Nodes = null) { this.Type = ThingType.Type; this.Description = ThingType.Description; this.Searchable = ThingType.Searchable; this.Model = ThingType.Models; // TODO: remove Img field from this model view // Img was used in Grid Layout of ThingsManager this.Img = "/Content/ThingsManager/img/" + ThingType.Type + ".png"; this.Nodes = Nodes; }
public static IThing CreateThing(ThingType type) { switch (type) { case ThingType.DerivedThing: return(new DerivedThing()); default: return(new Thing()); } }
public ThingComp(ThingType type, LevelBackgroundComp bgComp, Texture2D collisionTexture) { this.Type = type; this.bg = bgComp; this.boundingRectangle.Width = collisionTexture.Width; this.boundingRectangle.Height = collisionTexture.Height; // TODO needed to fetch text.data per entity? only for those that may change its shape/texture during play? textureData = new Color[collisionTexture.Width * collisionTexture.Height]; collisionTexture.GetData(textureData); }
public FrameGroup GetFrameGroup(ushort id, ThingCategory category, FrameGroupType groupType) { ThingType type = this.Things.GetThing(id, category); if (type != null) { return(type.GetFrameGroup(groupType)); } return(null); }
private ThingType CheckFightThing(ThingType thingType) { if (thingType == ThingType.None) { return(thingType); } var thing = _entityResolver.EntityById <IObject>((int)thingType) !; return(thing.CanFight ? thingType : ThingType.None); }
public static void Prefix(Player tplayer, ThingType tthingType) { if (CEOverlordCheatMenuConfig.enableUnlimitedResources == true) { for (int i = 0; i < tthingType.prices.Count; i++) { List <int> resources; int index; (resources = tplayer.resources)[index = i] = resources[index] + tthingType.prices[i]; } } }
public IObject GivenAnObjectOfType(ThingType thingType, bool unique = false) { var thing = _mainHooks.Container.Resolve <IObject>(); if (thing is Object item) { item.Id = new MXId(EntityType.Thing, (uint)thingType); item.SetFlags(ThingFlags.Unique, unique); } return(thing); }
private void UpdateThingsToRender() { thingsToRenderAmount = 0; for (int i = 0; i < thingsAmount; i++) { ThingType type = (ThingType)things[i].type; if (type == ThingType.Sun || type == ThingType.Planet || type == ThingType.Moon) { thingsToRender[thingsToRenderAmount++] = (ushort)i; } } }
public void Serialize(ThingType thingType, IO.BinaryStream binaryWriter, int fromVersion, int newVersion, sbyte startPhase, byte phasesLimit) { binaryWriter.WriteUnsignedByte(Width); binaryWriter.WriteUnsignedByte(Height); if (Width > 1 || Height > 1) { binaryWriter.WriteUnsignedByte(ExactSize); } binaryWriter.WriteUnsignedByte(Layers); binaryWriter.WriteUnsignedByte(PatternWidth); binaryWriter.WriteUnsignedByte(PatternHeight); if (newVersion >= 755) { binaryWriter.WriteUnsignedByte(PatternDepth); } binaryWriter.WriteUnsignedByte(phasesLimit); if (fromVersion < 1050) { if (phasesLimit > 1 && newVersion >= 1050) { FrameGroupAnimator.SerializeLegacy(thingType, binaryWriter, startPhase, phasesLimit); } } else { if (phasesLimit > 1 && newVersion >= 1050) { Animator.Serialize(binaryWriter, startPhase, phasesLimit); } } int spritesPerPhase = Width * Height * Layers * PatternWidth * PatternHeight * PatternDepth; int totalSprites = phasesLimit * spritesPerPhase; int offset = startPhase * spritesPerPhase; for (int j = 0; j < totalSprites; j++) { uint spriteId = Sprites[offset + j]; if (newVersion >= 960) { binaryWriter.WriteUnsignedInt(spriteId); } else { binaryWriter.WriteUnsignedShort((ushort)spriteId); } } }
private void DrawItemHandler(object sender, DrawItemEventArgs ev) { Rectangle bounds = ev.Bounds; bounds.Width--; // draw background ev.DrawBackground(); // draw border ev.Graphics.DrawRectangle(Pens.Gray, bounds); if (this.Client != null && ev.Index != -1) { ThingType thing = (ThingType)this.Items[ev.Index]; // find the area in which to put the text and draw. this.layoutRect.X = bounds.Left + 32 + (3 * ItemMargin); this.layoutRect.Y = bounds.Top + (ItemMargin * 2); this.layoutRect.Width = bounds.Right - ItemMargin - this.layoutRect.X; this.layoutRect.Height = bounds.Bottom - ItemMargin - this.layoutRect.Y; // draw thing id end name if ((ev.State & DrawItemState.Selected) == DrawItemState.Selected) { this.pen.Brush = WhiteBrush; ev.Graphics.DrawString(thing.ToString(), this.Font, WhiteBrush, this.layoutRect); } else { this.pen.Brush = BlackBrush; ev.Graphics.DrawString(thing.ToString(), this.Font, BlackBrush, this.layoutRect); } this.destRect.Y = bounds.Top + ItemMargin; Bitmap bitmap = this.Client.GetObjectImage(thing); if (bitmap != null) { this.sourceRect.Width = bitmap.Width; this.sourceRect.Height = bitmap.Height; ev.Graphics.DrawImage(bitmap, this.destRect, this.sourceRect, GraphicsUnit.Pixel); } } // draw view border ev.Graphics.DrawRectangle(this.pen, this.destRect); // draw focus rect ev.DrawFocusRectangle(); }
public static Certificate createIoTCore(Output <string> streamName) { var topicRuleRole = Iam.CreateIotTopicRuleRole(); var iotThingPolicy = new Policy($"{Common.appName}_iot_sensor_producer_thing_policy", new PolicyArgs { PolicyDocument = @"{ ""Version"": ""2012-10-17"", ""Statement"": [ { ""Action"": [ ""iot:*"", "" :*"" ], ""Effect"": ""Allow"", ""Resource"": ""*"" } ] }" }); var iotThingType = new ThingType($"{Common.appName}_raspberryPi"); var iotThing = new Thing($"{Common.appName}_iot_sensor_producer", new ThingArgs { ThingTypeName = iotThingType.Name }); var iotCert = new Certificate($"{Common.appName}_iot_sensor_producer_cert", new CertificateArgs { Active = true }); var iotThingPrincipalAttachement = new ThingPrincipalAttachment($"{Common.appName}_iot_sensor_producer_thing_cert_attachment", new ThingPrincipalAttachmentArgs { Principal = iotCert.Arn, Thing = iotThing.Name, }); var iotPolicyAttachment = new PolicyAttachment($"{Common.appName}_iot_sensor_producer_policy_attachment", new PolicyAttachmentArgs { Policy = iotThingPolicy.Name, Target = iotCert.Arn }); var iotRule = new TopicRule($"{Common.appName}_sensor_ingest_iot_rule", new TopicRuleArgs { Enabled = true, Kinesis = new Pulumi.Aws.Iot.Inputs.TopicRuleKinesisArgs { PartitionKey = "'SITE_ID'", RoleArn = topicRuleRole.Arn, StreamName = streamName }, Sql = $"SELECT * FROM 'sensor-topic'", SqlVersion = "2015-10-08" }); return(iotCert); }
/// <summary> /// Creates a new <see cref="Syncer"/> helper class /// </summary> /// <param name="type"> /// The <see cref="ThingType"/> describing the ClassKind to be synced /// </param> /// <param name="sourceSession"> /// The <see cref="ISession"/> for the source server session /// </param> /// <param name="targetSession"> /// The <see cref="ISession"/> for the target server session /// </param> /// <returns> /// The newly created helper <see cref="Syncer"/> class /// </returns> public Syncer CreateSyncer(ThingType type, ISession sourceSession, ISession targetSession) { switch (type) { case ThingType.DomainOfExpertise: return(new DomainOfExpertiseSyncer(sourceSession, targetSession)); case ThingType.SiteReferenceDataLibrary: return(new SiteReferenceDataLibrarySyncer(sourceSession, targetSession)); default: throw new ArgumentException("Invalid value", nameof(type)); } }
public Being(ThingType type) : base(type) { mAction=BeingAction.STAND; mTarget=null; mGender=BeingGender.GENDER_UNSPECIFIED; mDirection=BeingDirection.DOWN; Dictionary<int, List<AttributeInfoType>> attr=Program.attributeManager.getAttributeScope(ScopeType.BeingScope); Logger.Write(LogLevel.Debug, "Being creation: initialisation of {0} attributes.", attr.Count); foreach(KeyValuePair<int, List<AttributeInfoType>> pair in attr) { int debug=555; //TODO hier mal reinschauen //if(mAttributes.Count //if (mAttributes.count(it1.first)) // LOG_WARN("Redefinition of attribute '" << it1.first << "'!"); //LOG_DEBUG("Attempting to create attribute '" << it1.first << "'."); //mAttributes.insert(std::make_pair(it1.first, // Attribute(*it1.second))); } // TODO: Way to define default base values? // Should this be handled by the virtual modifiedAttribute? // URGENT either way //#if 0 // // Initialize element resistance to 100 (normal damage). // for (i = BASE_ELEM_BEGIN; i < BASE_ELEM_END; ++i) // { // mAttributes[i] = Attribute(TY_ST); // mAttributes[i].setBase(100); // } //#endif }
public ThingComp(ThingType type) { this.Type = type; }
public Entity CreateThing(ThingType tp, bool hasControls, Color color) { return CreateThing(tp, hasControls, "pixie", color); }
private TreeNode CreateSubNode(TreeNode parent,ThingType type,string text) { TreeNode temp; temp = new TreeNode(); temp.Text = text; Thing thing = new Thing(); thing.NoteDate = System.DateTime.Now; Thing tmp = parent.Tag as Thing; thing.ParentId = tmp.Id; thing.Title = text; thing.NodeType = (int)type; int imageindex = 1; if (type == ThingType.Folder) { imageindex = 2; } else if (type == ThingType.Schedule) { imageindex = 3; thing.Context=this.editor1.GetTemplateContext("�ҵļƻ�����.html"); } else if (type == ThingType.Task) { imageindex = 4; thing.Context = this.editor1.GetTemplateContext("�ҵĴ�������.html"); } else if (type == ThingType.JustThing) { imageindex = 5; thing.Context = this.editor1.GetTemplateContext("�ҵļ���.html"); } FT.DAL.Orm.SimpleOrmOperator.Create(thing); temp.Tag =thing; temp.ImageIndex = imageindex; temp.SelectedImageIndex = imageindex; this.ShowThing(temp); return temp; }
ThingType mType; /**< Type of this thing. */ #endregion Fields #region Constructors //, MapComposite *map = 0) public Thing(ThingType type) { mMap=null; mType=type; }
public Entity CreateThing(ThingType tp, bool hasControls, string bitmap, Color color) { var e = TTFactory.CreateSpritelet(bitmap); var sc = e.GetComponent<SpriteComp>(); var tc = new ThingComp(tp); var dc = e.GetComponent<DrawComp>(); dc.DrawColor = color; e.AddComponent(tc); e.AddComponent(new TargetMotionComp()); if (hasControls) { var tcc = new ControlComp(); e.AddComponent(tcc); } tc.PassableIntensityThreshold = PXGame.Instance.Level.DefaultPassableIntensityThreshold; return e; }
public Thing(ThingType type, MapComposite map) { mMap=map; mType=type; }
private List<Thing> GetThings(Thing parent, ThingType thingType) { List<Thing> things = new List<Thing>(); Walk(parent, thing => { if (thing.ThingType == thingType && !things.Contains(thing)) { things.Add(thing); } }); return things; }