本文整理汇总了C#中System.Entity.AddAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.AddAttribute方法的具体用法?C# Entity.AddAttribute怎么用?C# Entity.AddAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.AddAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddAttributes
private void AddAttributes( Dictionary<string, object> attributes, Entity entity )
{
// create and load data for all entity attributes
foreach ( KeyValuePair<string, object> attributeData in attributes ) {
// TODO: make sure these attributes are deep copied
entity.AddAttribute( attributeData.Key, attributeData.Value );
}
}
示例2: AddTestComponent
public static void AddTestComponent(Entity entity)
{
// Setup a velocity attribute
Vector3 velocity = new Vector3(0, 0, -1.0f);
entity.AddAttribute( Attributes.VELOCITY, velocity );
// Add the test component
MoveComponent moveComponent = new MoveComponent( entity );
entity.AddComponent( moveComponent );
}
示例3: AddTestComponent
public static void AddTestComponent( Entity entity, GeometricPrimitiveType primitiveType, float size )
{
Transform transform = new Transform();
entity.AddAttribute( Attributes.TRANSFORM, transform );
PrimitiveRenderComponent renderComponent = new PrimitiveRenderComponent( entity );
renderComponent.GeometricPrimitiveType = primitiveType;
renderComponent.Color = Color.LimeGreen;
renderComponent.Wireframe = false;
renderComponent.m_size = size;
entity.AddComponent( renderComponent );
}
示例4: CreateEntity
private Entity CreateEntity(ParseTreeNode node, Scene scene, bool prototype)
{
Entity entity = new Entity() { Name = grammar.GetName(node), IsPrototype = prototype };
foreach (string name in grammar.GetPrototypes(node)) entity.AddPrototype(game.GetPrototype(name));
foreach (Tuple<string, object> attribute in GetProperties(node))
{
ParseTreeNode attributeNode = (ParseTreeNode)attribute.Item2;
entity.AddAttribute(new Attribute(attribute.Item1) { Value = new Value(getStrVal(attributeNode)) });
}
foreach (ParseTreeNode componentNode in grammar.GetOfType(node, grammar.Component))
{
// Adding a component adds any other components that the new component requires.
// It is necessary to check if the component we are attempting to add already
// exists. If it does, we should not attempt to create a new component.
Plugin plugin = game.GetPlugin(grammar.GetName(componentNode));
Component component = entity.GetComponentByType(plugin.CoreType);
if (null == component)
{
component = new Component(plugin);
entity.AddComponent(component);
}
foreach (Tuple<string, object> property in GetProperties(componentNode))
{
ParseTreeNode propertyNode = (ParseTreeNode)property.Item2;
component.SetProperty(property.Item1, new Value(getStrVal(propertyNode)));
}
}
foreach (ParseTreeNode eventNode in grammar.GetOfType(node, grammar.Evt))
{
Event evt = CreateEvent(eventNode);
entity.AddEvent(evt);
}
return entity;
}
示例5: Entity_RemoveAttribute
public void Entity_RemoveAttribute()
{
var entity = new Entity();
var attribute = new Attribute("test");
entity.AddAttribute(attribute);
entity.SelectedAttribute = attribute;
CommandHelper.TestUndoableCommand(
() => Assert.AreEqual(1, entity.Attributes.Count),
() => entity.RemoveAttributeCommand.Execute(null),
() => Assert.AreEqual(0, entity.Attributes.Count)
);
}
示例6: ComponentTest
public static void ComponentTest()
{
XEngineComponentTest testGame = new XEngineComponentTest();
Entity entity1 = null;
Entity entity2 = null;
testGame.InitDelegate = delegate {
entity1 = new Entity();
AddShipTestComponent( entity1 );
entity1.AddAttribute( Attributes.TRANSFORM, new Transform( new Vector3( 0, 1.0f, 0 ) ) );
entity1.Initialize();
entity2 = new Entity();
AddGridTestComponent( entity2 );
entity2.Initialize();
};
testGame.DrawDelegate = delegate( GameTime gameTime ) {
entity1.Draw( gameTime );
entity2.Draw( gameTime );
};
testGame.Run();
}