/// <summary> /// Loads this scene node from a given binary reader. /// </summary> /// <param name="reader">Binary reader to load this scene node from.</param> public override void Load(BinaryReader reader) { base.Load(reader); _event = reader.ReadString(); int flagMask = reader.ReadInt32(); _visible = (flagMask & 1) != 0; _enabled = (flagMask & 2) != 0; _solid = (flagMask & 4) != 0; if ((flagMask & 262144) != 0) { string meshUrl = reader.ReadString(); if (ResourceManager.ResourceExists(meshUrl) == true) _mesh = GraphicsManager.LoadMesh(meshUrl, 0); } if ((flagMask & 8) != 0) { string imageUrl = reader.ReadString(); int cellWidth = reader.ReadInt32(); int cellHeight = reader.ReadInt32(); int hSpacing = reader.ReadInt16(); int vSpacing = reader.ReadInt16(); if (ResourceManager.ResourceExists(imageUrl) == true) _image = GraphicsManager.LoadImage(imageUrl,cellWidth,cellHeight,hSpacing,vSpacing, 0); } if ((flagMask & 16) != 0) { string fontUrl = reader.ReadString(); if (ResourceManager.ResourceExists(fontUrl) == true) _bitmapFont = GraphicsManager.LoadFont(fontUrl); } if ((flagMask & 32) != 0) _text = reader.ReadString(); if ((flagMask & 64) != 0) { _boundingRectangle.X = reader.ReadInt32(); _boundingRectangle.Y = reader.ReadInt32(); } if ((flagMask & 128) != 0) { _boundingRectangle.Width = reader.ReadInt32(); _boundingRectangle.Height = reader.ReadInt32(); } if ((flagMask & 256) != 0) _frame = reader.ReadInt32(); if ((flagMask & 512) != 0) _renderMode = (EntityRenderMode)reader.ReadByte(); else _renderMode = EntityRenderMode.Image; if ((flagMask & 1024) != 0) _blendMode = (BlendMode)reader.ReadByte(); else _blendMode = BlendMode.Alpha; if ((flagMask & 2048) != 0) _color = reader.ReadInt32(); else _color = unchecked((int)0xFFFFFFFF); if ((flagMask & 4096) != 0) { if (_collisionPolygon == null) InitializeCollision(); int count = reader.ReadInt32(); _collisionPolygon.Layers = new int[count]; for (int i = 0; i < count; i++) _collisionPolygon.Layers[i] = reader.ReadInt32(); } if ((flagMask & 8192) != 0) { _collisionRectangle.X = reader.ReadInt32(); _collisionRectangle.Y = reader.ReadInt32(); } if ((flagMask & 16384) != 0) { _collisionRectangle.Width = reader.ReadInt32(); _collisionRectangle.Height = reader.ReadInt32(); } if ((flagMask & 32768) != 0) _depthLayer = reader.ReadInt32(); if ((flagMask & 65536) != 0) _depthMode = (EntityDepthMode)reader.ReadByte(); if ((flagMask & 131072) != 0) _shader = GraphicsManager.LoadShader(reader.ReadString()); }
/// <summary> /// Loads this modifier from a given binary reader. /// </summary> /// <param name="reader">Binary reader to load this modifier from.</param> public override void Load(BinaryReader reader) { // Load ze base! base.Load(reader); // Load properties. _renderMode = (EntityRenderMode)reader.ReadInt32(); _blendMode = (BlendMode)reader.ReadInt32(); _text = reader.ReadString(); _isVisible = reader.ReadBoolean(); _isEnabled = reader.ReadBoolean(); if (reader.ReadBoolean() == true) { string imageUrl = reader.ReadString(); int cellWidth = reader.ReadInt32(); int cellHeight = reader.ReadInt32(); int hSpacing = reader.ReadInt16(); int vSpacing = reader.ReadInt16(); if (ResourceManager.ResourceExists(imageUrl) == true) { _image = GraphicsManager.LoadImage(imageUrl, cellWidth, cellHeight, hSpacing, vSpacing, 0); _image.Origin = new Point(cellWidth / 2, cellHeight / 2); } } if (reader.ReadBoolean() == true) { string fontUrl = reader.ReadString(); if (ResourceManager.ResourceExists(fontUrl) == true) _font = GraphicsManager.LoadFont(fontUrl); } if (reader.ReadBoolean() == true) { string shaderUrl = reader.ReadString(); if (ResourceManager.ResourceExists(shaderUrl) == true) { _shader = GraphicsManager.LoadShader(shaderUrl); _shaderFileEditor.FileUrl = shaderUrl; } } }
/// <summary> /// Resets this entity to the state it was in when it was created. /// </summary> public override void Reset() { base.Reset(); if (_collisionPolygon != null) DeinitializeCollision(); _forceVisibility = false; _forceBoundingBoxVisibility = false; _forceCollisionBoxVisibility = false; _visible = true; _enabled = true; _solid = false; _event = ""; _renderEventLines = false; _eventNodes.Clear(); _eventLineColor = unchecked((int)0xFFFF0000); _image = null; _mesh = null; _frame = 0; _renderMode = EntityRenderMode.Rectangle; _boundingRectangle = new Rectangle(0, 0, 16, 16); _collisionRectangle = new Rectangle(0, 0, 16, 16); _color = unchecked((int)0xFFFFFFFF); _blendMode = BlendMode.Alpha; _text = ""; _bitmapFont = null; _renderBoundingBox = false; _renderCollisionBox = false; _renderSizingPoints = false; _boundingBoxColor = unchecked((int)0xFF0000FF); _collisionBoxColor = unchecked((int)0xFF666666); _sizingPointsColor = unchecked((int)0xFFFFFFFF); _sizingPointsSize = 5; _collisionPolygon = null; _depthLayer = 0; _depthMode = EntityDepthMode.SubtractCollisionBoxBottom; _triggered = false; _shader = null; }