public static void AddComponents(EntityFactory factory) { // Apply these one after the other. // This will only initialize the inject variables of the behavior / component. // So, apply will be autogenerated for the different behaviors based on their injects. // Or do it even smarter? // So, since I'd like to make components structs in the future and store them somewhere // central (optionally), these can actually reference a global storage for them. // So this just adds the behavior Acting.AddTo(factory, null, Algos.SimpleAlgo, Order.Player); Moving.AddTo(factory); Digging.AddTo(factory); Pushable.AddTo(factory); Attacking.AddTo(factory, Attacking.GetTargetProviderFromInventory, Layers.REAL, Faction.Enemy | Faction.Environment); Attackable.AddTo(factory, Attackness.ALWAYS); Damageable.AddTo(factory, new Health(5)); Displaceable.AddTo(factory, Layers.BLOCK); Ticking.AddTo(factory); FactionComponent.AddTo(factory, Faction.Player); Transform.AddTo(factory, Layers.REAL, TransformFlags.Default); Inventory.AddTo(factory); Inventory.AddInitTo(factory); // TODO: pass this an action Controllable.AddTo(factory, // The default action is the AttackDigMove action. Action.Compose(Attacking.Action, Digging.Action, Moving.Action)); // TODO: rename the namespaces Stats.AddTo(factory, Registry.Global.Stats._map); }
public static void Main() { Hopper.Core.Main.Init(); Hopper.TestContent.Main.Init(); attackerFactory = new EntityFactory(); Transform.AddTo(attackerFactory, Layers.REAL, 0); Stats.AddTo(attackerFactory, Registry.Global.Stats._map); Attacking.AddTo(attackerFactory, entity => BufferedAttackTargetProvider.Simple, Layers.REAL, Faction.Any).SkipEmptyAttackPreset(); World.Global = new World(3, 3); var attacker = World.Global.SpawnEntity(attackerFactory, new IntVector2(0, 0)); attacker.Attack(IntVector2.Right); }
public AttackingTests() { InitScript.Init(); // attacking requires stats and transform attackerFactory = new EntityFactory(); Transform.AddTo(attackerFactory, Layers.REAL, 0); Stats.AddTo(attackerFactory, Registry.Global.Stats._map); Attacking.AddTo(attackerFactory, entity => BufferedAttackTargetProvider.Simple, Layers.REAL, Faction.Any).SkipEmptyAttackPreset(); attackedFactory = new EntityFactory(); Transform.AddTo(attackedFactory, Layers.REAL, 0); FactionComponent.AddTo(attackedFactory, Faction.Environment); Stats.AddTo(attackedFactory, Registry.Global.Stats._map); Attackable.AddTo(attackedFactory, Attackness.ALWAYS); }
public static void AddComponents(Entity subject, System.Action <Acting.Context> Algorithm, params Step[] sequenceSteps) { Stats.AddTo(subject, Registry.Global.Stats._map); Transform.AddTo(subject, Layers.REAL, TransformFlags.Default); FactionComponent.AddTo(subject, Faction.Enemy); Acting.AddTo(subject, Sequential.CalculateAction, Algorithm, Order.Entity); Moving.AddTo(subject); Ticking.AddTo(subject); Pushable.AddTo(subject); Attacking.AddTo(subject, entity => BufferedAttackTargetProvider.Simple, Layers.REAL, Faction.Player); Sequential.AddTo(subject, new Sequence(sequenceSteps)); Attackable.AddTo(subject, Attackness.ALWAYS); Damageable.AddTo(subject, new Health(1)); Displaceable.AddTo(subject, Layers.BLOCK); MoreChains.AddTo(subject, Registry.Global.MoreChains._map); }