private static void Drop( Comps.Inventory inventoryComp, Comps.Position positionComp, Ecs.Registry registry ) { foreach (KeyValuePair <Comps.Item.Kind, StorageInfo> pair in inventoryComp.data) { Comps.Item.Kind itemKind = pair.Key; StorageInfo storageInfo = pair.Value; for (int i = 0; i < storageInfo.Count; i++) { Entity itemEntity = Factories.Item.Create( itemKind, positionComp.data, registry ); registry.AssignComponent( itemEntity, new Comps.Velocity { data = 20 * Global.random.NextPhysicalVector2(), decay = 0.8f } ); } } }
public static Entity Create( Comps.Item.Kind kind, PhysicalVector2 position, Ecs.Registry registry ) { var result = registry.CreateEntity(); registry.AssignComponent( result, new Comps.Item { kind = kind } ); registry.AssignComponent( result, new Comps.Position { data = position } ); // TODO: Figure out what shape to assign registry.AssignComponent( result, new Comps.Shapes.Rectangle { data = new Physical.Rectangle(64.0f, 64.0f) } ); return(result); }
private static bool ShouldRemoveAfterUse(Comps.Item.Kind itemKind) { switch (itemKind) { case Comps.Item.Kind.Bow: case Comps.Item.Kind.Sword: case Comps.Item.Kind.RedKey: case Comps.Item.Kind.BlueKey: case Comps.Item.Kind.GreenKey: case Comps.Item.Kind.PurpleKey: case Comps.Item.Kind.YellowKey: return(false); default: return(true); } }