コード例 #1
0
ファイル: Entity.cs プロジェクト: frackiewicz/Wraithknight
 public void AddComponent(BindableComponent component, ICollection <Type> binds)
 {
     foreach (var bind in binds)
     {
         component.AddBinding(bind);
     }
     AddComponent(component);
 }
コード例 #2
0
 private void ApplyKnockback(ProjectileComponent actor, BindableComponent target)
 {
     if (actor.Bindings.TryGetValue(typeof(MovementComponent), out var actorBinding))
     {
         if (target.Bindings.TryGetValue(typeof(MovementComponent), out var targetBinding))
         {
             MovementComponent actorMovement  = actorBinding as MovementComponent;
             MovementComponent targetMovement = targetBinding as MovementComponent;
             targetMovement.Speed.SetVector2(new Coord2(actorMovement.Speed.Cartesian).ChangePolarLength(actor.Knockback).Cartesian);
         }
     }
 }
コード例 #3
0
ファイル: Entity.cs プロジェクト: frackiewicz/Wraithknight
 private void FinalizeBindableComponent(BindableComponent component)
 {
     for (int i = 0; i < component.Bindings.Count; i++)
     {
         Type type = component.Bindings.ElementAt(i).Key;
         if (Components.TryGetValue(type, out var binding))
         {
             component.Bindings[type] = binding;
         }
         else
         {
             throw new ArgumentException("Entity does not contain binding type");
         }
     }
 }
コード例 #4
0
ファイル: Entity.cs プロジェクト: frackiewicz/Wraithknight
 public void AddComponent(BindableComponent component, Type bind)
 {
     component.AddBinding(bind);
     AddComponent(component);
 }