wpf游戏引擎的script实现

1.script.cs

using System.IO;

using System.Runtime.Serialization;

using System.Text;

namespace PrimalEditor.Components

{

DataContract

class Script : Component

{

private string _name;

DataMember

public string Name

{

get => _name;

set

{

if (_name != value)

{

_name = value;

OnPropertyChanged(Name);

}

}

}

public override IMSComponent GetMultiselectionComponent(MSEntity msEntity) => new MSScript(msEntity);

public override void WriteToBinary(BinaryWriter bw)

{

var nameBytes = Encoding.UTF8.GetBytes(Name);

bw.Write(nameBytes.Length);

bw.Write(nameBytes);

}

public Script(GameEntity owner) : base(owner)

{

}

}

sealed class MSScript : MSComponent<Script>

{

private string _name;

DataMember

public string Name

{

get => _name;

set

{

if (_name != value)

{

_name = value;

OnPropertyChanged(Name);

}

}

}

protected override bool UpdateComponents(string propertyName)

{

if (propertyName == nameof(Name))

{

SelectedComponents.ForEach(c => c.Name = _name);

return true;

}

return false;

}

protected override bool UpdateMSComponent()

{

Name = MSEntity.GetMixedValue(SelectedComponents, new Func<Script, string>(x => x.Name));

return true;

}

public MSScript(MSEntity msEntity) : base(msEntity)

{

Refresh();

}

}

}

相关推荐
c#上位机2 小时前
wpf之Border
c#·wpf
SunflowerCoder2 小时前
WPF迁移avalonia之图像处理(一)
图像处理·wpf·avalonia
周杰伦fans3 小时前
WPF中的DataContext以及常见的绑定方式
wpf
没有bug.的程序员1 天前
Redis 数据结构全面解析:从底层编码到实战应用
java·数据结构·redis·wpf
Xeon_CC1 天前
Unity中,软遮罩SoftMaskForUGUI的使用
unity·游戏引擎
somethingGoWay1 天前
wpf 自定义输入ip地址的文本框
wpf
DanmF--1 天前
NGUI--三大基础组件
unity·游戏引擎
秋月的私语1 天前
Wpf程序屏幕居中问题修复全记录
wpf
我要打打代码1 天前
WPF启动窗体的三种方式
wpf
R瑾安1 天前
mysql集群部署(Mysql Group Replication)
数据库·mysql·wpf